1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
5
|
|
|
* @copyright Aimeos (aimeos.org), 2016 |
6
|
|
|
* @package Admin |
7
|
|
|
* @subpackage JQAdm |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
|
11
|
|
|
namespace Aimeos\Admin\JQAdm\Dashboard; |
12
|
|
|
|
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Factory for dashboard JQAdm client |
16
|
|
|
* |
17
|
|
|
* @package Admin |
18
|
|
|
* @subpackage JQAdm |
19
|
|
|
*/ |
20
|
|
|
class Factory |
21
|
|
|
extends \Aimeos\Admin\JQAdm\Common\Factory\Base |
|
|
|
|
22
|
|
|
implements \Aimeos\Admin\JQAdm\Common\Factory\Iface |
|
|
|
|
23
|
|
|
{ |
24
|
|
|
/** |
25
|
|
|
* Creates a dashboard client object |
26
|
|
|
* |
27
|
|
|
* @param \Aimeos\MShop\Context\Item\Iface $context Shop context instance with necessary objects |
28
|
|
|
* @param array $templatePaths List of file system paths where the templates are stored |
29
|
|
|
* @param string|null $name Admin name (default: "Standard") |
30
|
|
|
* @return \Aimeos\Admin\JQAdm\Iface Filter part implementing \Aimeos\Admin\JQAdm\Iface |
31
|
|
|
* @throws \Aimeos\Admin\JQAdm\Exception If requested client implementation couldn't be found or initialisation fails |
32
|
|
|
*/ |
33
|
|
|
public static function createClient( \Aimeos\MShop\Context\Item\Iface $context, array $templatePaths, $name = null ) |
34
|
|
|
{ |
35
|
|
|
/** admin/jqadm/dashboard/name |
36
|
|
|
* Class name of the used account favorite client implementation |
37
|
|
|
* |
38
|
|
|
* Each default admin client 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 client factory knows which class it |
41
|
|
|
* has to instantiate. |
42
|
|
|
* |
43
|
|
|
* For example, if the name of the default class is |
44
|
|
|
* |
45
|
|
|
* \Aimeos\Admin\JQAdm\Dashboard\Standard |
46
|
|
|
* |
47
|
|
|
* and you want to replace it with your own version named |
48
|
|
|
* |
49
|
|
|
* \Aimeos\Admin\JQAdm\Dashboard\Myfavorite |
50
|
|
|
* |
51
|
|
|
* then you have to set the this configuration option: |
52
|
|
|
* |
53
|
|
|
* admin/jqadm/dashboard/name = Myfavorite |
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 "MyFavorite"! |
63
|
|
|
* |
64
|
|
|
* @param string Last part of the class name |
65
|
|
|
* @since 2016.01 |
66
|
|
|
* @category Developer |
67
|
|
|
*/ |
68
|
|
|
if( $name === null ) { |
69
|
|
|
$name = $context->getConfig()->get( 'admin/jqadm/dashboard/name', 'Standard' ); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
if( ctype_alnum( $name ) === false ) |
73
|
|
|
{ |
74
|
|
|
$classname = is_string( $name ) ? '\\Aimeos\\Admin\\JQAdm\\Dashboard\\' . $name : '<not a string>'; |
75
|
|
|
throw new \Aimeos\Admin\JQAdm\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) ); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
$iface = '\\Aimeos\\Admin\\JQAdm\\Iface'; |
79
|
|
|
$classname = '\\Aimeos\\Admin\\JQAdm\\Dashboard\\' . $name; |
80
|
|
|
|
81
|
|
|
$client = self::createClientBase( $context, $classname, $iface, $templatePaths ); |
82
|
|
|
|
83
|
|
|
return self::addClientDecorators( $context, $client, $templatePaths, 'dashboard' ); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
} |
87
|
|
|
|