PluginProbe
CSS & JavaScript Toolbox / 11.6
CSS & JavaScript Toolbox v11.6
trunk 0.3 0.8 10 10.1 11 11.2 11.3 11.4 11.5 11.6 11.7 11.8 11.9 11.9.1 12 12.0 12.0.1 12.0.3 12.0.4 12.0.5 12.0.6 12.0.7 6.0 6.0.11 All 60 releases
css-javascript-toolbox / framework / ServicesFW / PluginBase.class.php

PluginBase.class.php in CSS & JavaScript Toolbox 11.6, at framework/ServicesFW/PluginBase.class.php

166 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 *
4 */
5
6 /**
7 *
8 */
9 abstract class CJTServicesPluginBase implements CJTServicesIPluginBase
10 {
11
12 /**
13 * put your comment there...
14 *
15 * @var mixed
16 */
17 private $config;
18
19 /**
20 * put your comment there...
21 *
22 * @var mixed
23 */
24 private $dir;
25
26 /**
27 * put your comment there...
28 *
29 * @var mixed
30 */
31 private $file;
32
33 /**
34 * put your comment there...
35 *
36 * @var mixed
37 */
38 private $services;
39
40 /**
41 * put your comment there...
42 *
43 * @var mixed
44 */
45 private $url;
46
47 /**
48 * put your comment there...
49 *
50 * @param mixed $file
51 * @param mixed $config
52 */
53 protected function __construct( $file, $config )
54 {
55
56 $this->file = $file;
57 $this->dir = dirname( $file );
58 $this->url = plugin_dir_url( $file );
59 $this->config = $config;
60
61 }
62
63 /**
64 * put your comment there...
65 *
66 * @param mixed $item
67 */
68 public function getConfig( $configNames )
69 {
70
71 $configs = array();
72
73 # Each passed parameter is configuration to be merged to former one
74 foreach ( func_get_args() as $configName )
75 {
76 # Generaly target config point to all configs
77 # below loop is to point to the correct item
78 $targetConfig =& $this->config;
79
80 # Explode name and get array element recusively
81 foreach ( explode( '.', $configName ) as $itemName )
82 {
83
84 if ( ! isset( $targetConfig[ $itemName ] ) )
85 {
86 throw new Exception( "Config: {$itemName} doesn't exists in {$configName}!!!" );
87 }
88
89 # Go deeper as requested
90 $targetConfig =& $targetConfig[ $itemName ];
91 }
92
93 $configs = array_merge( $configs, $targetConfig );
94 }
95
96 return $configs;
97 }
98
99 /**
100 * put your comment there...
101 *
102 * @param mixed $serviceConfig
103 */
104 public function & getController( $serviceConfig )
105 {
106
107 return CJTServicesMVCController::getInstance( $serviceConfig, $serviceConfig[ 'route' ] );
108 }
109
110 /**
111 * put your comment there...
112 *
113 */
114 public function getDir()
115 {
116 return $this->dir;
117 }
118
119 /**
120 * put your comment there...
121 *
122 */
123 public function getFile()
124 {
125 return $this->file;
126 }
127
128 /**
129 * put your comment there...
130 *
131 */
132 public function getName()
133 {
134 return basename( $this->dir );
135 }
136
137 /**
138 * put your comment there...
139 *
140 */
141 public function getUrl()
142 {
143 return $this->url;
144 }
145
146 /**
147 * put your comment there...
148 *
149 * @param mixed $list
150 */
151 protected function & loadServices( $list )
152 {
153
154 foreach ( func_get_args() as $service )
155 {
156
157 $this->services[ get_class( $service ) ] =& $service;
158
159 # Start
160 $service->start();
161 }
162
163 return $this;
164 }
165
166 }