@@ -15,36 +15,36 @@ |
||
15 | 15 | interface DomainInterface |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * @return string |
|
20 | - * @throws DomainException |
|
21 | - */ |
|
22 | - public function pluginFile(); |
|
18 | + /** |
|
19 | + * @return string |
|
20 | + * @throws DomainException |
|
21 | + */ |
|
22 | + public function pluginFile(); |
|
23 | 23 | |
24 | 24 | |
25 | - /** |
|
26 | - * @return string |
|
27 | - * @throws DomainException |
|
28 | - */ |
|
29 | - public function pluginBasename(); |
|
25 | + /** |
|
26 | + * @return string |
|
27 | + * @throws DomainException |
|
28 | + */ |
|
29 | + public function pluginBasename(); |
|
30 | 30 | |
31 | 31 | |
32 | - /** |
|
33 | - * @return string |
|
34 | - */ |
|
35 | - public function pluginPath(); |
|
32 | + /** |
|
33 | + * @return string |
|
34 | + */ |
|
35 | + public function pluginPath(); |
|
36 | 36 | |
37 | 37 | |
38 | - /** |
|
39 | - * @return string |
|
40 | - * @throws DomainException |
|
41 | - */ |
|
42 | - public function pluginUrl(); |
|
38 | + /** |
|
39 | + * @return string |
|
40 | + * @throws DomainException |
|
41 | + */ |
|
42 | + public function pluginUrl(); |
|
43 | 43 | |
44 | 44 | |
45 | - /** |
|
46 | - * @return string |
|
47 | - * @throws DomainException |
|
48 | - */ |
|
49 | - public function version(); |
|
45 | + /** |
|
46 | + * @return string |
|
47 | + * @throws DomainException |
|
48 | + */ |
|
49 | + public function version(); |
|
50 | 50 | } |
@@ -21,146 +21,146 @@ |
||
21 | 21 | class CachingLoader extends LoaderDecorator |
22 | 22 | { |
23 | 23 | |
24 | - /** |
|
25 | - * @var CollectionInterface $cache |
|
26 | - */ |
|
27 | - protected $cache; |
|
28 | - |
|
29 | - /** |
|
30 | - * @var string $identifier |
|
31 | - */ |
|
32 | - protected $identifier; |
|
33 | - |
|
34 | - |
|
35 | - |
|
36 | - /** |
|
37 | - * CachingLoader constructor. |
|
38 | - * |
|
39 | - * @param LoaderDecoratorInterface $loader |
|
40 | - * @param CollectionInterface $cache |
|
41 | - * @param string $identifier |
|
42 | - * @throws InvalidDataTypeException |
|
43 | - */ |
|
44 | - public function __construct(LoaderDecoratorInterface $loader, CollectionInterface $cache, $identifier = '') |
|
45 | - { |
|
46 | - parent::__construct($loader); |
|
47 | - $this->cache = $cache; |
|
48 | - $this->setIdentifier($identifier); |
|
49 | - if ($this->identifier !== '') { |
|
50 | - // to only clear this cache, and assuming an identifier has been set, simply do the following: |
|
51 | - // do_action('AHEE__EventEspresso_core_services_loaders_CachingLoader__resetCache__IDENTIFIER'); |
|
52 | - // where "IDENTIFIER" = the string that was set during construction |
|
53 | - add_action( |
|
54 | - "AHEE__EventEspresso_core_services_loaders_CachingLoader__resetCache__{$identifier}", |
|
55 | - array($this, 'reset') |
|
56 | - ); |
|
57 | - } |
|
58 | - // to clear ALL caches, simply do the following: |
|
59 | - // do_action('AHEE__EventEspresso_core_services_loaders_CachingLoader__resetCache'); |
|
60 | - add_action( |
|
61 | - 'AHEE__EventEspresso_core_services_loaders_CachingLoader__resetCache', |
|
62 | - array($this, 'reset') |
|
63 | - ); |
|
64 | - } |
|
65 | - |
|
66 | - |
|
67 | - |
|
68 | - /** |
|
69 | - * @return string |
|
70 | - */ |
|
71 | - public function identifier() |
|
72 | - { |
|
73 | - return $this->identifier; |
|
74 | - } |
|
75 | - |
|
76 | - |
|
77 | - |
|
78 | - /** |
|
79 | - * @param string $identifier |
|
80 | - * @throws InvalidDataTypeException |
|
81 | - */ |
|
82 | - private function setIdentifier($identifier) |
|
83 | - { |
|
84 | - if ( ! is_string($identifier)) { |
|
85 | - throw new InvalidDataTypeException('$identifier', $identifier, 'string'); |
|
86 | - } |
|
87 | - $this->identifier = $identifier; |
|
88 | - } |
|
89 | - |
|
90 | - |
|
91 | - |
|
92 | - /** |
|
93 | - * @param string $fqcn |
|
94 | - * @param array $arguments |
|
95 | - * @param bool $shared |
|
96 | - * @return mixed |
|
97 | - */ |
|
98 | - public function load($fqcn, $arguments = array(), $shared = true) |
|
99 | - { |
|
100 | - $fqcn = ltrim($fqcn, '\\'); |
|
101 | - // caching can be turned off via the following code: |
|
102 | - // add_filter('FHEE__EventEspresso_core_services_loaders_CachingLoader__load__bypass_cache', '__return_true'); |
|
103 | - if( |
|
104 | - apply_filters( |
|
105 | - 'FHEE__EventEspresso_core_services_loaders_CachingLoader__load__bypass_cache', |
|
106 | - false, |
|
107 | - $this |
|
108 | - ) |
|
109 | - ){ |
|
110 | - // even though $shared might be true, caching could be bypassed for whatever reason, |
|
111 | - // so we don't want the core loader to cache anything, therefore caching is turned off |
|
112 | - return $this->loader->load($fqcn, $arguments, false); |
|
113 | - } |
|
114 | - $identifier = md5($fqcn . $this->getIdentifierForArgument($arguments)); |
|
115 | - if($this->cache->has($identifier)){ |
|
116 | - return $this->cache->get($identifier); |
|
117 | - } |
|
118 | - $object = $this->loader->load($fqcn, $arguments, $shared); |
|
119 | - if($object instanceof $fqcn){ |
|
120 | - $this->cache->add($object, $identifier); |
|
121 | - } |
|
122 | - return $object; |
|
123 | - } |
|
124 | - |
|
125 | - |
|
126 | - |
|
127 | - /** |
|
128 | - * empties cache and calls reset() on loader if method exists |
|
129 | - */ |
|
130 | - public function reset() |
|
131 | - { |
|
132 | - $this->cache->trashAndDetachAll(); |
|
133 | - $this->loader->reset(); |
|
134 | - } |
|
135 | - |
|
136 | - |
|
137 | - |
|
138 | - /** |
|
139 | - * build a string representation of a class' arguments |
|
140 | - * (mostly because Closures can't be serialized) |
|
141 | - * |
|
142 | - * @param array $arguments |
|
143 | - * @return string |
|
144 | - */ |
|
145 | - private function getIdentifierForArgument(array $arguments) |
|
146 | - { |
|
147 | - $identifier = ''; |
|
148 | - foreach ($arguments as $argument) { |
|
149 | - switch (true) { |
|
150 | - case is_object($argument) : |
|
151 | - case $argument instanceof Closure : |
|
152 | - $identifier .= spl_object_hash($argument); |
|
153 | - break; |
|
154 | - case is_array($argument) : |
|
155 | - $identifier .= $this->getIdentifierForArgument($argument); |
|
156 | - break; |
|
157 | - default : |
|
158 | - $identifier .= $argument; |
|
159 | - break; |
|
160 | - } |
|
161 | - } |
|
162 | - return $identifier; |
|
163 | - } |
|
24 | + /** |
|
25 | + * @var CollectionInterface $cache |
|
26 | + */ |
|
27 | + protected $cache; |
|
28 | + |
|
29 | + /** |
|
30 | + * @var string $identifier |
|
31 | + */ |
|
32 | + protected $identifier; |
|
33 | + |
|
34 | + |
|
35 | + |
|
36 | + /** |
|
37 | + * CachingLoader constructor. |
|
38 | + * |
|
39 | + * @param LoaderDecoratorInterface $loader |
|
40 | + * @param CollectionInterface $cache |
|
41 | + * @param string $identifier |
|
42 | + * @throws InvalidDataTypeException |
|
43 | + */ |
|
44 | + public function __construct(LoaderDecoratorInterface $loader, CollectionInterface $cache, $identifier = '') |
|
45 | + { |
|
46 | + parent::__construct($loader); |
|
47 | + $this->cache = $cache; |
|
48 | + $this->setIdentifier($identifier); |
|
49 | + if ($this->identifier !== '') { |
|
50 | + // to only clear this cache, and assuming an identifier has been set, simply do the following: |
|
51 | + // do_action('AHEE__EventEspresso_core_services_loaders_CachingLoader__resetCache__IDENTIFIER'); |
|
52 | + // where "IDENTIFIER" = the string that was set during construction |
|
53 | + add_action( |
|
54 | + "AHEE__EventEspresso_core_services_loaders_CachingLoader__resetCache__{$identifier}", |
|
55 | + array($this, 'reset') |
|
56 | + ); |
|
57 | + } |
|
58 | + // to clear ALL caches, simply do the following: |
|
59 | + // do_action('AHEE__EventEspresso_core_services_loaders_CachingLoader__resetCache'); |
|
60 | + add_action( |
|
61 | + 'AHEE__EventEspresso_core_services_loaders_CachingLoader__resetCache', |
|
62 | + array($this, 'reset') |
|
63 | + ); |
|
64 | + } |
|
65 | + |
|
66 | + |
|
67 | + |
|
68 | + /** |
|
69 | + * @return string |
|
70 | + */ |
|
71 | + public function identifier() |
|
72 | + { |
|
73 | + return $this->identifier; |
|
74 | + } |
|
75 | + |
|
76 | + |
|
77 | + |
|
78 | + /** |
|
79 | + * @param string $identifier |
|
80 | + * @throws InvalidDataTypeException |
|
81 | + */ |
|
82 | + private function setIdentifier($identifier) |
|
83 | + { |
|
84 | + if ( ! is_string($identifier)) { |
|
85 | + throw new InvalidDataTypeException('$identifier', $identifier, 'string'); |
|
86 | + } |
|
87 | + $this->identifier = $identifier; |
|
88 | + } |
|
89 | + |
|
90 | + |
|
91 | + |
|
92 | + /** |
|
93 | + * @param string $fqcn |
|
94 | + * @param array $arguments |
|
95 | + * @param bool $shared |
|
96 | + * @return mixed |
|
97 | + */ |
|
98 | + public function load($fqcn, $arguments = array(), $shared = true) |
|
99 | + { |
|
100 | + $fqcn = ltrim($fqcn, '\\'); |
|
101 | + // caching can be turned off via the following code: |
|
102 | + // add_filter('FHEE__EventEspresso_core_services_loaders_CachingLoader__load__bypass_cache', '__return_true'); |
|
103 | + if( |
|
104 | + apply_filters( |
|
105 | + 'FHEE__EventEspresso_core_services_loaders_CachingLoader__load__bypass_cache', |
|
106 | + false, |
|
107 | + $this |
|
108 | + ) |
|
109 | + ){ |
|
110 | + // even though $shared might be true, caching could be bypassed for whatever reason, |
|
111 | + // so we don't want the core loader to cache anything, therefore caching is turned off |
|
112 | + return $this->loader->load($fqcn, $arguments, false); |
|
113 | + } |
|
114 | + $identifier = md5($fqcn . $this->getIdentifierForArgument($arguments)); |
|
115 | + if($this->cache->has($identifier)){ |
|
116 | + return $this->cache->get($identifier); |
|
117 | + } |
|
118 | + $object = $this->loader->load($fqcn, $arguments, $shared); |
|
119 | + if($object instanceof $fqcn){ |
|
120 | + $this->cache->add($object, $identifier); |
|
121 | + } |
|
122 | + return $object; |
|
123 | + } |
|
124 | + |
|
125 | + |
|
126 | + |
|
127 | + /** |
|
128 | + * empties cache and calls reset() on loader if method exists |
|
129 | + */ |
|
130 | + public function reset() |
|
131 | + { |
|
132 | + $this->cache->trashAndDetachAll(); |
|
133 | + $this->loader->reset(); |
|
134 | + } |
|
135 | + |
|
136 | + |
|
137 | + |
|
138 | + /** |
|
139 | + * build a string representation of a class' arguments |
|
140 | + * (mostly because Closures can't be serialized) |
|
141 | + * |
|
142 | + * @param array $arguments |
|
143 | + * @return string |
|
144 | + */ |
|
145 | + private function getIdentifierForArgument(array $arguments) |
|
146 | + { |
|
147 | + $identifier = ''; |
|
148 | + foreach ($arguments as $argument) { |
|
149 | + switch (true) { |
|
150 | + case is_object($argument) : |
|
151 | + case $argument instanceof Closure : |
|
152 | + $identifier .= spl_object_hash($argument); |
|
153 | + break; |
|
154 | + case is_array($argument) : |
|
155 | + $identifier .= $this->getIdentifierForArgument($argument); |
|
156 | + break; |
|
157 | + default : |
|
158 | + $identifier .= $argument; |
|
159 | + break; |
|
160 | + } |
|
161 | + } |
|
162 | + return $identifier; |
|
163 | + } |
|
164 | 164 | |
165 | 165 | |
166 | 166 | } |
@@ -100,23 +100,23 @@ |
||
100 | 100 | $fqcn = ltrim($fqcn, '\\'); |
101 | 101 | // caching can be turned off via the following code: |
102 | 102 | // add_filter('FHEE__EventEspresso_core_services_loaders_CachingLoader__load__bypass_cache', '__return_true'); |
103 | - if( |
|
103 | + if ( |
|
104 | 104 | apply_filters( |
105 | 105 | 'FHEE__EventEspresso_core_services_loaders_CachingLoader__load__bypass_cache', |
106 | 106 | false, |
107 | 107 | $this |
108 | 108 | ) |
109 | - ){ |
|
109 | + ) { |
|
110 | 110 | // even though $shared might be true, caching could be bypassed for whatever reason, |
111 | 111 | // so we don't want the core loader to cache anything, therefore caching is turned off |
112 | 112 | return $this->loader->load($fqcn, $arguments, false); |
113 | 113 | } |
114 | - $identifier = md5($fqcn . $this->getIdentifierForArgument($arguments)); |
|
115 | - if($this->cache->has($identifier)){ |
|
114 | + $identifier = md5($fqcn.$this->getIdentifierForArgument($arguments)); |
|
115 | + if ($this->cache->has($identifier)) { |
|
116 | 116 | return $this->cache->get($identifier); |
117 | 117 | } |
118 | 118 | $object = $this->loader->load($fqcn, $arguments, $shared); |
119 | - if($object instanceof $fqcn){ |
|
119 | + if ($object instanceof $fqcn) { |
|
120 | 120 | $this->cache->add($object, $identifier); |
121 | 121 | } |
122 | 122 | return $object; |
@@ -20,15 +20,15 @@ |
||
20 | 20 | interface RequiresDependencyMapInterface |
21 | 21 | { |
22 | 22 | |
23 | - /** |
|
24 | - * @param EE_Dependency_Map $dependency_map |
|
25 | - */ |
|
26 | - public function setDependencyMap($dependency_map); |
|
27 | - |
|
28 | - /** |
|
29 | - * @return EE_Dependency_Map |
|
30 | - */ |
|
31 | - public function dependencyMap(); |
|
23 | + /** |
|
24 | + * @param EE_Dependency_Map $dependency_map |
|
25 | + */ |
|
26 | + public function setDependencyMap($dependency_map); |
|
27 | + |
|
28 | + /** |
|
29 | + * @return EE_Dependency_Map |
|
30 | + */ |
|
31 | + public function dependencyMap(); |
|
32 | 32 | |
33 | 33 | } |
34 | 34 | // Location: RequiresDependencyMap.php |
@@ -32,115 +32,115 @@ |
||
32 | 32 | class CoreLoader implements LoaderDecoratorInterface |
33 | 33 | { |
34 | 34 | |
35 | - /** |
|
36 | - * @var EE_Registry|CoffeeShop $generator |
|
37 | - */ |
|
38 | - private $generator; |
|
39 | - |
|
40 | - |
|
41 | - |
|
42 | - /** |
|
43 | - * CoreLoader constructor. |
|
44 | - * |
|
45 | - * @param EE_Registry|CoffeeShop $generator |
|
46 | - * @throws InvalidArgumentException |
|
47 | - */ |
|
48 | - public function __construct($generator) |
|
49 | - { |
|
50 | - if(!($generator instanceof EE_Registry || $generator instanceof CoffeeShop)) { |
|
51 | - throw new InvalidArgumentException( |
|
52 | - esc_html__( |
|
53 | - 'The CoreLoader class must receive an instance of EE_Registry or the CoffeeShop DI container.', |
|
54 | - 'event_espresso' |
|
55 | - ) |
|
56 | - ); |
|
57 | - } |
|
58 | - $this->generator = $generator; |
|
59 | - } |
|
60 | - |
|
61 | - |
|
62 | - |
|
63 | - /** |
|
64 | - * Calls the appropriate loading method from the installed generator; |
|
65 | - * If EE_Registry is being used, then the additional parameters for the EE_Registry::create() method |
|
66 | - * can be added to the $arguments array and they will be extracted and passed to EE_Registry::create(), |
|
67 | - * but NOT to the class being instantiated. |
|
68 | - * This is done by adding the parameters to the $arguments array as follows: |
|
69 | - * array( |
|
70 | - * 'EE_Registry::create(from_db)' => true, // boolean value, default = false |
|
71 | - * 'EE_Registry::create(load_only)' => true, // boolean value, default = false |
|
72 | - * 'EE_Registry::create(addon)' => true, // boolean value, default = false |
|
73 | - * ) |
|
74 | - * |
|
75 | - * @param string $fqcn |
|
76 | - * @param array $arguments |
|
77 | - * @param bool $shared |
|
78 | - * @return mixed |
|
79 | - * @throws OutOfBoundsException |
|
80 | - * @throws ServiceExistsException |
|
81 | - * @throws InstantiationException |
|
82 | - * @throws InvalidIdentifierException |
|
83 | - * @throws InvalidDataTypeException |
|
84 | - * @throws InvalidClassException |
|
85 | - * @throws EE_Error |
|
86 | - * @throws ServiceNotFoundException |
|
87 | - * @throws ReflectionException |
|
88 | - */ |
|
89 | - public function load($fqcn, $arguments = array(), $shared = true) |
|
90 | - { |
|
91 | - $shared = filter_var($shared, FILTER_VALIDATE_BOOLEAN); |
|
92 | - if($this->generator instanceof EE_Registry) { |
|
93 | - // check if additional EE_Registry::create() arguments have been passed |
|
94 | - // from_db |
|
95 | - $from_db = isset($arguments['EE_Registry::create(from_db)']) |
|
96 | - ? filter_var($arguments['EE_Registry::create(from_db)'], FILTER_VALIDATE_BOOLEAN) |
|
97 | - : false; |
|
98 | - // load_only |
|
99 | - $load_only = isset($arguments['EE_Registry::create(load_only)']) |
|
100 | - ? filter_var($arguments['EE_Registry::create(load_only)'], FILTER_VALIDATE_BOOLEAN) |
|
101 | - : false; |
|
102 | - // addon |
|
103 | - $addon = isset($arguments['EE_Registry::create(addon)']) |
|
104 | - ? filter_var($arguments['EE_Registry::create(addon)'], FILTER_VALIDATE_BOOLEAN) |
|
105 | - : false; |
|
106 | - unset( |
|
107 | - $arguments['EE_Registry::create(from_db)'], |
|
108 | - $arguments['EE_Registry::create(load_only)'], |
|
109 | - $arguments['EE_Registry::create(addon)'] |
|
110 | - ); |
|
111 | - // addons need to be cached on EE_Registry |
|
112 | - $shared = $addon ? true : $shared; |
|
113 | - return $this->generator->create( |
|
114 | - $fqcn, |
|
115 | - $arguments, |
|
116 | - $shared, |
|
117 | - $from_db, |
|
118 | - $load_only, |
|
119 | - $addon |
|
120 | - ); |
|
121 | - } |
|
122 | - return $this->generator->brew( |
|
123 | - $fqcn, |
|
124 | - $arguments, |
|
125 | - $shared ? CoffeeMaker::BREW_SHARED : CoffeeMaker::BREW_NEW |
|
126 | - ); |
|
127 | - |
|
128 | - } |
|
129 | - |
|
130 | - |
|
131 | - |
|
132 | - /** |
|
133 | - * calls reset() on generator if method exists |
|
134 | - * |
|
135 | - * @throws EE_Error |
|
136 | - * @throws ReflectionException |
|
137 | - */ |
|
138 | - public function reset() |
|
139 | - { |
|
140 | - if (method_exists($this->generator, 'reset')) { |
|
141 | - $this->generator->reset(); |
|
142 | - } |
|
143 | - } |
|
35 | + /** |
|
36 | + * @var EE_Registry|CoffeeShop $generator |
|
37 | + */ |
|
38 | + private $generator; |
|
39 | + |
|
40 | + |
|
41 | + |
|
42 | + /** |
|
43 | + * CoreLoader constructor. |
|
44 | + * |
|
45 | + * @param EE_Registry|CoffeeShop $generator |
|
46 | + * @throws InvalidArgumentException |
|
47 | + */ |
|
48 | + public function __construct($generator) |
|
49 | + { |
|
50 | + if(!($generator instanceof EE_Registry || $generator instanceof CoffeeShop)) { |
|
51 | + throw new InvalidArgumentException( |
|
52 | + esc_html__( |
|
53 | + 'The CoreLoader class must receive an instance of EE_Registry or the CoffeeShop DI container.', |
|
54 | + 'event_espresso' |
|
55 | + ) |
|
56 | + ); |
|
57 | + } |
|
58 | + $this->generator = $generator; |
|
59 | + } |
|
60 | + |
|
61 | + |
|
62 | + |
|
63 | + /** |
|
64 | + * Calls the appropriate loading method from the installed generator; |
|
65 | + * If EE_Registry is being used, then the additional parameters for the EE_Registry::create() method |
|
66 | + * can be added to the $arguments array and they will be extracted and passed to EE_Registry::create(), |
|
67 | + * but NOT to the class being instantiated. |
|
68 | + * This is done by adding the parameters to the $arguments array as follows: |
|
69 | + * array( |
|
70 | + * 'EE_Registry::create(from_db)' => true, // boolean value, default = false |
|
71 | + * 'EE_Registry::create(load_only)' => true, // boolean value, default = false |
|
72 | + * 'EE_Registry::create(addon)' => true, // boolean value, default = false |
|
73 | + * ) |
|
74 | + * |
|
75 | + * @param string $fqcn |
|
76 | + * @param array $arguments |
|
77 | + * @param bool $shared |
|
78 | + * @return mixed |
|
79 | + * @throws OutOfBoundsException |
|
80 | + * @throws ServiceExistsException |
|
81 | + * @throws InstantiationException |
|
82 | + * @throws InvalidIdentifierException |
|
83 | + * @throws InvalidDataTypeException |
|
84 | + * @throws InvalidClassException |
|
85 | + * @throws EE_Error |
|
86 | + * @throws ServiceNotFoundException |
|
87 | + * @throws ReflectionException |
|
88 | + */ |
|
89 | + public function load($fqcn, $arguments = array(), $shared = true) |
|
90 | + { |
|
91 | + $shared = filter_var($shared, FILTER_VALIDATE_BOOLEAN); |
|
92 | + if($this->generator instanceof EE_Registry) { |
|
93 | + // check if additional EE_Registry::create() arguments have been passed |
|
94 | + // from_db |
|
95 | + $from_db = isset($arguments['EE_Registry::create(from_db)']) |
|
96 | + ? filter_var($arguments['EE_Registry::create(from_db)'], FILTER_VALIDATE_BOOLEAN) |
|
97 | + : false; |
|
98 | + // load_only |
|
99 | + $load_only = isset($arguments['EE_Registry::create(load_only)']) |
|
100 | + ? filter_var($arguments['EE_Registry::create(load_only)'], FILTER_VALIDATE_BOOLEAN) |
|
101 | + : false; |
|
102 | + // addon |
|
103 | + $addon = isset($arguments['EE_Registry::create(addon)']) |
|
104 | + ? filter_var($arguments['EE_Registry::create(addon)'], FILTER_VALIDATE_BOOLEAN) |
|
105 | + : false; |
|
106 | + unset( |
|
107 | + $arguments['EE_Registry::create(from_db)'], |
|
108 | + $arguments['EE_Registry::create(load_only)'], |
|
109 | + $arguments['EE_Registry::create(addon)'] |
|
110 | + ); |
|
111 | + // addons need to be cached on EE_Registry |
|
112 | + $shared = $addon ? true : $shared; |
|
113 | + return $this->generator->create( |
|
114 | + $fqcn, |
|
115 | + $arguments, |
|
116 | + $shared, |
|
117 | + $from_db, |
|
118 | + $load_only, |
|
119 | + $addon |
|
120 | + ); |
|
121 | + } |
|
122 | + return $this->generator->brew( |
|
123 | + $fqcn, |
|
124 | + $arguments, |
|
125 | + $shared ? CoffeeMaker::BREW_SHARED : CoffeeMaker::BREW_NEW |
|
126 | + ); |
|
127 | + |
|
128 | + } |
|
129 | + |
|
130 | + |
|
131 | + |
|
132 | + /** |
|
133 | + * calls reset() on generator if method exists |
|
134 | + * |
|
135 | + * @throws EE_Error |
|
136 | + * @throws ReflectionException |
|
137 | + */ |
|
138 | + public function reset() |
|
139 | + { |
|
140 | + if (method_exists($this->generator, 'reset')) { |
|
141 | + $this->generator->reset(); |
|
142 | + } |
|
143 | + } |
|
144 | 144 | |
145 | 145 | } |
146 | 146 | // End of file CoreLoader.php |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | */ |
48 | 48 | public function __construct($generator) |
49 | 49 | { |
50 | - if(!($generator instanceof EE_Registry || $generator instanceof CoffeeShop)) { |
|
50 | + if ( ! ($generator instanceof EE_Registry || $generator instanceof CoffeeShop)) { |
|
51 | 51 | throw new InvalidArgumentException( |
52 | 52 | esc_html__( |
53 | 53 | 'The CoreLoader class must receive an instance of EE_Registry or the CoffeeShop DI container.', |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | public function load($fqcn, $arguments = array(), $shared = true) |
90 | 90 | { |
91 | 91 | $shared = filter_var($shared, FILTER_VALIDATE_BOOLEAN); |
92 | - if($this->generator instanceof EE_Registry) { |
|
92 | + if ($this->generator instanceof EE_Registry) { |
|
93 | 93 | // check if additional EE_Registry::create() arguments have been passed |
94 | 94 | // from_db |
95 | 95 | $from_db = isset($arguments['EE_Registry::create(from_db)']) |
@@ -25,19 +25,19 @@ |
||
25 | 25 | * @param int $code |
26 | 26 | * @param \Exception $previous |
27 | 27 | */ |
28 | - public function __construct( $file_path, $message = '', $code = 0, \Exception $previous = null ) { |
|
29 | - if ( empty( $message ) ) { |
|
28 | + public function __construct($file_path, $message = '', $code = 0, \Exception $previous = null) { |
|
29 | + if (empty($message)) { |
|
30 | 30 | $message = sprintf( |
31 | 31 | __( |
32 | 32 | 'The "%1$s" file is either missing or could not be read due to permissions. Please ensure that the following path is correct and verify that the file permissions are correct:%2$s %3$s', |
33 | 33 | 'event_espresso' |
34 | 34 | ), |
35 | - basename( $file_path ), |
|
35 | + basename($file_path), |
|
36 | 36 | '<br />', |
37 | 37 | $file_path |
38 | 38 | ); |
39 | 39 | } |
40 | - parent::__construct( $message, $code, $previous ); |
|
40 | + parent::__construct($message, $code, $previous); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | } |
@@ -25,14 +25,14 @@ |
||
25 | 25 | * @param int $code |
26 | 26 | * @param \Exception $previous |
27 | 27 | */ |
28 | - public function __construct( $interface_name, $message = '', $code = 0, \Exception $previous = null ) { |
|
29 | - if ( empty( $message ) ) { |
|
28 | + public function __construct($interface_name, $message = '', $code = 0, \Exception $previous = null) { |
|
29 | + if (empty($message)) { |
|
30 | 30 | $message = sprintf( |
31 | - __( 'The "%1$s" Interface is either missing or invalid.', 'event_espresso' ), |
|
31 | + __('The "%1$s" Interface is either missing or invalid.', 'event_espresso'), |
|
32 | 32 | $interface_name |
33 | 33 | ); |
34 | 34 | } |
35 | - parent::__construct( $message, $code, $previous ); |
|
35 | + parent::__construct($message, $code, $previous); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | } |
@@ -29,10 +29,10 @@ discard block |
||
29 | 29 | * @param int $code |
30 | 30 | * @param Exception $previous |
31 | 31 | */ |
32 | - public function __construct( $var_name, $variable, $expected, $message = '', $code = 0, Exception $previous = null ) { |
|
33 | - if ( empty( $message ) ) { |
|
34 | - $expected = strpos( ' was expected.', $expected ) === false |
|
35 | - ? $this->addIndefiniteArticle( $expected ) . ' was expected.' |
|
32 | + public function __construct($var_name, $variable, $expected, $message = '', $code = 0, Exception $previous = null) { |
|
33 | + if (empty($message)) { |
|
34 | + $expected = strpos(' was expected.', $expected) === false |
|
35 | + ? $this->addIndefiniteArticle($expected).' was expected.' |
|
36 | 36 | : $expected; |
37 | 37 | $message = sprintf( |
38 | 38 | __( |
@@ -40,11 +40,11 @@ discard block |
||
40 | 40 | 'event_espresso' |
41 | 41 | ), |
42 | 42 | $var_name, |
43 | - $this->addIndefiniteArticle( gettype( $variable ) ), |
|
43 | + $this->addIndefiniteArticle(gettype($variable)), |
|
44 | 44 | $expected |
45 | 45 | ); |
46 | 46 | } |
47 | - parent::__construct( $message, $code, $previous ); |
|
47 | + parent::__construct($message, $code, $previous); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | |
@@ -53,11 +53,11 @@ discard block |
||
53 | 53 | * @param $string |
54 | 54 | * @return string |
55 | 55 | */ |
56 | - protected function addIndefiniteArticle( $string ) { |
|
57 | - if ( strtolower( $string ) === 'null' ) { |
|
56 | + protected function addIndefiniteArticle($string) { |
|
57 | + if (strtolower($string) === 'null') { |
|
58 | 58 | return $string; |
59 | 59 | } |
60 | - return ( stripos( 'aeiou', $string[0] ) !== false ? 'an ' : 'a ' ) . $string; |
|
60 | + return (stripos('aeiou', $string[0]) !== false ? 'an ' : 'a ').$string; |
|
61 | 61 | } |
62 | 62 | } |
63 | 63 | // End of file InvalidDataTypeException.php |
@@ -24,14 +24,14 @@ |
||
24 | 24 | * @param int $code |
25 | 25 | * @param \Exception $previous |
26 | 26 | */ |
27 | - public function __construct( $class_name, $message = '', $code = 0, \Exception $previous = null ) { |
|
28 | - if ( empty( $message ) ) { |
|
27 | + public function __construct($class_name, $message = '', $code = 0, \Exception $previous = null) { |
|
28 | + if (empty($message)) { |
|
29 | 29 | $message = sprintf( |
30 | - __( 'The "%1$s" Class is either missing or invalid.', 'event_espresso' ), |
|
30 | + __('The "%1$s" Class is either missing or invalid.', 'event_espresso'), |
|
31 | 31 | $class_name |
32 | 32 | ); |
33 | 33 | } |
34 | - parent::__construct( $message, $code, $previous ); |
|
34 | + parent::__construct($message, $code, $previous); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | } |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | */ |
41 | 41 | public static function getShared(FullyQualifiedName $domain_fqcn, array $arguments) |
42 | 42 | { |
43 | - if (! isset($arguments[0], $arguments[1])) { |
|
43 | + if ( ! isset($arguments[0], $arguments[1])) { |
|
44 | 44 | throw new InvalidArgumentException( |
45 | 45 | esc_html__( |
46 | 46 | 'You need to pass at least two arguments, representing the addon plugin file and version, in order to generate a Domain class', |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | ); |
50 | 50 | } |
51 | 51 | $domain = LoaderFactory::getLoader()->getShared($domain_fqcn, $arguments); |
52 | - if (! $domain instanceof $domain_fqcn && ! $domain instanceof DomainBase) { |
|
52 | + if ( ! $domain instanceof $domain_fqcn && ! $domain instanceof DomainBase) { |
|
53 | 53 | throw new DomainException( |
54 | 54 | sprintf( |
55 | 55 | esc_html__( |
@@ -24,44 +24,44 @@ |
||
24 | 24 | class DomainFactory |
25 | 25 | { |
26 | 26 | |
27 | - /** |
|
28 | - * @param FullyQualifiedName $domain_fqcn [required] Fully Qualified Class Name for the Domain class |
|
29 | - * @param array $arguments [required] array of arguments to be passed to the Domain class |
|
30 | - * constructor. Must at least include the following two value objects: |
|
31 | - * array( |
|
32 | - * EventEspresso\core\domain\values\FilePath $plugin_file |
|
33 | - * EventEspresso\core\domain\values\Version $version |
|
34 | - * ) |
|
35 | - * @return mixed |
|
36 | - * @throws DomainException |
|
37 | - * @throws InvalidArgumentException |
|
38 | - * @throws InvalidDataTypeException |
|
39 | - * @throws InvalidInterfaceException |
|
40 | - */ |
|
41 | - public static function getShared(FullyQualifiedName $domain_fqcn, array $arguments) |
|
42 | - { |
|
43 | - if (! isset($arguments[0], $arguments[1])) { |
|
44 | - throw new InvalidArgumentException( |
|
45 | - esc_html__( |
|
46 | - 'You need to pass at least two arguments, representing the addon plugin file and version, in order to generate a Domain class', |
|
47 | - 'event_espresso' |
|
48 | - ) |
|
49 | - ); |
|
50 | - } |
|
51 | - $domain = LoaderFactory::getLoader()->getShared($domain_fqcn, $arguments); |
|
52 | - if (! $domain instanceof $domain_fqcn && ! $domain instanceof DomainBase) { |
|
53 | - throw new DomainException( |
|
54 | - sprintf( |
|
55 | - esc_html__( |
|
56 | - 'The requested Domain class "%1$s" could not be loaded.', |
|
57 | - 'event_espresso' |
|
58 | - ), |
|
59 | - $domain_fqcn |
|
60 | - ) |
|
61 | - ); |
|
62 | - } |
|
63 | - return $domain; |
|
64 | - } |
|
27 | + /** |
|
28 | + * @param FullyQualifiedName $domain_fqcn [required] Fully Qualified Class Name for the Domain class |
|
29 | + * @param array $arguments [required] array of arguments to be passed to the Domain class |
|
30 | + * constructor. Must at least include the following two value objects: |
|
31 | + * array( |
|
32 | + * EventEspresso\core\domain\values\FilePath $plugin_file |
|
33 | + * EventEspresso\core\domain\values\Version $version |
|
34 | + * ) |
|
35 | + * @return mixed |
|
36 | + * @throws DomainException |
|
37 | + * @throws InvalidArgumentException |
|
38 | + * @throws InvalidDataTypeException |
|
39 | + * @throws InvalidInterfaceException |
|
40 | + */ |
|
41 | + public static function getShared(FullyQualifiedName $domain_fqcn, array $arguments) |
|
42 | + { |
|
43 | + if (! isset($arguments[0], $arguments[1])) { |
|
44 | + throw new InvalidArgumentException( |
|
45 | + esc_html__( |
|
46 | + 'You need to pass at least two arguments, representing the addon plugin file and version, in order to generate a Domain class', |
|
47 | + 'event_espresso' |
|
48 | + ) |
|
49 | + ); |
|
50 | + } |
|
51 | + $domain = LoaderFactory::getLoader()->getShared($domain_fqcn, $arguments); |
|
52 | + if (! $domain instanceof $domain_fqcn && ! $domain instanceof DomainBase) { |
|
53 | + throw new DomainException( |
|
54 | + sprintf( |
|
55 | + esc_html__( |
|
56 | + 'The requested Domain class "%1$s" could not be loaded.', |
|
57 | + 'event_espresso' |
|
58 | + ), |
|
59 | + $domain_fqcn |
|
60 | + ) |
|
61 | + ); |
|
62 | + } |
|
63 | + return $domain; |
|
64 | + } |
|
65 | 65 | |
66 | 66 | } |
67 | 67 |