These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
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-2017 |
||
7 | * @package MAdmin |
||
8 | * @subpackage Cache |
||
9 | */ |
||
10 | |||
11 | |||
12 | namespace Aimeos\MAdmin\Cache\Manager; |
||
13 | |||
14 | |||
15 | /** |
||
16 | * Admin cache factory. |
||
17 | * |
||
18 | * @package MAdmin |
||
19 | * @subpackage Cache |
||
20 | */ |
||
21 | class Factory |
||
22 | extends \Aimeos\MAdmin\Common\Factory\Base |
||
0 ignored issues
–
show
Coding Style
introduced
by
Loading history...
|
|||
23 | implements \Aimeos\MShop\Common\Factory\Iface |
||
24 | { |
||
25 | /** |
||
26 | * Creates an admin cache manager object. |
||
27 | * |
||
28 | * @param \Aimeos\MShop\Context\Item\Iface $context Context instance with necessary objects |
||
29 | * @param string|null $name Manager name |
||
30 | * @return \Aimeos\MAdmin\Cache\Manager\Iface Cache manager object |
||
31 | */ |
||
32 | public static function createManager( \Aimeos\MShop\Context\Item\Iface $context, $name = null ) |
||
33 | { |
||
34 | /** madmin/cache/manager/name |
||
35 | * Class name of the used cache manager implementation |
||
36 | * |
||
37 | * Each default manager 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 manager factory knows which class it |
||
40 | * has to instantiate. |
||
41 | * |
||
42 | * For example, if the name of the default class is |
||
43 | * |
||
44 | * \Aimeos\MShop\Cache\Manager\Standard |
||
45 | * |
||
46 | * and you want to replace it with your own version named |
||
47 | * |
||
48 | * \Aimeos\MShop\Cache\Manager\Mymanager |
||
49 | * |
||
50 | * then you have to set the this configuration option: |
||
51 | * |
||
52 | * madmin/cache/manager/name = Mymanager |
||
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 "MyManager"! |
||
62 | * |
||
63 | * @param string Last part of the class name |
||
64 | * @since 2014.03 |
||
65 | * @category Developer |
||
66 | */ |
||
67 | if( $name === null ) { |
||
68 | $name = $context->getConfig()->get( 'madmin/cache/manager/name', 'Standard' ); |
||
69 | } |
||
70 | |||
71 | if( ctype_alnum( $name ) === false ) |
||
72 | { |
||
73 | $classname = is_string( $name ) ? '\\Aimeos\\MAdmin\\Cache\\Manager\\' . $name : '<not a string>'; |
||
74 | throw new \Aimeos\MAdmin\Cache\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) ); |
||
75 | } |
||
76 | |||
77 | $iface = '\\Aimeos\\MAdmin\\Cache\\Manager\\Iface'; |
||
78 | $classname = '\\Aimeos\\MAdmin\\Cache\\Manager\\' . $name; |
||
79 | |||
80 | $manager = self::createManagerBase( $context, $classname, $iface ); |
||
81 | |||
82 | /** madmin/cache/manager/decorators/excludes |
||
83 | * Excludes decorators added by the "common" option from the cache manager |
||
84 | * |
||
85 | * Decorators extend the functionality of a class by adding new aspects |
||
86 | * (e.g. cache what is currently done), executing the methods of the underlying |
||
87 | * class only in certain conditions (e.g. only for cacheged in users) or |
||
88 | * modify what is returned to the caller. |
||
89 | * |
||
90 | * This option allows you to remove a decorator added via |
||
91 | * "madmin/common/manager/decorators/default" before they are wrapped |
||
92 | * around the cache manager. |
||
93 | * |
||
94 | * madmin/cache/manager/decorators/excludes = array( 'decorator1' ) |
||
95 | * |
||
96 | * This would remove the decorator named "decorator1" from the list of |
||
97 | * common decorators ("\Aimeos\MShop\Common\Manager\Decorator\*") added via |
||
98 | * "madmin/common/manager/decorators/default" for the cache manager. |
||
99 | * |
||
100 | * @param array List of decorator names |
||
101 | * @since 2014.03 |
||
102 | * @category Developer |
||
103 | * @see madmin/common/manager/decorators/default |
||
104 | * @see madmin/cache/manager/decorators/global |
||
105 | * @see madmin/cache/manager/decorators/local |
||
106 | */ |
||
107 | |||
108 | /** madmin/cache/manager/decorators/global |
||
109 | * Adds a list of globally available decorators only to the cache manager |
||
110 | * |
||
111 | * Decorators extend the functionality of a class by adding new aspects |
||
112 | * (e.g. cache what is currently done), executing the methods of the underlying |
||
113 | * class only in certain conditions (e.g. only for cacheged in users) or |
||
114 | * modify what is returned to the caller. |
||
115 | * |
||
116 | * This option allows you to wrap global decorators |
||
117 | * ("\Aimeos\MShop\Common\Manager\Decorator\*") around the cache manager. |
||
118 | * |
||
119 | * madmin/cache/manager/decorators/global = array( 'decorator1' ) |
||
120 | * |
||
121 | * This would add the decorator named "decorator1" defined by |
||
122 | * "\Aimeos\MShop\Common\Manager\Decorator\Decorator1" only to the cache controller. |
||
123 | * |
||
124 | * @param array List of decorator names |
||
125 | * @since 2014.03 |
||
126 | * @category Developer |
||
127 | * @see madmin/common/manager/decorators/default |
||
128 | * @see madmin/cache/manager/decorators/excludes |
||
129 | * @see madmin/cache/manager/decorators/local |
||
130 | */ |
||
131 | |||
132 | /** madmin/cache/manager/decorators/local |
||
133 | * Adds a list of local decorators only to the cache manager |
||
134 | * |
||
135 | * Decorators extend the functionality of a class by adding new aspects |
||
136 | * (e.g. cache what is currently done), executing the methods of the underlying |
||
137 | * class only in certain conditions (e.g. only for cacheged in users) or |
||
138 | * modify what is returned to the caller. |
||
139 | * |
||
140 | * This option allows you to wrap local decorators |
||
141 | * ("\Aimeos\MShop\Common\Manager\Decorator\*") around the cache manager. |
||
142 | * |
||
143 | * madmin/cache/manager/decorators/local = array( 'decorator2' ) |
||
144 | * |
||
145 | * This would add the decorator named "decorator2" defined by |
||
146 | * "\Aimeos\MShop\Common\Manager\Decorator\Decorator2" only to the cache |
||
147 | * controller. |
||
148 | * |
||
149 | * @param array List of decorator names |
||
150 | * @since 2014.03 |
||
151 | * @category Developer |
||
152 | * @see madmin/common/manager/decorators/default |
||
153 | * @see madmin/cache/manager/decorators/excludes |
||
154 | * @see madmin/cache/manager/decorators/global |
||
155 | */ |
||
156 | return self::addManagerDecorators( $context, $manager, 'cache' ); |
||
157 | } |
||
158 | } |
||
159 |