1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @link https://github.com/nnx-framework/doctrine-fixture-module |
4
|
|
|
* @author Malofeykin Andrey <[email protected]> |
5
|
|
|
*/ |
6
|
|
|
namespace Nnx\DoctrineFixtureModule\Executor; |
7
|
|
|
|
8
|
|
|
use Nnx\DoctrineFixtureModule\FixtureInitializer\FixtureInitializerManagerInterface; |
9
|
|
|
use Zend\ServiceManager\AbstractPluginManager; |
10
|
|
|
use Zend\ServiceManager\FactoryInterface; |
11
|
|
|
use Zend\ServiceManager\ServiceLocatorInterface; |
12
|
|
|
use Nnx\ModuleOptions\ModuleOptionsPluginManagerInterface; |
13
|
|
|
use Nnx\DoctrineFixtureModule\Options\ModuleOptions; |
14
|
|
|
|
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Class DefaultExecutorConfigurationFactory |
18
|
|
|
* |
19
|
|
|
* @package Nnx\DoctrineFixtureModule\Executor |
20
|
|
|
*/ |
21
|
|
|
class DefaultExecutorConfigurationFactory implements FactoryInterface |
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* @inheritDoc |
25
|
|
|
* @throws \Zend\ServiceManager\Exception\ServiceNotFoundException |
26
|
|
|
*/ |
27
|
|
|
public function createService(ServiceLocatorInterface $serviceLocator) |
28
|
|
|
{ |
29
|
|
|
$appServiceLocator = $serviceLocator instanceof AbstractPluginManager ? $serviceLocator->getServiceLocator() : $serviceLocator; |
30
|
|
|
|
31
|
|
|
$defaultExecutorConfiguration = new DefaultExecutorConfiguration(); |
32
|
|
|
|
33
|
|
|
$eventManager = $defaultExecutorConfiguration->getEventManager(); |
34
|
|
|
|
35
|
|
|
/** @var ModuleOptionsPluginManagerInterface $moduleOptionsPluginManager */ |
36
|
|
|
$moduleOptionsPluginManager = $serviceLocator->get(ModuleOptionsPluginManagerInterface::class); |
37
|
|
|
/** @var ModuleOptions $moduleOptions */ |
38
|
|
|
$moduleOptions = $moduleOptionsPluginManager->get(ModuleOptions::class); |
39
|
|
|
|
40
|
|
|
$defaultFixtureEventListeners = $moduleOptions->getFixtureInitializer(); |
41
|
|
|
|
42
|
|
|
/** @var FixtureInitializerManagerInterface $fixtureInitializerManager */ |
43
|
|
|
$fixtureInitializerManager = $appServiceLocator->get(FixtureInitializerManagerInterface::class); |
44
|
|
|
|
45
|
|
|
foreach ($defaultFixtureEventListeners as $listenerName) { |
46
|
|
|
$listener = $fixtureInitializerManager->get($listenerName); |
47
|
|
|
$eventManager->addEventSubscriber($listener); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
return $defaultExecutorConfiguration; |
51
|
|
|
} |
52
|
|
|
} |
53
|
|
|
|