Completed
Push — master ( c19652...9df19e )
by Bernhard
02:12
created

ProductMagic360ProcessorFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 89
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 12

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 0
cbo 12
dl 0
loc 89
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getProcessorType() 0 4 1
A factory() 0 67 1
1
<?php
2
3
/**
4
 * TechDivision\Import\Product\Magic360\Services\ProductMagic360ProcessorFactory
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 2016 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-cli-simple
18
 * @link      http://www.techdivision.com
19
 */
20
21
namespace TechDivision\Import\Product\Magic360\Services;
22
23
use TechDivision\Import\Configuration\ProcessorConfigurationInterface;
24
use TechDivision\Import\Product\Magic360\Actions\Magic360ColumnsAction;
25
use TechDivision\Import\Product\Magic360\Actions\Magic360GalleryAction;
26
use TechDivision\Import\Product\Magic360\Actions\Processors\Magic360ColumnsCreateProcessor;
27
use TechDivision\Import\Product\Magic360\Actions\Processors\Magic360ColumnsDeleteProcessor;
28
use TechDivision\Import\Product\Magic360\Actions\Processors\Magic360ColumnsUpdateProcessor;
29
use TechDivision\Import\Product\Magic360\Actions\Processors\Magic360GalleryCreateProcessor;
30
use TechDivision\Import\Product\Magic360\Actions\Processors\Magic360GalleryDeleteProcessor;
31
use TechDivision\Import\Product\Magic360\Actions\Processors\Magic360GalleryUpdateProcessor;
32
use TechDivision\Import\Product\Magic360\Repositories\ProductMagic360ColumnsRepository;
33
use TechDivision\Import\Product\Magic360\Repositories\ProductMagic360GalleryRepository;
34
35
/**
36
 * Factory to create a new product media processor.
37
 *
38
 * @author    Tim Wagner <[email protected]>
39
 * @copyright 2016 TechDivision GmbH <[email protected]>
40
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
41
 * @link      https://github.com/techdivision/import-cli-simple
42
 * @link      http://www.techdivision.com
43
 */
44
class ProductMagic360ProcessorFactory
45
{
46
47
    /**
48
     * Returns the processor class name.
49
     *
50
     * @return string The processor class name
51
     */
52
    protected static function getProcessorType()
53
    {
54
        return 'TechDivision\Import\Product\Magic360\Services\ProductMagic360Processor';
55
    }
56
57
    /**
58
     * Factory method to create a new product media processor instance.
59
     *
60
     * @param \PDO                                                               $connection    The PDO connection to use
61
     * @param \TechDivision\Import\Configuration\ProcessorConfigurationInterface $configuration The subject configuration
62
     *
63
     * @return \TechDivision\Import\Product\Magic360\Services\ProductMagic360Processor The processor instance
64
     */
65
    public static function factory(\PDO $connection, ProcessorConfigurationInterface $configuration)
66
    {
67
68
        // load the utility class name
69
        $utilityClassName = $configuration->getUtilityClassName();
70
71
        // initialize the repository that provides product media gallery query functionality
72
        $productMagic360GalleryRepository = new ProductMagic360GalleryRepository();
73
        $productMagic360GalleryRepository->setUtilityClassName($utilityClassName);
74
        $productMagic360GalleryRepository->setConnection($connection);
75
        $productMagic360GalleryRepository->init();
76
77
        // initialize the repository that provides product media gallery value to entity query functionality
78
        $productMagic360ColumnsRepository = new ProductMagic360ColumnsRepository();
79
        $productMagic360ColumnsRepository->setUtilityClassName($utilityClassName);
80
        $productMagic360ColumnsRepository->setConnection($connection);
81
        $productMagic360ColumnsRepository->init();
82
83
        // initialize the action that provides product media gallery CRUD functionality
84
        $productMagic360GalleryCreateProcessor = new Magic360GalleryCreateProcessor();
85
        $productMagic360GalleryCreateProcessor->setUtilityClassName($utilityClassName);
86
        $productMagic360GalleryCreateProcessor->setConnection($connection);
87
        $productMagic360GalleryCreateProcessor->init();
88
        $productMagic360GalleryUpdateProcessor = new Magic360GalleryUpdateProcessor();
89
        $productMagic360GalleryUpdateProcessor->setUtilityClassName($utilityClassName);
90
        $productMagic360GalleryUpdateProcessor->setConnection($connection);
91
        $productMagic360GalleryUpdateProcessor->init();
92
        $productMagic360GalleryDeleteProcessor = new Magic360GalleryDeleteProcessor();
93
        $productMagic360GalleryDeleteProcessor->setUtilityClassName($utilityClassName);
94
        $productMagic360GalleryDeleteProcessor->setConnection($connection);
95
        $productMagic360GalleryDeleteProcessor->init();
96
        $magic360GalleryAction = new Magic360GalleryAction();
97
        $magic360GalleryAction->setCreateProcessor($productMagic360GalleryCreateProcessor);
98
        $magic360GalleryAction->setUpdateProcessor($productMagic360GalleryUpdateProcessor);
99
        $magic360GalleryAction->setDeleteProcessor($productMagic360GalleryDeleteProcessor);
100
101
        // initialize the action that provides product media gallery value CRUD functionality
102
        $productMagic360ColumnsCreateProcessor = new Magic360ColumnsCreateProcessor();
103
        $productMagic360ColumnsCreateProcessor->setUtilityClassName($utilityClassName);
104
        $productMagic360ColumnsCreateProcessor->setConnection($connection);
105
        $productMagic360ColumnsCreateProcessor->init();
106
        $productMagic360ColumnsUpdateProcessor = new Magic360ColumnsUpdateProcessor();
107
        $productMagic360ColumnsUpdateProcessor->setUtilityClassName($utilityClassName);
108
        $productMagic360ColumnsUpdateProcessor->setConnection($connection);
109
        $productMagic360ColumnsUpdateProcessor->init();
110
        $productMagic360ColumnsDeleteProcessor = new Magic360ColumnsDeleteProcessor()   ;
111
        $productMagic360ColumnsDeleteProcessor->setUtilityClassName($utilityClassName);
112
        $productMagic360ColumnsDeleteProcessor->setConnection($connection);
113
        $productMagic360ColumnsDeleteProcessor->init();
114
        $magic360ColumnsAction = new Magic360ColumnsAction();
115
        $magic360ColumnsAction->setCreateProcessor($productMagic360ColumnsCreateProcessor);
116
        $magic360ColumnsAction->setUpdateProcessor($productMagic360ColumnsUpdateProcessor);
117
        $magic360ColumnsAction->setDeleteProcessor($productMagic360ColumnsDeleteProcessor);
118
119
        // initialize the product media processor
120
        $processorType = static::getProcessorType();
121
        /** @var \TechDivision\Import\Product\Magic360\Services\ProductMagic360Processor $productMagic360Processor */
122
        $productMagic360Processor = new $processorType();
123
        $productMagic360Processor->setConnection($connection);
124
        $productMagic360Processor->setProductMagic360GalleryRepository($productMagic360GalleryRepository);
125
        $productMagic360Processor->setProductMagic360ColumnsRepository($productMagic360ColumnsRepository);
126
        $productMagic360Processor->setMagic360GalleryAction($magic360GalleryAction);
127
        $productMagic360Processor->setMagic360ColumnsAction($magic360ColumnsAction);
128
129
        // return the instance
130
        return $productMagic360Processor;
131
    }
132
}
133