|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* TechDivision\Import\Subjects\I18n\DateConverterFactory |
|
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 2018 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\Subjects\I18n; |
|
22
|
|
|
|
|
23
|
|
|
use Symfony\Component\DependencyInjection\ContainerInterface; |
|
24
|
|
|
use TechDivision\Import\Configuration\SubjectConfigurationInterface; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* Factory for date converter instances. |
|
28
|
|
|
* |
|
29
|
|
|
* @author Tim Wagner <[email protected]> |
|
30
|
|
|
* @copyright 2018 TechDivision GmbH <[email protected]> |
|
31
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
|
32
|
|
|
* @link https://github.com/techdivision/import |
|
33
|
|
|
* @link http://www.techdivision.com |
|
34
|
|
|
*/ |
|
35
|
|
|
class DateConverterFactory implements DateConverterFactoryInterface |
|
36
|
|
|
{ |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* The DI container instance. |
|
40
|
|
|
* |
|
41
|
|
|
* @var \Symfony\Component\DependencyInjection\ContainerInterface |
|
42
|
|
|
*/ |
|
43
|
|
|
protected $container; |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* Initialize the factory with the DI container instance. |
|
47
|
|
|
* |
|
48
|
|
|
* @param \Symfony\Component\DependencyInjection\ContainerInterface $container The DI container instance |
|
49
|
|
|
*/ |
|
50
|
|
|
public function __construct(ContainerInterface $container) |
|
51
|
|
|
{ |
|
52
|
|
|
$this->container = $container; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* Creates and returns the date converter instance for the subject with the passed configuration. |
|
57
|
|
|
* |
|
58
|
|
|
* @param \TechDivision\Import\Configuration\SubjectConfigurationInterface $subject The subject to create the date converter for |
|
59
|
|
|
* |
|
60
|
|
|
* @return \TechDivision\Import\Subjects\I18n\DateConverterInterface The date converter instance |
|
61
|
|
|
*/ |
|
62
|
|
|
public function createDateConverter(SubjectConfigurationInterface $subject) |
|
63
|
|
|
{ |
|
64
|
|
|
|
|
65
|
|
|
// create a new date converter instance for the subject with the passed configuration |
|
66
|
|
|
$dateConverter = $this->container->get($subject->getDateConverter()->getId()); |
|
67
|
|
|
$dateConverter->setSubjectConfiguration($subject); |
|
68
|
|
|
|
|
69
|
|
|
// return the date converter instance |
|
70
|
|
|
return $dateConverter; |
|
71
|
|
|
} |
|
72
|
|
|
} |
|
73
|
|
|
|