From 54cb40f6ed0e8e4a3f389a26dd422353a3010439 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sat, 22 Jul 2017 13:41:41 +0200 Subject: [PATCH] Replaced more ussages of AnnotatedFactory by ConfigAbstractFactory --- bin/install | 21 ++++++++++---- bin/update | 21 ++++++++++---- .../src/Factory/InstallApplicationFactory.php | 4 +-- module/Common/config/dependencies.config.php | 28 +++++++++++++------ .../src/Middleware/LocaleMiddleware.php | 7 ----- .../Common/src/Service/IpLocationResolver.php | 7 ----- .../Common/src/Service/PreviewGenerator.php | 10 ------- .../Twig/Extension/TranslatorExtension.php | 7 ----- 8 files changed, 53 insertions(+), 52 deletions(-) diff --git a/bin/install b/bin/install index 43a07cd3..e8ecb3c9 100755 --- a/bin/install +++ b/bin/install @@ -1,9 +1,11 @@ #!/usr/bin/env php [ - Application::class => InstallApplicationFactory::class, - Filesystem::class => InvokableFactory::class, - QuestionHelper::class => InvokableFactory::class, -]]); +$container = new ServiceManager([ + 'factories' => [ + Application::class => InstallApplicationFactory::class, + Filesystem::class => InvokableFactory::class, + QuestionHelper::class => InvokableFactory::class, + ], + 'services' => [ + 'config' => [ + ConfigAbstractFactory::class => [ + DatabaseConfigCustomizerPlugin::class => [QuestionHelper::class, Filesystem::class] + ], + ], + ], +]); $container->build(Application::class)->run(); diff --git a/bin/update b/bin/update index 164e20b0..d4203528 100755 --- a/bin/update +++ b/bin/update @@ -1,9 +1,11 @@ #!/usr/bin/env php [ - Application::class => InstallApplicationFactory::class, - Filesystem::class => InvokableFactory::class, - QuestionHelper::class => InvokableFactory::class, -]]); +$container = new ServiceManager([ + 'factories' => [ + Application::class => InstallApplicationFactory::class, + Filesystem::class => InvokableFactory::class, + QuestionHelper::class => InvokableFactory::class, + ], + 'services' => [ + 'config' => [ + ConfigAbstractFactory::class => [ + DatabaseConfigCustomizerPlugin::class => [QuestionHelper::class, Filesystem::class] + ], + ], + ], +]); $container->build(Application::class, ['isUpdate' => true])->run(); diff --git a/module/CLI/src/Factory/InstallApplicationFactory.php b/module/CLI/src/Factory/InstallApplicationFactory.php index 742b5b70..387b2321 100644 --- a/module/CLI/src/Factory/InstallApplicationFactory.php +++ b/module/CLI/src/Factory/InstallApplicationFactory.php @@ -1,7 +1,6 @@ get(Filesystem::class), new ConfigCustomizerPluginManager($container, ['factories' => [ - Plugin\DatabaseConfigCustomizerPlugin::class => AnnotatedFactory::class, + Plugin\DatabaseConfigCustomizerPlugin::class => ConfigAbstractFactory::class, Plugin\UrlShortenerConfigCustomizerPlugin::class => DefaultConfigCustomizerPluginFactory::class, Plugin\LanguageConfigCustomizerPlugin::class => DefaultConfigCustomizerPluginFactory::class, Plugin\ApplicationConfigCustomizerPlugin::class => DefaultConfigCustomizerPluginFactory::class, diff --git a/module/Common/config/dependencies.config.php b/module/Common/config/dependencies.config.php index 06250b3a..dd64b026 100644 --- a/module/Common/config/dependencies.config.php +++ b/module/Common/config/dependencies.config.php @@ -1,45 +1,44 @@ [ - 'invokables' => [ - Filesystem::class => Filesystem::class, - ], 'factories' => [ EntityManager::class => Factory\EntityManagerFactory::class, GuzzleHttp\Client::class => InvokableFactory::class, Cache::class => Factory\CacheFactory::class, 'Logger_Shlink' => Factory\LoggerFactory::class, + Filesystem::class => InvokableFactory::class, Translator::class => Factory\TranslatorFactory::class, - TranslatorExtension::class => AnnotatedFactory::class, - LocaleMiddleware::class => AnnotatedFactory::class, + TranslatorExtension::class => ConfigAbstractFactory::class, + LocaleMiddleware::class => ConfigAbstractFactory::class, Image\ImageBuilder::class => Image\ImageBuilderFactory::class, - Service\IpLocationResolver::class => AnnotatedFactory::class, - Service\PreviewGenerator::class => AnnotatedFactory::class, + Service\IpLocationResolver::class => ConfigAbstractFactory::class, + Service\PreviewGenerator::class => ConfigAbstractFactory::class, ], 'aliases' => [ 'em' => EntityManager::class, 'httpClient' => GuzzleHttp\Client::class, 'translator' => Translator::class, 'logger' => LoggerInterface::class, - AnnotatedFactory::CACHE_SERVICE => Cache::class, Logger::class => 'Logger_Shlink', LoggerInterface::class => 'Logger_Shlink', ], @@ -48,4 +47,15 @@ return [ ], ], + ConfigAbstractFactory::class => [ + TranslatorExtension::class => ['translator'], + LocaleMiddleware::class => ['translator'], + Service\IpLocationResolver::class => ['httpClient'], + Service\PreviewGenerator::class => [ + ImageBuilder::class, + Filesystem::class, + 'config.preview_generation.files_location', + ], + ], + ]; diff --git a/module/Common/src/Middleware/LocaleMiddleware.php b/module/Common/src/Middleware/LocaleMiddleware.php index 0cb81502..fe0ff2c6 100644 --- a/module/Common/src/Middleware/LocaleMiddleware.php +++ b/module/Common/src/Middleware/LocaleMiddleware.php @@ -1,7 +1,6 @@ translator = $translator; diff --git a/module/Common/src/Service/IpLocationResolver.php b/module/Common/src/Service/IpLocationResolver.php index 0bfa80ce..287760a3 100644 --- a/module/Common/src/Service/IpLocationResolver.php +++ b/module/Common/src/Service/IpLocationResolver.php @@ -1,7 +1,6 @@ httpClient = $httpClient; diff --git a/module/Common/src/Service/PreviewGenerator.php b/module/Common/src/Service/PreviewGenerator.php index 03fa392f..d85bf50b 100644 --- a/module/Common/src/Service/PreviewGenerator.php +++ b/module/Common/src/Service/PreviewGenerator.php @@ -1,10 +1,8 @@ location = $location; diff --git a/module/Common/src/Twig/Extension/TranslatorExtension.php b/module/Common/src/Twig/Extension/TranslatorExtension.php index 48ee3f11..807c3099 100644 --- a/module/Common/src/Twig/Extension/TranslatorExtension.php +++ b/module/Common/src/Twig/Extension/TranslatorExtension.php @@ -1,7 +1,6 @@ translator = $translator;