eZ content repository uses the concept of roles and policies in order to authorize a user to do something (e.g. read content).

It is possible for any bundle to expose available policies via a PolicyProvider which can be added to EzPublishCoreBundle's DIC extension.


PolicyProvider is an object providing a hash containing declared modules, functions and limitations.

Policies configuration hash contains declared these modules, functions and limitations.
First level key is the module name, value is a hash of available functions, with function name as key.
Function value is an array of available limitations, identified by the alias declared in LimitationType service tag.
If no limitation is provided, value can be null or an empty array.

    "content" => [
        "read" => ["Class", "ParentClass", "Node", "Language"],
        "edit" => ["Class", "ParentClass", "Language"]
    "custom_module" => [
        "custom_function_1" => null,
        "custom_function_2" => ["CustomLimitation"]

Limitations need to be implemented as limitation types and declared as services identified with ezpublish.limitationType tag. Name provided in the hash for each limitation is the same value set in alias attribute in the service tag.


namespace Acme\FooBundle\AcmeFooBundle\Security;

use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\ConfigBuilderInterface;
use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Security\PolicyProvider\PolicyProviderInterface;

class MyPolicyProvider implements PolicyProviderInterface
    public function addPolicies(ConfigBuilderInterface $configBuilder)
             "custom_module" => [
                 "custom_function_1" => null,
                 "custom_function_2" => ["CustomLimitation"],


An abstract class based on YAML is provided: eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Security\PolicyProvider\YamlPolicyProvider.
It defines an abstract getFiles() method.

Extend YamlPolicyProvider and implement getFiles() to return absolute paths to your YAML files.

namespace Acme\FooBundle\AcmeFooBundle\Security;

use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Security\PolicyProvider\YamlPolicyProvider;

class MyPolicyProvider extends YamlPolicyProvider
    protected function getFiles()
        return [
             __DIR__ . '/../Resources/config/policies.yml',
    custom_function_1: ~
    custom_function_2: [CustomLimitation]

Extending existing policies

A PolicyProvider may provide new functions to a module, and additional limitations to an existing function. 
It is however strongly encouraged to add functions to your own policy modules.

It is not possible to remove an existing module, function or limitation from a policy.

Integrating the PolicyProvider into EzPublishCoreBundle

For a PolicyProvider to be active, it must be properly declared in EzPublishCoreBundle.
A bundle just has to retrieve CoreBundle's DIC extension and call 
addPolicyProvider(). This must be done in bundle's build() method.

namespace Acme\FooBundle\AcmeFooBundle;

use Symfony\Component\HttpKernel\Bundle\Bundle;

class AcmeFooBundle extends Bundle
    public function build(ContainerBuilder $container)

        // ...
        // Retrieve "ezpublish" container extension.
        $eZExtension = $container->getExtension('ezpublish');
        // Add the policy provider.
        $eZExtension->addPolicyProvider(new MyPolicyProvider());

Core policies

Policies used internally in repository services are defined in EzPublishCoreBundle/Resources/config/policies.yml.