1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* TechDivision\Import\Repositories\Finders\ConfigurableFinderFactory |
5
|
|
|
* |
6
|
|
|
* NOTICE OF LICENSE |
7
|
|
|
* |
8
|
|
|
* This source file is subject to the Open Software License (OSL 3.0) |
9
|
|
|
* that is available through the world-wide-web at this URL: |
10
|
|
|
* http://opensource.org/licenses/osl-3.0.php |
11
|
|
|
* |
12
|
|
|
* PHP version 5 |
13
|
|
|
* |
14
|
|
|
* @author Tim Wagner <[email protected]> |
15
|
|
|
* @copyright 2019 TechDivision GmbH <[email protected]> |
16
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
17
|
|
|
* @link https://github.com/techdivision/import |
18
|
|
|
* @link http://www.techdivision.com |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
namespace TechDivision\Import\Repositories\Finders; |
22
|
|
|
|
23
|
|
|
use TechDivision\Import\Configuration\ConfigurationInterface; |
24
|
|
|
use Symfony\Component\DependencyInjection\TaggedContainerInterface; |
25
|
|
|
use TechDivision\Import\Repositories\FinderAwareRepositoryInterface; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Factory for finder instances. |
29
|
|
|
* |
30
|
|
|
* @author Tim Wagner <[email protected]> |
31
|
|
|
* @copyright 2019 TechDivision GmbH <[email protected]> |
32
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
33
|
|
|
* @link https://github.com/techdivision/import |
34
|
|
|
* @link http://www.techdivision.com |
35
|
|
|
*/ |
36
|
|
|
class ConfigurableFinderFactory implements FinderFactoryInterface |
37
|
|
|
{ |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* The DI container builder instance. |
41
|
|
|
* |
42
|
|
|
* @var \Symfony\Component\DependencyInjection\TaggedContainerInterface |
43
|
|
|
*/ |
44
|
|
|
protected $container; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* The configuration instance. |
48
|
|
|
* |
49
|
|
|
* @var \TechDivision\Import\Configuration\ConfigurationInterface |
50
|
|
|
*/ |
51
|
|
|
protected $configuration; |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* The constructor to initialize the instance. |
55
|
|
|
* |
56
|
|
|
* @param \Symfony\Component\DependencyInjection\TaggedContainerInterface $container The container instance |
57
|
|
|
* @param \TechDivision\Import\Configuration\ConfigurationInterface $configuration The configuration instance |
58
|
|
|
*/ |
59
|
|
|
public function __construct(TaggedContainerInterface $container, ConfigurationInterface $configuration) |
60
|
|
|
{ |
61
|
|
|
$this->container = $container; |
62
|
|
|
$this->configuration = $configuration; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Initialize's and return's a new finder instance. |
67
|
|
|
* |
68
|
|
|
* @param \TechDivision\Import\Repositories\FinderAwareRepositoryInterface $repository The repository instance to create the finder for |
69
|
|
|
* @param string $key The key of the prepared statement |
70
|
|
|
* |
71
|
|
|
* @return \TechDivision\Import\Repositories\Finders\FinderInterface The finder instance |
72
|
|
|
*/ |
73
|
|
|
public function createFinder(FinderAwareRepositoryInterface $repository, $key) |
74
|
|
|
{ |
75
|
|
|
return $this->container->get($this->configuration->getFinderMappingByKey($key))->createFinder($repository, $key); |
76
|
|
|
} |
77
|
|
|
} |
78
|
|
|
|