Completed
Push — master ( 0b1729...545b8f )
by Aimeos
01:57
created

Factory   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 139
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 4
dl 0
loc 139
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B create() 0 126 4
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Metaways Infosystems GmbH, 2013
6
 * @copyright Aimeos (aimeos.org), 2015-2018
7
 * @package Controller
8
 * @subpackage Jobs
9
 */
10
11
12
namespace Aimeos\Controller\Jobs\Admin\Cache;
13
14
15
/**
16
 * Admin cache controller factory.
17
 *
18
 * @package Controller
19
 * @subpackage Jobs
20
 */
21
class Factory
0 ignored issues
show
Bug introduced by
There is one abstract method createController in this class; you could implement it, or declare this class as abstract.
Loading history...
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, $name = null )
34
	{
35
		/** controller/jobs/admin/cache/name
36
		 * Class name of the used admin cache scheduler controller implementation
37
		 *
38
		 * Each default cache 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\Admin\Cache\Standard
46
		 *
47
		 * and you want to replace it with your own version named
48
		 *
49
		 *  \Aimeos\Controller\Jobs\Admin\Cache\Mycache
50
		 *
51
		 * then you have to set the this configuration option:
52
		 *
53
		 *  controller/jobs/admin/cache/name = Mycache
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 "MyCache"!
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->getConfig()->get( 'controller/jobs/admin/cache/name', 'Standard' );
70
		}
71
72
		if( ctype_alnum( $name ) === false )
73
		{
74
			$classname = is_string( $name ) ? '\\Aimeos\\Controller\\Jobs\\Admin\\Cache\\' . $name : '<not a string>';
75
			throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) );
76
		}
77
78
		$iface = '\\Aimeos\\Controller\\Jobs\\Iface';
79
		$classname = '\\Aimeos\\Controller\\Jobs\\Admin\\Cache\\' . $name;
80
81
		$controller = self::createController( $context, $aimeos, $classname, $iface );
0 ignored issues
show
Unused Code introduced by
The call to Factory::createController() has too many arguments starting with $iface.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
82
83
		/** controller/jobs/admin/cache/decorators/excludes
84
		 * Excludes decorators added by the "common" option from the admin cache controllers
85
		 *
86
		 * Decorators extend the functionality of a class by adding new aspects
87
		 * (e.g. log what is currently done), executing the methods of the underlying
88
		 * class only in certain conditions (e.g. only for logged in users) or
89
		 * modify what is returned to the caller.
90
		 *
91
		 * This option allows you to remove a decorator added via
92
		 * "controller/jobs/common/decorators/default" before they are wrapped
93
		 * around the job controller.
94
		 *
95
		 *  controller/jobs/admin/cache/decorators/excludes = array( 'decorator1' )
96
		 *
97
		 * This would remove the decorator named "decorator1" from the list of
98
		 * common decorators ("\Aimeos\Controller\Jobs\Common\Decorator\*") added via
99
		 * "controller/jobs/common/decorators/default" to this job controller.
100
		 *
101
		 * @param array List of decorator names
102
		 * @since 2015.09
103
		 * @category Developer
104
		 * @see controller/jobs/common/decorators/default
105
		 * @see controller/jobs/admin/cache/decorators/global
106
		 * @see controller/jobs/admin/cache/decorators/local
107
		 */
108
109
		/** controller/jobs/admin/cache/decorators/global
110
		 * Adds a list of globally available decorators only to the admin cache controllers
111
		 *
112
		 * Decorators extend the functionality of a class by adding new aspects
113
		 * (e.g. log what is currently done), executing the methods of the underlying
114
		 * class only in certain conditions (e.g. only for logged in users) or
115
		 * modify what is returned to the caller.
116
		 *
117
		 * This option allows you to wrap global decorators
118
		 * ("\Aimeos\Controller\Jobs\Common\Decorator\*") around the job controller.
119
		 *
120
		 *  controller/jobs/admin/cache/decorators/global = array( 'decorator1' )
121
		 *
122
		 * This would add the decorator named "decorator1" defined by
123
		 * "\Aimeos\Controller\Jobs\Common\Decorator\Decorator1" only to this job controller.
124
		 *
125
		 * @param array List of decorator names
126
		 * @since 2015.09
127
		 * @category Developer
128
		 * @see controller/jobs/common/decorators/default
129
		 * @see controller/jobs/admin/cache/decorators/excludes
130
		 * @see controller/jobs/admin/cache/decorators/local
131
		 */
132
133
		/** controller/jobs/admin/cache/decorators/local
134
		 * Adds a list of local decorators only to the admin cache controllers
135
		 *
136
		 * Decorators extend the functionality of a class by adding new aspects
137
		 * (e.g. log what is currently done), executing the methods of the underlying
138
		 * class only in certain conditions (e.g. only for logged in users) or
139
		 * modify what is returned to the caller.
140
		 *
141
		 * This option allows you to wrap local decorators
142
		 * ("\Aimeos\Controller\Jobs\Admin\Cache\Decorator\*") around this job controller.
143
		 *
144
		 *  controller/jobs/admin/cache/decorators/local = array( 'decorator2' )
145
		 *
146
		 * This would add the decorator named "decorator2" defined by
147
		 * "\Aimeos\Controller\Jobs\Admin\Cache\Decorator\Decorator2" only to this job
148
		 * controller.
149
		 *
150
		 * @param array List of decorator names
151
		 * @since 2015.09
152
		 * @category Developer
153
		 * @see controller/jobs/common/decorators/default
154
		 * @see controller/jobs/admin/cache/decorators/excludes
155
		 * @see controller/jobs/admin/cache/decorators/global
156
		 */
157
		return self::addControllerDecorators( $context, $aimeos, $controller, 'admin/cache' );
158
	}
159
}