Passed
Push — master ( 23e72e...dc62e4 )
by Aimeos
03:22
created

Factory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 135
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 11
c 2
b 0
f 0
dl 0
loc 135
rs 10
wmc 3

1 Method

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