|
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\CoreBundle\DependencyInjection; |
|
13
|
|
|
|
|
14
|
|
|
use Sylius\Bundle\ResourceBundle\DependencyInjection\Extension\AbstractResourceExtension; |
|
15
|
|
|
use Symfony\Component\Config\FileLocator; |
|
16
|
|
|
use Symfony\Component\Config\Loader\LoaderInterface; |
|
17
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
18
|
|
|
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface; |
|
19
|
|
|
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* @author Paweł Jędrzejewski <[email protected]> |
|
23
|
|
|
* @author Gonzalo Vilaseca <[email protected]> |
|
24
|
|
|
*/ |
|
25
|
|
|
final class SyliusCoreExtension extends AbstractResourceExtension implements PrependExtensionInterface |
|
26
|
|
|
{ |
|
27
|
|
|
/** |
|
28
|
|
|
* @var array |
|
29
|
|
|
*/ |
|
30
|
|
|
private static $bundles = [ |
|
31
|
|
|
'sylius_addressing', |
|
32
|
|
|
'sylius_attribute', |
|
33
|
|
|
'sylius_channel', |
|
34
|
|
|
'sylius_currency', |
|
35
|
|
|
'sylius_customer', |
|
36
|
|
|
'sylius_inventory', |
|
37
|
|
|
'sylius_locale', |
|
38
|
|
|
'sylius_order', |
|
39
|
|
|
'sylius_payment', |
|
40
|
|
|
'sylius_payum', |
|
41
|
|
|
'sylius_product', |
|
42
|
|
|
'sylius_promotion', |
|
43
|
|
|
'sylius_review', |
|
44
|
|
|
'sylius_shipping', |
|
45
|
|
|
'sylius_taxation', |
|
46
|
|
|
'sylius_taxonomy', |
|
47
|
|
|
'sylius_user', |
|
48
|
|
|
'sylius_variation', |
|
49
|
|
|
]; |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* {@inheritdoc} |
|
53
|
|
|
*/ |
|
54
|
|
|
public function load(array $config, ContainerBuilder $container) |
|
55
|
|
|
{ |
|
56
|
|
|
$config = $this->processConfiguration($this->getConfiguration($config, $container), $config); |
|
|
|
|
|
|
57
|
|
|
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); |
|
58
|
|
|
|
|
59
|
|
|
$this->registerResources('sylius', $config['driver'], $config['resources'], $container); |
|
60
|
|
|
|
|
61
|
|
|
$loader->load('services.xml'); |
|
62
|
|
|
|
|
63
|
|
|
$env = $container->getParameter('kernel.environment'); |
|
64
|
|
|
if ('test' === $env || 'test_cached' === $env) { |
|
65
|
|
|
$loader->load('test_services.xml'); |
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* {@inheritdoc} |
|
71
|
|
|
*/ |
|
72
|
|
|
public function prepend(ContainerBuilder $container) |
|
73
|
|
|
{ |
|
74
|
|
|
$config = $container->getExtensionConfig($this->getAlias()); |
|
75
|
|
|
$config = $this->processConfiguration($this->getConfiguration($config, $container), $config); |
|
|
|
|
|
|
76
|
|
|
|
|
77
|
|
|
foreach ($container->getExtensions() as $name => $extension) { |
|
78
|
|
|
if (in_array($name, self::$bundles, true)) { |
|
79
|
|
|
$container->prependExtensionConfig($name, ['driver' => $config['driver']]); |
|
80
|
|
|
} |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
$container->prependExtensionConfig('sylius_theme', ['context' => 'sylius.theme.context.channel_based']); |
|
84
|
|
|
|
|
85
|
|
|
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); |
|
86
|
|
|
$this->prependHwiOauth($container, $loader); |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* @param ContainerBuilder $container |
|
91
|
|
|
* @param LoaderInterface $loader |
|
92
|
|
|
*/ |
|
93
|
|
|
private function prependHwiOauth(ContainerBuilder $container, LoaderInterface $loader) |
|
94
|
|
|
{ |
|
95
|
|
|
if (!$container->hasExtension('hwi_oauth')) { |
|
96
|
|
|
return; |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
$loader->load('services/integrations/hwi_oauth.xml'); |
|
100
|
|
|
} |
|
101
|
|
|
} |
|
102
|
|
|
|
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: