Skip to content

Commit

Permalink
EZP-30543: Removed Dynamic Settings functionality from kernel (#35)
Browse files Browse the repository at this point in the history
* Removed dynamic settings usage from CacheViewResponseListener

* Removed dynamic settings usage from AssetMapper

* Removed dynamic settings usage from HTTPHandler, MailToHandler

* Removed dynamic settings usage from LegacyStorageImageFileList

* Removed dynamic settings usage from FieldBlockRenderer

* Removed dynamic settings usage from LocalAdapter

* Removed dynamic settings usage from OptionsProvider

* Added ConfigScopeChangeSubscriber

* Removed dynamic settings usage from IO Data Handlers

* Removed dynamic settings usage from IO Service

* Removed Dynamic Settings

* Removed ComplexSettingsPass

* Addressed review comments

* Fixed invalid return statements

* Fixed invalid eZ\Publish\Core\FieldType\ImageAsset\AssetMapper service definition

* Type hinted on IOServiceInterface instead of concrete implementation in DownloadController

* Addressed issues from code review
  • Loading branch information
webhdx authored Apr 2, 2020
1 parent d2ada36 commit 709bb3d
Show file tree
Hide file tree
Showing 42 changed files with 1,071 additions and 1,126 deletions.
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 @@ -143,6 +145,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((int) $this->configResolver->getParameter('content.default_ttl'));
}
}
}
Loading

0 comments on commit 709bb3d

Please sign in to comment.