You've already forked redmine-bundle
35 lines
1.2 KiB
PHP
35 lines
1.2 KiB
PHP
<?php declare(strict_types=1);
|
|
|
|
namespace Magdev\RedmineBundle\DependencyInjection;
|
|
|
|
use Magdev\RedmineBundle\Client\RedmineClient;
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
|
use Symfony\Component\DependencyInjection\Extension\Extension;
|
|
|
|
/**
|
|
* @author Marco Grätsch <magdev3.0@gmail.com>
|
|
*/
|
|
final class MagdevRedmineExtension extends Extension
|
|
{
|
|
public function load(array $configs, ContainerBuilder $container)
|
|
{
|
|
$config = $this->processConfiguration(new Configuration(), $configs);
|
|
|
|
if (!isset($config['default_connection'])) {
|
|
$config['default_connection'] = array_key_first($config['connections']);
|
|
}
|
|
|
|
foreach ($config['connections'] as $name => $connection) {
|
|
$id = sprintf('magdev.redmine.%s', $name);
|
|
|
|
$container->register($id, RedmineClient::class)
|
|
->setArguments([$connection['url'], $connection['apikey']]);
|
|
$container->registerAliasForArgument($id, RedmineClient::class, "{$name}Client");
|
|
|
|
if ($name === $config['default_connection']) {
|
|
$container->setAlias(RedmineClient::class, $id);
|
|
}
|
|
}
|
|
}
|
|
}
|