PluginProbe ʕ •ᴥ•ʔ
WP All Export – Drag & Drop Export to Any Custom CSV, XML & Excel / 1.3.4
WP All Export – Drag & Drop Export to Any Custom CSV, XML & Excel v1.3.4
trunk 0.9.0 0.9.1 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.2.0 1.2.1 1.2.10 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.10 1.4.11 1.4.12 1.4.13 1.4.14 1.4.15 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 1.5.0
wp-all-export / src / Di / WpaeDi.php
wp-all-export / src / Di Last commit date
WpaeDi.php 9 years ago
WpaeDi.php
61 lines
1 <?php
2
3 namespace Wpae\Di;
4
5
6 class WpaeDi
7 {
8 private $config;
9
10 private $cache;
11
12 private $services;
13
14 public function __construct($config)
15 {
16
17 $this->config = $config;
18
19 $this->services = [
20 'c' => [
21 'value' => 10
22 ],
23 'a' => [
24 'class' => '\Wpae\ClassA',
25 'arguments' => [
26 '@a',
27 '@b'
28 ]
29 ],
30 'b' => [
31 'class' => '\Wpae\ClassB',
32 'arguments' => [
33 '@a',
34 '%c'
35 ]
36 ]
37 ];
38
39 }
40
41 public function get($name) {
42 if(isset($this->cache[$name])) {
43 return $this->cache[$name];
44 }
45 if(isset($this->services[$name])) {
46 $arguments = [];
47 if(count($this->services[$name]['arguments'])){
48 foreach($this->services[$name]['arguments'] as $argument) {
49 $arguments[] = $this->get($argument);
50 }
51 } else {
52 $serviceClass = $this->services[$name]['class'];
53 $this->cache[$name] = new $serviceClass();
54 return $this->cache[$name];
55 }
56 $r = new \ReflectionClass($this->services[$name]['class']);
57 $this->cache[$name] = $r->newInstanceArgs($arguments);
58 }
59 return $this->cache[$name];
60 }
61 }