Updated GeoLite2 db reader service so that it is lazily created

This commit is contained in:
Alejandro Celaya 2018-11-12 20:22:42 +01:00
parent de0470d200
commit e915b7e499
3 changed files with 32 additions and 0 deletions

View file

@ -23,6 +23,12 @@ return [
Container\ApplicationConfigInjectionDelegator::class,
],
],
'lazy_services' => [
'proxies_target_dir' => 'data/proxies',
'proxies_namespace' => 'ShlinkProxy',
'write_proxy_files' => true,
],
],
];

View file

@ -0,0 +1,12 @@
<?php
declare(strict_types=1);
return [
'dependencies' => [
'lazy_services' => [
'write_proxy_files' => false,
],
],
];

View file

@ -14,6 +14,7 @@ use Symfony\Component\Filesystem\Filesystem;
use Zend\I18n\Translator\Translator;
use Zend\ServiceManager\AbstractFactory\ConfigAbstractFactory;
use Zend\ServiceManager\Factory\InvokableFactory;
use Zend\ServiceManager\Proxy\LazyServiceFactory;
return [
@ -56,6 +57,19 @@ return [
'abstract_factories' => [
Factory\DottedAccessConfigAbstractFactory::class,
],
'delegators' => [
// The GeoLite2 db reader has to be lazy so that it does not try to load the DB file at app bootstrapping.
// By doing so, it would fail the first time shlink tries to download it.
Reader::class => [
LazyServiceFactory::class,
],
],
'lazy_services' => [
'class_map' => [
Reader::class => Reader::class,
],
],
],
ConfigAbstractFactory::class => [