From 295e02fcc8c0a5461b0f4b1ab97816ae679a2f72 Mon Sep 17 00:00:00 2001 From: Kamil Madejski Date: Wed, 14 Nov 2018 16:22:08 +0100 Subject: [PATCH 1/3] EZP-29749: As an Administrator I want to configure Imagine ProxyResolver --- .../Configuration/Parser/Image.php | 5 +++ .../Imagine/ResolverFactory.php | 40 +++++++++++++++++++ .../Resources/config/default_settings.yml | 2 + .../Resources/config/image.yml | 15 +++++++ 4 files changed, 62 insertions(+) create mode 100644 eZ/Bundle/EzPublishCoreBundle/Imagine/ResolverFactory.php diff --git a/eZ/Bundle/EzPublishCoreBundle/DependencyInjection/Configuration/Parser/Image.php b/eZ/Bundle/EzPublishCoreBundle/DependencyInjection/Configuration/Parser/Image.php index af64b98e68e..a8c5b5fe01e 100644 --- a/eZ/Bundle/EzPublishCoreBundle/DependencyInjection/Configuration/Parser/Image.php +++ b/eZ/Bundle/EzPublishCoreBundle/DependencyInjection/Configuration/Parser/Image.php @@ -115,12 +115,17 @@ function ($v) { ->end() ->end() ->end() + ->end() + ->scalarNode('image_host') + ->info('Images host. All system images URLs are prefixed with given host if configured.') + ->example('https://ezplatform.com') ->end(); } public function preMap(array $config, ContextualizerInterface $contextualizer) { $contextualizer->mapConfigArray('image_variations', $config); + $contextualizer->mapSetting('image_host', $config); } public function mapConfig(array &$scopeSettings, $currentScope, ContextualizerInterface $contextualizer) diff --git a/eZ/Bundle/EzPublishCoreBundle/Imagine/ResolverFactory.php b/eZ/Bundle/EzPublishCoreBundle/Imagine/ResolverFactory.php new file mode 100644 index 00000000000..8a784d242e7 --- /dev/null +++ b/eZ/Bundle/EzPublishCoreBundle/Imagine/ResolverFactory.php @@ -0,0 +1,40 @@ +resolver = $resolver; + $this->proxyResolverClass = $proxyResolverClass; + + if ($configResolver->hasParameter('image_host') && + ($imageHost = $configResolver->getParameter('image_host')) !== '') { + $this->hosts = [$imageHost]; + } + } + + public function createCacheResolver() + { + return new $this->proxyResolverClass($this->resolver, $this->hosts); + } +} diff --git a/eZ/Bundle/EzPublishCoreBundle/Resources/config/default_settings.yml b/eZ/Bundle/EzPublishCoreBundle/Resources/config/default_settings.yml index 97112cb9c4b..996fe2de777 100644 --- a/eZ/Bundle/EzPublishCoreBundle/Resources/config/default_settings.yml +++ b/eZ/Bundle/EzPublishCoreBundle/Resources/config/default_settings.yml @@ -240,6 +240,8 @@ parameters: resize: "-resize {1}" optimize: "-strip" + ezsettings.default.image_host: '' + ### # default ezpage settings ## diff --git a/eZ/Bundle/EzPublishCoreBundle/Resources/config/image.yml b/eZ/Bundle/EzPublishCoreBundle/Resources/config/image.yml index ad33469c1f6..abd681de286 100644 --- a/eZ/Bundle/EzPublishCoreBundle/Resources/config/image.yml +++ b/eZ/Bundle/EzPublishCoreBundle/Resources/config/image.yml @@ -1,5 +1,8 @@ parameters: + liip_imagine.filter.configuration.class: eZ\Bundle\EzPublishCoreBundle\Imagine\Filter\FilterConfiguration + liip_imagine.cache_resolver.proxy.class: Liip\ImagineBundle\Imagine\Cache\Resolver\ProxyResolver ezpublish.image_alias.imagine.binary_loader.class: eZ\Bundle\EzPublishCoreBundle\Imagine\BinaryLoader + ezpublish.image_alias.imagine.decorated_cache_resolver_factory.class: eZ\Bundle\EzPublishCoreBundle\Imagine\ResolverFactory ezpublish.image_alias.imagine.cache_resolver.class: eZ\Bundle\EzPublishCoreBundle\Imagine\IORepositoryResolver ezpublish.image_alias.imagine.cache.alias_generator_decorator.class: eZ\Bundle\EzPublishCoreBundle\Imagine\Cache\AliasGeneratorDecorator ezpublish.image_alias.imagine.variation.imagine_alias_generator.class: eZ\Bundle\EzPublishCoreBundle\Imagine\Variation\ImagineAwareAliasGenerator @@ -81,6 +84,18 @@ services: tags: - { name: liip_imagine.cache.resolver, resolver: ezpublish } + ezpublish.image_alias.imagine.cache_resolver_decorator_factory: + class: '%ezpublish.image_alias.imagine.decorated_cache_resolver_factory.class%' + arguments: + - '@ezpublish.config.resolver.chain' + - '@ezpublish.image_alias.imagine.cache_resolver_decorator.inner' + - '%liip_imagine.cache_resolver.proxy.class%' + + ezpublish.image_alias.imagine.cache_resolver_decorator: + class: '%liip_imagine.cache_resolver.proxy.class%' + factory: 'ezpublish.image_alias.imagine.cache_resolver_decorator_factory:createCacheResolver' + decorates: ezpublish.image_alias.imagine.cache_resolver + ezpublish.image_alias.imagine.cache.alias_generator_decorator: class: '%ezpublish.image_alias.imagine.cache.alias_generator_decorator.class%' arguments: From dae85a1e3a4a2eec6d113bed949b5cc1d9f43c9a Mon Sep 17 00:00:00 2001 From: Kamil Madejski Date: Wed, 14 Nov 2018 16:26:37 +0100 Subject: [PATCH 2/3] fixup! EZP-29749: As an Administrator I want to configure Imagine ProxyResolver --- eZ/Bundle/EzPublishCoreBundle/Imagine/ResolverFactory.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/eZ/Bundle/EzPublishCoreBundle/Imagine/ResolverFactory.php b/eZ/Bundle/EzPublishCoreBundle/Imagine/ResolverFactory.php index 8a784d242e7..96960e30df6 100644 --- a/eZ/Bundle/EzPublishCoreBundle/Imagine/ResolverFactory.php +++ b/eZ/Bundle/EzPublishCoreBundle/Imagine/ResolverFactory.php @@ -1,5 +1,9 @@ Date: Fri, 16 Nov 2018 11:38:13 +0100 Subject: [PATCH 3/3] Update eZ/Bundle/EzPublishCoreBundle/Resources/config/image.yml Co-Authored-By: kmadejski --- eZ/Bundle/EzPublishCoreBundle/Resources/config/image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eZ/Bundle/EzPublishCoreBundle/Resources/config/image.yml b/eZ/Bundle/EzPublishCoreBundle/Resources/config/image.yml index abd681de286..747863eeca4 100644 --- a/eZ/Bundle/EzPublishCoreBundle/Resources/config/image.yml +++ b/eZ/Bundle/EzPublishCoreBundle/Resources/config/image.yml @@ -87,7 +87,7 @@ services: ezpublish.image_alias.imagine.cache_resolver_decorator_factory: class: '%ezpublish.image_alias.imagine.decorated_cache_resolver_factory.class%' arguments: - - '@ezpublish.config.resolver.chain' + - '@ezpublish.config.resolver' - '@ezpublish.image_alias.imagine.cache_resolver_decorator.inner' - '%liip_imagine.cache_resolver.proxy.class%'