From 7efb3b3a86b81a092f69334f45025dca130118a9 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Tue, 19 Jul 2016 17:17:37 +0200 Subject: [PATCH] Created cli-specific services config file --- config/autoload/services.global.php | 11 +---------- module/CLI/config/services.config.php | 20 ++++++++++++++++++++ src/Service/UrlShortener.php | 2 +- 3 files changed, 22 insertions(+), 11 deletions(-) create mode 100644 module/CLI/config/services.config.php diff --git a/config/autoload/services.global.php b/config/autoload/services.global.php index 81c5669f..bf5b28e4 100644 --- a/config/autoload/services.global.php +++ b/config/autoload/services.global.php @@ -1,5 +1,4 @@ [ 'factories' => [ Expressive\Application::class => Container\ApplicationFactory::class, - Console\Application::class => CLI\Factory\ApplicationFactory::class, // Url helpers Helper\UrlHelper::class => Helper\UrlHelperFactory::class, @@ -42,12 +39,6 @@ return [ Service\ShortUrlService::class => AnnotatedFactory::class, Cache::class => CacheFactory::class, - // Cli commands - CLI\Command\GenerateShortcodeCommand::class => AnnotatedFactory::class, - CLI\Command\ResolveUrlCommand::class => AnnotatedFactory::class, - CLI\Command\ListShortcodesCommand::class => AnnotatedFactory::class, - CLI\Command\GetVisitsCommand::class => AnnotatedFactory::class, - // Middleware Middleware\Routable\RedirectMiddleware::class => AnnotatedFactory::class, ], @@ -56,7 +47,7 @@ return [ 'httpClient' => GuzzleHttp\Client::class, Router\RouterInterface::class => Router\FastRouteRouter::class, AnnotatedFactory::CACHE_SERVICE => Cache::class, - ] + ], ], ]; diff --git a/module/CLI/config/services.config.php b/module/CLI/config/services.config.php new file mode 100644 index 00000000..5c10f5a9 --- /dev/null +++ b/module/CLI/config/services.config.php @@ -0,0 +1,20 @@ + [ + 'factories' => [ + Console\Application::class => CLI\Factory\ApplicationFactory::class, + + CLI\Command\GenerateShortcodeCommand::class => AnnotatedFactory::class, + CLI\Command\ResolveUrlCommand::class => AnnotatedFactory::class, + CLI\Command\ListShortcodesCommand::class => AnnotatedFactory::class, + CLI\Command\GetVisitsCommand::class => AnnotatedFactory::class, + ], + ], + +]; diff --git a/src/Service/UrlShortener.php b/src/Service/UrlShortener.php index 3c15a0f6..c538110d 100644 --- a/src/Service/UrlShortener.php +++ b/src/Service/UrlShortener.php @@ -44,7 +44,7 @@ class UrlShortener implements UrlShortenerInterface ) { $this->httpClient = $httpClient; $this->em = $em; - $this->chars = $chars; + $this->chars = empty($chars) ? self::DEFAULT_CHARS : $chars; } /**