One can call this method from a bundle build() method.
php
public function build(ContainerBuilder $container)
{
$ezExtension = $container->getExtension('ezpublish');
$ezExtension->addPolicyProvider($myPolicyProvider);
}
public addPolicyProvider ( eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Security\PolicyProvider\PolicyProviderInterface $policyProvider ) | ||
$policyProvider | eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Security\PolicyProvider\PolicyProviderInterface |
public function testRegisteredPolicies() { $policies1 = ['custom_module' => ['custom_function_1' => null, 'custom_function_2' => ['CustomLimitation']], 'helloworld' => ['foo' => ['bar'], 'baz' => null]]; $this->extension->addPolicyProvider(new StubPolicyProvider($policies1)); $policies2 = ['custom_module2' => ['custom_function_3' => null, 'custom_function_4' => ['CustomLimitation2', 'CustomLimitation3']], 'helloworld' => ['foo' => ['additional_limitation'], 'some' => ['thingy', 'thing', 'but', 'wait']]]; $this->extension->addPolicyProvider(new StubPolicyProvider($policies2)); $expectedPolicies = ['custom_module' => ['custom_function_1' => [], 'custom_function_2' => ['CustomLimitation' => true]], 'helloworld' => ['foo' => ['bar' => true, 'additional_limitation' => true], 'baz' => [], 'some' => ['thingy' => true, 'thing' => true, 'but' => true, 'wait' => true]], 'custom_module2' => ['custom_function_3' => [], 'custom_function_4' => ['CustomLimitation2' => true, 'CustomLimitation3' => true]]]; $this->load(); self::assertContainerBuilderHasParameter('ezpublish.api.role.policy_map'); self::assertEquals($expectedPolicies, $this->container->getParameter('ezpublish.api.role.policy_map')); }