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\FixturesBundle\DependencyInjection; |
13
|
|
|
|
14
|
|
|
use Symfony\Component\Config\FileLocator; |
15
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
16
|
|
|
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface; |
17
|
|
|
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; |
18
|
|
|
use Symfony\Component\HttpKernel\DependencyInjection\Extension; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @author Kamil Kokot <[email protected]> |
22
|
|
|
*/ |
23
|
|
|
final class SyliusFixturesExtension extends Extension 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); |
|
|
|
|
31
|
|
|
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); |
32
|
|
|
|
33
|
|
|
$loader->load('services.xml'); |
34
|
|
|
|
35
|
|
|
$this->registerSuites($config, $container); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* {@inheritdoc} |
40
|
|
|
*/ |
41
|
|
|
public function prepend(ContainerBuilder $container) |
42
|
|
|
{ |
43
|
|
|
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config/driver')); |
44
|
|
|
|
45
|
|
|
$extensionsNamesToConfigurationFiles = [ |
46
|
|
|
'doctrine' => 'doctrine/orm.xml', |
47
|
|
|
'doctrine_mongodb' => 'doctrine/mongodb.xml', |
48
|
|
|
'doctrine_phpcr' => 'doctrine/phpcr.xml', |
49
|
|
|
]; |
50
|
|
|
|
51
|
|
|
foreach ($extensionsNamesToConfigurationFiles as $extensionName => $configurationFile) { |
52
|
|
|
if (!$container->hasExtension($extensionName)) { |
53
|
|
|
continue; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
$loader->load($configurationFile); |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @param array $config |
62
|
|
|
* @param ContainerBuilder $container |
63
|
|
|
*/ |
64
|
|
|
private function registerSuites(array $config, ContainerBuilder $container) |
65
|
|
|
{ |
66
|
|
|
$suiteRegistry = $container->findDefinition('sylius_fixtures.suite_registry'); |
67
|
|
|
foreach ($config['suites'] as $suiteName => $suiteConfiguration) { |
68
|
|
|
$suiteRegistry->addMethodCall('addSuite', [$suiteName, $suiteConfiguration]); |
69
|
|
|
} |
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
|
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: