|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
|
5
|
|
|
* @copyright Aimeos (aimeos.org), 2019 |
|
6
|
|
|
* @package Controller |
|
7
|
|
|
* @subpackage Jobs |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
|
|
11
|
|
|
namespace Aimeos\Controller\Jobs\Product\Import\Xml; |
|
12
|
|
|
|
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* Product import controller factory for XML files. |
|
16
|
|
|
* |
|
17
|
|
|
* @package Controller |
|
18
|
|
|
* @subpackage Jobs |
|
19
|
|
|
*/ |
|
20
|
|
|
class Factory |
|
21
|
|
|
extends \Aimeos\Controller\Jobs\Common\Factory\Base |
|
22
|
|
|
implements \Aimeos\Controller\Jobs\Common\Factory\Iface |
|
23
|
|
|
{ |
|
24
|
|
|
/** |
|
25
|
|
|
* Creates a new controller specified by the given name. |
|
26
|
|
|
* |
|
27
|
|
|
* @param \Aimeos\MShop\Context\Item\Iface $context Context object required by controllers |
|
28
|
|
|
* @param \Aimeos\Bootstrap $aimeos \Aimeos\Bootstrap object |
|
29
|
|
|
* @param string|null $name Name of the controller or "Standard" if null |
|
30
|
|
|
* @return \Aimeos\Controller\Jobs\Iface New controller object |
|
31
|
|
|
*/ |
|
32
|
|
|
public static function create( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\Bootstrap $aimeos, $name = null ) |
|
33
|
|
|
{ |
|
34
|
|
|
/** controller/jobs/product/import/xml/name |
|
35
|
|
|
* Class name of the used product suggestions scheduler controller implementation |
|
36
|
|
|
* |
|
37
|
|
|
* Each default job controller can be replace by an alternative imlementation. |
|
38
|
|
|
* To use this implementation, you have to set the last part of the class |
|
39
|
|
|
* name as configuration value so the controller factory knows which class it |
|
40
|
|
|
* has to instantiate. |
|
41
|
|
|
* |
|
42
|
|
|
* For example, if the name of the default class is |
|
43
|
|
|
* |
|
44
|
|
|
* \Aimeos\Controller\Jobs\Product\Import\Xml\Standard |
|
45
|
|
|
* |
|
46
|
|
|
* and you want to replace it with your own version named |
|
47
|
|
|
* |
|
48
|
|
|
* \Aimeos\Controller\Jobs\Product\Import\Xml\Myxml |
|
49
|
|
|
* |
|
50
|
|
|
* then you have to set the this configuration option: |
|
51
|
|
|
* |
|
52
|
|
|
* controller/jobs/product/import/xml/name = Myxml |
|
53
|
|
|
* |
|
54
|
|
|
* The value is the last part of your own class name and it's case sensitive, |
|
55
|
|
|
* so take care that the configuration value is exactly named like the last |
|
56
|
|
|
* part of the class name. |
|
57
|
|
|
* |
|
58
|
|
|
* The allowed characters of the class name are A-Z, a-z and 0-9. No other |
|
59
|
|
|
* characters are possible! You should always start the last part of the class |
|
60
|
|
|
* name with an upper case character and continue only with lower case characters |
|
61
|
|
|
* or numbers. Avoid chamel case names like "MyXml"! |
|
62
|
|
|
* |
|
63
|
|
|
* @param string Last part of the class name |
|
64
|
|
|
* @since 2019.04 |
|
65
|
|
|
* @category Developer |
|
66
|
|
|
*/ |
|
67
|
|
|
if ( $name === null ) { |
|
68
|
|
|
$name = $context->getConfig()->get('controller/jobs/product/import/xml/name', 'Standard'); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
if ( ctype_alnum($name) === false ) |
|
72
|
|
|
{ |
|
73
|
|
|
$classname = is_string($name) ? '\\Aimeos\\Controller\\Jobs\\Product\\Import\\Xml\\' . $name : '<not a string>'; |
|
74
|
|
|
throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) ); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
$iface = '\\Aimeos\\Controller\\Jobs\\Iface'; |
|
78
|
|
|
$classname = '\\Aimeos\\Controller\\Jobs\\Product\\Import\\Xml\\' . $name; |
|
79
|
|
|
|
|
80
|
|
|
$controller = self::createController( $context, $aimeos, $classname, $iface ); |
|
81
|
|
|
|
|
82
|
|
|
/** controller/jobs/product/import/xml/decorators/excludes |
|
83
|
|
|
* Excludes decorators added by the "common" option from the product import CSV job controller |
|
84
|
|
|
* |
|
85
|
|
|
* Decorators extend the functionality of a class by adding new aspects |
|
86
|
|
|
* (e.g. log what is currently done), executing the methods of the underlying |
|
87
|
|
|
* class only in certain conditions (e.g. only for logged in users) or |
|
88
|
|
|
* modify what is returned to the caller. |
|
89
|
|
|
* |
|
90
|
|
|
* This option allows you to remove a decorator added via |
|
91
|
|
|
* "controller/jobs/common/decorators/default" before they are wrapped |
|
92
|
|
|
* around the job controller. |
|
93
|
|
|
* |
|
94
|
|
|
* controller/jobs/product/import/xml/decorators/excludes = array( 'decorator1' ) |
|
95
|
|
|
* |
|
96
|
|
|
* This would remove the decorator named "decorator1" from the list of |
|
97
|
|
|
* common decorators ("\Aimeos\Controller\Jobs\Common\Decorator\*") added via |
|
98
|
|
|
* "controller/jobs/common/decorators/default" to the job controller. |
|
99
|
|
|
* |
|
100
|
|
|
* @param array List of decorator names |
|
101
|
|
|
* @since 2019.04 |
|
102
|
|
|
* @category Developer |
|
103
|
|
|
* @see controller/jobs/common/decorators/default |
|
104
|
|
|
* @see controller/jobs/product/import/xml/decorators/global |
|
105
|
|
|
* @see controller/jobs/product/import/xml/decorators/local |
|
106
|
|
|
*/ |
|
107
|
|
|
|
|
108
|
|
|
/** controller/jobs/product/import/xml/decorators/global |
|
109
|
|
|
* Adds a list of globally available decorators only to the product import CSV job controller |
|
110
|
|
|
* |
|
111
|
|
|
* Decorators extend the functionality of a class by adding new aspects |
|
112
|
|
|
* (e.g. log what is currently done), executing the methods of the underlying |
|
113
|
|
|
* class only in certain conditions (e.g. only for logged in users) or |
|
114
|
|
|
* modify what is returned to the caller. |
|
115
|
|
|
* |
|
116
|
|
|
* This option allows you to wrap global decorators |
|
117
|
|
|
* ("\Aimeos\Controller\Jobs\Common\Decorator\*") around the job controller. |
|
118
|
|
|
* |
|
119
|
|
|
* controller/jobs/product/import/xml/decorators/global = array( 'decorator1' ) |
|
120
|
|
|
* |
|
121
|
|
|
* This would add the decorator named "decorator1" defined by |
|
122
|
|
|
* "\Aimeos\Controller\Jobs\Common\Decorator\Decorator1" only to the job controller. |
|
123
|
|
|
* |
|
124
|
|
|
* @param array List of decorator names |
|
125
|
|
|
* @since 2019.04 |
|
126
|
|
|
* @category Developer |
|
127
|
|
|
* @see controller/jobs/common/decorators/default |
|
128
|
|
|
* @see controller/jobs/product/import/xml/decorators/excludes |
|
129
|
|
|
* @see controller/jobs/product/import/xml/decorators/local |
|
130
|
|
|
*/ |
|
131
|
|
|
|
|
132
|
|
|
/** controller/jobs/product/import/xml/decorators/local |
|
133
|
|
|
* Adds a list of local decorators only to the product import CSV job controller |
|
134
|
|
|
* |
|
135
|
|
|
* Decorators extend the functionality of a class by adding new aspects |
|
136
|
|
|
* (e.g. log what is currently done), executing the methods of the underlying |
|
137
|
|
|
* class only in certain conditions (e.g. only for logged in users) or |
|
138
|
|
|
* modify what is returned to the caller. |
|
139
|
|
|
* |
|
140
|
|
|
* This option allows you to wrap local decorators |
|
141
|
|
|
* ("\Aimeos\Controller\Jobs\Product\Import\Xml\Decorator\*") around the job |
|
142
|
|
|
* controller. |
|
143
|
|
|
* |
|
144
|
|
|
* controller/jobs/product/import/xml/decorators/local = array( 'decorator2' ) |
|
145
|
|
|
* |
|
146
|
|
|
* This would add the decorator named "decorator2" defined by |
|
147
|
|
|
* "\Aimeos\Controller\Jobs\Product\Import\Xml\Decorator\Decorator2" |
|
148
|
|
|
* only to the job controller. |
|
149
|
|
|
* |
|
150
|
|
|
* @param array List of decorator names |
|
151
|
|
|
* @since 2019.04 |
|
152
|
|
|
* @category Developer |
|
153
|
|
|
* @see controller/jobs/common/decorators/default |
|
154
|
|
|
* @see controller/jobs/product/import/xml/decorators/excludes |
|
155
|
|
|
* @see controller/jobs/product/import/xml/decorators/global |
|
156
|
|
|
*/ |
|
157
|
|
|
return self::addControllerDecorators( $context, $aimeos, $controller, 'product/import/xml' ); |
|
158
|
|
|
} |
|
159
|
|
|
} |
|
160
|
|
|
|