1
|
|
|
<?php
|
2
|
|
|
|
3
|
|
|
declare(strict_types=1);
|
4
|
|
|
|
5
|
|
|
namespace Arp\LaminasDoctrineFixtures\Factory\Command;
|
6
|
|
|
|
7
|
|
|
use Arp\LaminasDoctrineFixtures\Command\ImportCommand;
|
8
|
|
|
use Arp\LaminasDoctrineFixtures\Service\Executor;
|
9
|
|
|
use Arp\LaminasDoctrineFixtures\Service\Loader;
|
10
|
|
|
use Arp\LaminasFactory\AbstractFactory;
|
11
|
|
|
use Doctrine\Common\DataFixtures\Purger\ORMPurger;
|
12
|
|
|
use Interop\Container\ContainerInterface;
|
13
|
|
|
|
14
|
|
|
/**
|
15
|
|
|
* @author Alex Patterson <[email protected]>
|
16
|
|
|
* @package Arp\LaminasDoctrineFixtures\Factory\Command
|
17
|
|
|
*/
|
18
|
|
|
final class ImportCommandFactory extends AbstractFactory
|
19
|
|
|
{
|
20
|
|
|
/**
|
21
|
|
|
* @var string
|
22
|
|
|
*/
|
23
|
|
|
private $defaultClassName = ImportCommand::class;
|
24
|
|
|
|
25
|
|
|
/**
|
26
|
|
|
* @param ContainerInterface $container
|
27
|
|
|
* @param string $requestedName
|
28
|
|
|
* @param array|null $options
|
29
|
|
|
*
|
30
|
|
|
* @return ImportCommand
|
31
|
|
|
*/
|
32
|
|
|
public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
|
33
|
|
|
{
|
34
|
|
|
$options = $options ?? $this->getServiceOptions($container, $requestedName);
|
35
|
|
|
|
36
|
|
|
$className = $options['class_name'] ?? $this->defaultClassName;
|
37
|
|
|
$loader = $options['loader'] ?? Loader::class;
|
38
|
|
|
$executor = $options['executor'] ?? Executor::class;
|
39
|
|
|
$purger = $options['purger'] ?? ORMPurger::class;
|
40
|
|
|
|
41
|
|
|
$loader = $this->getService($container, $loader, $requestedName);
|
42
|
|
|
|
43
|
|
|
return new $className(
|
44
|
|
|
$loader->getFixtures(),
|
45
|
|
|
$this->getService($container, $executor, $requestedName),
|
46
|
|
|
$this->getService($container, $purger, $requestedName)
|
47
|
|
|
);
|
48
|
|
|
}
|
49
|
|
|
}
|
50
|
|
|
|