These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | /* |
||
4 | * This file is part of the Sylius package. |
||
5 | * |
||
6 | * (c) Paweł Jędrzejewski |
||
7 | * |
||
8 | * For the full copyright and license information, please view the LICENSE |
||
9 | * file that was distributed with this source code. |
||
10 | */ |
||
11 | |||
12 | namespace Sylius\Bundle\RbacBundle\DependencyInjection; |
||
13 | |||
14 | use Sylius\Bundle\ResourceBundle\DependencyInjection\Extension\AbstractResourceExtension; |
||
15 | use Symfony\Component\Config\FileLocator; |
||
16 | use Symfony\Component\DependencyInjection\ContainerBuilder; |
||
17 | use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface; |
||
18 | use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; |
||
19 | |||
20 | /** |
||
21 | * @author Paweł Jędrzejewski <[email protected]> |
||
22 | */ |
||
23 | class SyliusRbacExtension extends AbstractResourceExtension implements PrependExtensionInterface |
||
24 | { |
||
25 | /** |
||
26 | * {@inheritdoc} |
||
27 | */ |
||
28 | public function load(array $config, ContainerBuilder $container) |
||
29 | { |
||
30 | $config = $this->processConfiguration($this->getConfiguration($config, $container), $config); |
||
0 ignored issues
–
show
|
|||
31 | $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); |
||
32 | |||
33 | $loader->load(sprintf('driver/%s.xml', $config['driver'])); |
||
34 | |||
35 | $this->registerResources('sylius', $config['driver'], $config['resources'], $container); |
||
36 | |||
37 | $configFiles = [ |
||
38 | 'services.xml', |
||
39 | 'templating.xml', |
||
40 | 'twig.xml', |
||
41 | ]; |
||
42 | |||
43 | foreach ($configFiles as $configFile) { |
||
44 | $loader->load($configFile); |
||
45 | } |
||
46 | |||
47 | $container->setAlias('sylius.authorization_identity_provider', $config['identity_provider']); |
||
48 | $container->setAlias('sylius.permission_map', $config['permission_map']); |
||
49 | $container->setAlias('sylius.authorization_checker', $config['authorization_checker']); |
||
50 | |||
51 | $container->setParameter('sylius.rbac.security_roles', $config['security_roles']); |
||
52 | |||
53 | $container->setParameter('sylius.rbac.default_roles', $config['roles']); |
||
54 | $container->setParameter('sylius.rbac.default_roles_hierarchy', $config['roles_hierarchy']); |
||
55 | |||
56 | $container->setParameter('sylius.rbac.default_permissions', $config['permissions']); |
||
57 | $container->setParameter('sylius.rbac.default_permissions_hierarchy', $config['permissions_hierarchy']); |
||
58 | } |
||
59 | |||
60 | /** |
||
61 | * {@inheritdoc} |
||
62 | */ |
||
63 | public function prepend(ContainerBuilder $container) |
||
64 | { |
||
65 | $this->prependDoctrineCache($container); |
||
66 | $this->prependSyliusResource($container); |
||
67 | } |
||
68 | |||
69 | /** |
||
70 | * @param ContainerBuilder $container |
||
71 | */ |
||
72 | private function prependDoctrineCache(ContainerBuilder $container) |
||
73 | { |
||
74 | if (!$container->hasExtension('doctrine_cache')) { |
||
75 | throw new \RuntimeException('DoctrineCacheBundle must be registered!'); |
||
76 | } |
||
77 | |||
78 | $container->prependExtensionConfig('doctrine_cache', [ |
||
79 | 'providers' => [ |
||
80 | 'sylius_rbac' => '%sylius.cache%', |
||
81 | ], |
||
82 | ]); |
||
83 | } |
||
84 | /** |
||
85 | * @param ContainerBuilder $container |
||
86 | */ |
||
87 | private function prependSyliusResource(ContainerBuilder $container) |
||
88 | { |
||
89 | if (!$container->hasExtension('sylius_resource')) { |
||
90 | return; |
||
91 | } |
||
92 | |||
93 | $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); |
||
94 | $loader->load('resource_integration.xml'); |
||
95 | |||
96 | $container->prependExtensionConfig('sylius_resource', [ |
||
97 | 'authorization_checker' => 'sylius.resource_controller.authorization_checker.rbac', |
||
98 | ]); |
||
99 | } |
||
100 | } |
||
101 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: