Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DO NOT MERGE, FOR QA ONLY! EZP-29749: As an Administrator I want to configure Imagine ProxyResolver #2506

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
44 changes: 44 additions & 0 deletions eZ/Bundle/EzPublishCoreBundle/Imagine/ResolverFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

/**
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
namespace eZ\Bundle\EzPublishCoreBundle\Imagine;

use eZ\Publish\Core\MVC\ConfigResolverInterface;
use Liip\ImagineBundle\Imagine\Cache\Resolver\ResolverInterface;

class ResolverFactory
{
/**
* @var \Liip\ImagineBundle\Imagine\Cache\Resolver\ResolverInterface
*/
private $resolver;

/**
* @var string
*/
private $proxyResolverClass;

/**
* @var array
*/
private $hosts = [];

public function __construct(ConfigResolverInterface $configResolver, ResolverInterface $resolver, $proxyResolverClass)
{
$this->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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,8 @@ parameters:
resize: "-resize {1}"
optimize: "-strip"

ezsettings.default.image_host: ''

###
# default ezpage settings
##
Expand Down
15 changes: 15 additions & 0 deletions eZ/Bundle/EzPublishCoreBundle/Resources/config/image.yml
Original file line number Diff line number Diff line change
@@ -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
Copy link
Contributor

@andrerom andrerom Dec 20, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not how we role on Symfony 3x ;)

ref: 4896acf#diff-5f3dc6c12e2a442a9d234416275f9555

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
Expand Down Expand Up @@ -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'
- '@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:
Expand Down