2016-07-19 18:38:41 +03:00
|
|
|
<?php
|
2017-10-12 11:13:20 +03:00
|
|
|
declare(strict_types=1);
|
2017-07-22 14:41:41 +03:00
|
|
|
|
2018-10-18 20:53:50 +03:00
|
|
|
namespace Shlinkio\Shlink\Common;
|
|
|
|
|
2018-11-11 14:40:40 +03:00
|
|
|
use GeoIp2\Database\Reader;
|
2018-10-18 20:53:50 +03:00
|
|
|
use GuzzleHttp\Client as GuzzleClient;
|
2016-08-08 13:07:04 +03:00
|
|
|
use Monolog\Logger;
|
2016-08-08 12:56:19 +03:00
|
|
|
use Psr\Log\LoggerInterface;
|
2018-10-18 20:53:50 +03:00
|
|
|
use RKA\Middleware\IpAddress;
|
2016-08-18 14:20:57 +03:00
|
|
|
use Symfony\Component\Filesystem\Filesystem;
|
2016-07-21 16:08:46 +03:00
|
|
|
use Zend\I18n\Translator\Translator;
|
2017-07-22 14:41:41 +03:00
|
|
|
use Zend\ServiceManager\AbstractFactory\ConfigAbstractFactory;
|
2016-07-19 18:38:41 +03:00
|
|
|
use Zend\ServiceManager\Factory\InvokableFactory;
|
2018-11-12 22:22:42 +03:00
|
|
|
use Zend\ServiceManager\Proxy\LazyServiceFactory;
|
2016-07-19 18:38:41 +03:00
|
|
|
|
|
|
|
return [
|
|
|
|
|
2016-07-31 17:30:05 +03:00
|
|
|
'dependencies' => [
|
2016-07-19 18:38:41 +03:00
|
|
|
'factories' => [
|
2018-10-18 20:53:50 +03:00
|
|
|
GuzzleClient::class => InvokableFactory::class,
|
2017-07-22 14:41:41 +03:00
|
|
|
Filesystem::class => InvokableFactory::class,
|
2018-11-11 14:40:40 +03:00
|
|
|
Reader::class => ConfigAbstractFactory::class,
|
2016-08-08 12:56:19 +03:00
|
|
|
|
2016-08-18 14:20:57 +03:00
|
|
|
Translator::class => Factory\TranslatorFactory::class,
|
2018-10-18 20:53:50 +03:00
|
|
|
Template\Extension\TranslatorExtension::class => ConfigAbstractFactory::class,
|
|
|
|
|
|
|
|
Middleware\LocaleMiddleware::class => ConfigAbstractFactory::class,
|
2018-11-24 14:49:25 +03:00
|
|
|
Middleware\CloseDbConnectionMiddleware::class => ConfigAbstractFactory::class,
|
2018-10-18 20:53:50 +03:00
|
|
|
IpAddress::class => Middleware\IpAddressMiddlewareFactory::class,
|
2016-07-30 14:51:52 +03:00
|
|
|
|
2016-08-18 13:21:26 +03:00
|
|
|
Image\ImageBuilder::class => Image\ImageBuilderFactory::class,
|
|
|
|
|
2018-11-11 14:44:57 +03:00
|
|
|
IpGeolocation\IpApiLocationResolver::class => ConfigAbstractFactory::class,
|
|
|
|
IpGeolocation\GeoLite2LocationResolver::class => ConfigAbstractFactory::class,
|
2018-11-12 22:58:14 +03:00
|
|
|
IpGeolocation\EmptyIpLocationResolver::class => InvokableFactory::class,
|
2018-11-11 15:18:21 +03:00
|
|
|
IpGeolocation\ChainIpLocationResolver::class => ConfigAbstractFactory::class,
|
2018-11-11 23:08:23 +03:00
|
|
|
IpGeolocation\GeoLite2\GeoLite2Options::class => ConfigAbstractFactory::class,
|
|
|
|
IpGeolocation\GeoLite2\DbUpdater::class => ConfigAbstractFactory::class,
|
2018-11-11 15:18:21 +03:00
|
|
|
|
2017-07-22 14:41:41 +03:00
|
|
|
Service\PreviewGenerator::class => ConfigAbstractFactory::class,
|
2016-07-19 18:38:41 +03:00
|
|
|
],
|
|
|
|
'aliases' => [
|
2018-10-18 20:53:50 +03:00
|
|
|
'httpClient' => GuzzleClient::class,
|
2016-07-21 16:08:46 +03:00
|
|
|
'translator' => Translator::class,
|
2018-11-11 21:04:59 +03:00
|
|
|
|
2016-08-08 12:56:19 +03:00
|
|
|
'logger' => LoggerInterface::class,
|
2016-08-12 19:01:09 +03:00
|
|
|
Logger::class => 'Logger_Shlink',
|
|
|
|
LoggerInterface::class => 'Logger_Shlink',
|
2018-11-11 21:04:59 +03:00
|
|
|
|
|
|
|
IpGeolocation\IpLocationResolverInterface::class => IpGeolocation\ChainIpLocationResolver::class,
|
2016-07-19 18:38:41 +03:00
|
|
|
],
|
2017-07-22 14:33:32 +03:00
|
|
|
'abstract_factories' => [
|
|
|
|
Factory\DottedAccessConfigAbstractFactory::class,
|
|
|
|
],
|
2018-11-12 22:22:42 +03:00
|
|
|
'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,
|
|
|
|
],
|
|
|
|
],
|
2016-07-19 18:38:41 +03:00
|
|
|
],
|
|
|
|
|
2017-07-22 14:41:41 +03:00
|
|
|
ConfigAbstractFactory::class => [
|
2018-11-11 14:40:40 +03:00
|
|
|
Reader::class => ['config.geolite2.db_location'],
|
|
|
|
|
2018-10-18 20:53:50 +03:00
|
|
|
Template\Extension\TranslatorExtension::class => ['translator'],
|
|
|
|
Middleware\LocaleMiddleware::class => ['translator'],
|
2018-11-24 14:49:25 +03:00
|
|
|
Middleware\CloseDbConnectionMiddleware::class => ['em'],
|
2018-11-11 15:18:21 +03:00
|
|
|
|
2018-11-11 14:44:57 +03:00
|
|
|
IpGeolocation\IpApiLocationResolver::class => ['httpClient'],
|
|
|
|
IpGeolocation\GeoLite2LocationResolver::class => [Reader::class],
|
2018-11-11 15:18:21 +03:00
|
|
|
IpGeolocation\ChainIpLocationResolver::class => [
|
|
|
|
IpGeolocation\GeoLite2LocationResolver::class,
|
|
|
|
IpGeolocation\IpApiLocationResolver::class,
|
2018-11-12 22:58:14 +03:00
|
|
|
IpGeolocation\EmptyIpLocationResolver::class,
|
2018-11-11 15:18:21 +03:00
|
|
|
],
|
2018-11-11 23:08:23 +03:00
|
|
|
IpGeolocation\GeoLite2\GeoLite2Options::class => ['config.geolite2'],
|
|
|
|
IpGeolocation\GeoLite2\DbUpdater::class => [
|
|
|
|
GuzzleClient::class,
|
|
|
|
Filesystem::class,
|
|
|
|
IpGeolocation\GeoLite2\GeoLite2Options::class,
|
|
|
|
],
|
2018-11-11 15:18:21 +03:00
|
|
|
|
2017-07-22 14:41:41 +03:00
|
|
|
Service\PreviewGenerator::class => [
|
2018-10-18 20:53:50 +03:00
|
|
|
Image\ImageBuilder::class,
|
2017-07-22 14:41:41 +03:00
|
|
|
Filesystem::class,
|
|
|
|
'config.preview_generation.files_location',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
|
2016-07-19 18:38:41 +03:00
|
|
|
];
|