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

EZP-30543: Removed Dynamic Settings functionality from kernel #34

Closed
wants to merge 13 commits into from
Closed
2 changes: 2 additions & 0 deletions doc/bc/changes-1.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,8 @@ Changes affecting version compatibility with deprecated ezpublish-kernel version

* Legacy (SQL) Search Engine will no longer treat deprecated `%` as a search wildcard. Use `*` instead.

* Dynamic Settings feature has been dropped. It was conceptually not compatible with Symfony's Container. Consider injecting `\eZ\Publish\Core\MVC\ConfigResolverInterface` instead and using `getParameter` method to fetch SiteAccess dependent settings.

## Deprecated features

* Using SiteAccess-aware `pagelayout` setting is derecated, use `page_layout` instead.
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Security\PolicyProvider\PoliciesConfigBuilder;
use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Security\PolicyProvider\PolicyProviderInterface;
use eZ\Bundle\EzPublishCoreBundle\SiteAccess\SiteAccessConfigurationFilter;
use eZ\Publish\Core\MVC\Symfony\MVCEvents;
use eZ\Publish\Core\QueryType\QueryType;
use eZ\Publish\SPI\MVC\EventSubscriber\ConfigScopeChangeSubscriber;
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
use Symfony\Component\Filesystem\Filesystem;
Expand Down Expand Up @@ -141,6 +143,16 @@ public function load(array $configs, ContainerBuilder $container)

$container->registerForAutoconfiguration(QueryType::class)
->addTag(QueryTypePass::QUERY_TYPE_SERVICE_TAG);

$container->registerForAutoconfiguration(ConfigScopeChangeSubscriber::class)
->addTag(
'kernel.event_listener',
['method' => 'onConfigScopeChange', 'event' => MVCEvents::CONFIG_SCOPE_CHANGE]
)
->addTag(
'kernel.event_listener',
['method' => 'onConfigScopeChange', 'event' => MVCEvents::CONFIG_SCOPE_RESTORE]
);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
namespace eZ\Bundle\EzPublishCoreBundle\EventListener;

use eZ\Publish\API\Repository\Values\Content\Location;
use eZ\Publish\Core\MVC\ConfigResolverInterface;
use eZ\Publish\Core\MVC\Symfony\View\CachableView;
use eZ\Publish\Core\MVC\Symfony\View\LocationValueView;
use eZ\Publish\Core\MVC\Symfony\View\View;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\ResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;
Expand All @@ -17,31 +17,12 @@
*/
class CacheViewResponseListener implements EventSubscriberInterface
{
/**
* True if view cache is enabled, false if it is not.
*
* @var bool
*/
private $enableViewCache;
/** @var \eZ\Publish\Core\MVC\ConfigResolverInterface */
private $configResolver;

/**
* True if TTL cache is enabled, false if it is not.
* @var bool
*/
private $enableTtlCache;

/**
* Default ttl for ttl cache.
*
* @var int
*/
private $defaultTtl;

public function __construct($enableViewCache, $enableTtlCache, $defaultTtl)
public function __construct(ConfigResolverInterface $configResolver)
{
$this->enableViewCache = $enableViewCache;
$this->enableTtlCache = $enableTtlCache;
$this->defaultTtl = $defaultTtl;
$this->configResolver = $configResolver;
}

public static function getSubscribedEvents()
Expand All @@ -55,7 +36,8 @@ public function configureCache(ResponseEvent $event)
return;
}

if (!$this->enableViewCache || !$view->isCacheEnabled()) {
$isViewCacheEnabled = $this->configResolver->getParameter('content.view_cache');
if (!$isViewCacheEnabled || !$view->isCacheEnabled()) {
return;
}

Expand All @@ -66,8 +48,10 @@ public function configureCache(ResponseEvent $event)
}

$response->setPublic();
if ($this->enableTtlCache && !$response->headers->hasCacheControlDirective('s-maxage')) {
$response->setSharedMaxAge($this->defaultTtl);

$isTtlCacheEnabled = $this->configResolver->getParameter('content.ttl_cache');
if ($isTtlCacheEnabled && !$response->headers->hasCacheControlDirective('s-maxage')) {
$response->setSharedMaxAge($this->configResolver->getParameter('content.default_ttl'));
}
}
}
Loading