diff --git a/src/Client/RedmineClient.php b/src/Client/RedmineClient.php index 2ef6294..3b85418 100644 --- a/src/Client/RedmineClient.php +++ b/src/Client/RedmineClient.php @@ -5,6 +5,7 @@ namespace Magdev\RedmineBundle\Client; use Redmine\Client\Psr18Client; use GuzzleHttp\Client as GuzzleClient; use GuzzleHttp\Psr7\HttpFactory as GuzzleHttpFactory; +use Redmine\Api; use Symfony\Contracts\Cache\ItemInterface; use Symfony\Contracts\Cache\TagAwareCacheInterface; @@ -49,4 +50,9 @@ final class RedmineClient } return $this->client; } + + public function getApi(string $name): Api + { + return $this->getClient()->getApi($name); + } } diff --git a/src/DependencyInjection/MagdevRedmineExtension.php b/src/DependencyInjection/MagdevRedmineExtension.php index 26302bd..5765a76 100644 --- a/src/DependencyInjection/MagdevRedmineExtension.php +++ b/src/DependencyInjection/MagdevRedmineExtension.php @@ -17,24 +17,6 @@ final class MagdevRedmineExtension extends Extension { $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) - ->addMethodCall('setUrl', [$connection['url']]) - ->addMethodCall('setApiKey', [$connection['apikey']]); - - $container->registerAliasForArgument($id, RedmineClient::class, "{$name}Client"); - - if ($name === $config['default_connection']) { - $container->setAlias(RedmineClient::class, $id); - } - } - $loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); $loader->load('services.yaml'); }