diff --git a/eZ/Bundle/EzPublishCoreBundle/DependencyInjection/Security/PolicyProvider/PoliciesConfigBuilder.php b/eZ/Bundle/EzPublishCoreBundle/DependencyInjection/Security/PolicyProvider/PoliciesConfigBuilder.php index c7a72c1716e..c2f6dd98137 100644 --- a/eZ/Bundle/EzPublishCoreBundle/DependencyInjection/Security/PolicyProvider/PoliciesConfigBuilder.php +++ b/eZ/Bundle/EzPublishCoreBundle/DependencyInjection/Security/PolicyProvider/PoliciesConfigBuilder.php @@ -14,23 +14,28 @@ class PoliciesConfigBuilder extends ContainerConfigBuilder { public function addConfig(array $config) { - $policyMap = []; $previousPolicyMap = []; + if ($this->containerBuilder->hasParameter('ezpublish.api.role.policy_map')) { + $previousPolicyMap = $this->containerBuilder->getParameter('ezpublish.api.role.policy_map'); + } + // We receive limitations as values, but we want them as keys to be used by isset(). foreach ($config as $module => $functionArray) { foreach ($functionArray as $function => $limitationCollection) { - $policyMap[$module][$function] = array_fill_keys((array)$limitationCollection, true); - } - } + if (null !== $limitationCollection && $this->policyExists($previousPolicyMap, $module, $function)) { + $limitations = array_merge_recursive($previousPolicyMap[$module][$function], array_fill_keys((array)$limitationCollection, true)); + } else { + $limitations = array_fill_keys((array)$limitationCollection, true); + } - if ($this->containerBuilder->hasParameter('ezpublish.api.role.policy_map')) { - $previousPolicyMap = $this->containerBuilder->getParameter('ezpublish.api.role.policy_map'); + $previousPolicyMap[$module][$function] = $limitations; + } } $this->containerBuilder->setParameter( 'ezpublish.api.role.policy_map', - array_merge_recursive($previousPolicyMap, $policyMap) + $previousPolicyMap ); } @@ -38,4 +43,18 @@ public function addResource(ResourceInterface $resource) { $this->containerBuilder->addResource($resource); } + + /** + * Checks if policy for module and function exist in Policy Map. + * + * @param array $policyMap + * @param string $module + * @param string $function + * + * @return bool + */ + private function policyExists(array $policyMap, $module, $function) + { + return array_key_exists($module, $policyMap) && array_key_exists($function, $policyMap[$module]); + } } diff --git a/eZ/Bundle/EzPublishCoreBundle/Resources/views/content_fields.html.twig b/eZ/Bundle/EzPublishCoreBundle/Resources/views/content_fields.html.twig index 310d335e69d..607808793cd 100644 --- a/eZ/Bundle/EzPublishCoreBundle/Resources/views/content_fields.html.twig +++ b/eZ/Bundle/EzPublishCoreBundle/Resources/views/content_fields.html.twig @@ -422,8 +422,8 @@
{% set imageAlias = ez_image_alias( field, versionInfo, parameters.alias|default( 'original' ) ) %} {% set src = imageAlias ? asset( imageAlias.uri ) : "//:0" %} - {% set width = parameters.width is defined ? parameters.width : imageAlias.width %} - {% set height = parameters.height is defined ? parameters.height : imageAlias.height %} + {% set width = parameters.width is defined ? parameters.width : (imageAlias ? imageAlias.width : '') %} + {% set height = parameters.height is defined ? parameters.height : (imageAlias ? imageAlias.height : '') %} {{ field.value.alternativeText }}
{% endif %} diff --git a/eZ/Publish/Core/MVC/Symfony/Templating/Twig/Extension/ImageExtension.php b/eZ/Publish/Core/MVC/Symfony/Templating/Twig/Extension/ImageExtension.php index 0cdee6c1a70..2d20b567a7d 100644 --- a/eZ/Publish/Core/MVC/Symfony/Templating/Twig/Extension/ImageExtension.php +++ b/eZ/Publish/Core/MVC/Symfony/Templating/Twig/Extension/ImageExtension.php @@ -52,7 +52,7 @@ public function getFunctions() * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo * @param string $variationName * - * @return \eZ\Publish\SPI\Variation\Values\Variation + * @return \eZ\Publish\SPI\Variation\Values\Variation|null */ public function getImageVariation(Field $field, VersionInfo $versionInfo, $variationName) {