@@ -5,22 +5,22 @@ |
||
5 | 5 | */ |
6 | 6 | interface EEI_Address_Formatter |
7 | 7 | { |
8 | - /** |
|
9 | - * @param string $address |
|
10 | - * @param string $address2 |
|
11 | - * @param string $city |
|
12 | - * @param string $state |
|
13 | - * @param string $zip |
|
14 | - * @param string $country |
|
15 | - * @param string $CNT_ISO |
|
16 | - */ |
|
17 | - public function format( |
|
18 | - string $address, |
|
19 | - string $address2, |
|
20 | - string $city, |
|
21 | - string $state, |
|
22 | - string $zip, |
|
23 | - string $country, |
|
24 | - string $CNT_ISO |
|
25 | - ): ?string; |
|
8 | + /** |
|
9 | + * @param string $address |
|
10 | + * @param string $address2 |
|
11 | + * @param string $city |
|
12 | + * @param string $state |
|
13 | + * @param string $zip |
|
14 | + * @param string $country |
|
15 | + * @param string $CNT_ISO |
|
16 | + */ |
|
17 | + public function format( |
|
18 | + string $address, |
|
19 | + string $address2, |
|
20 | + string $city, |
|
21 | + string $state, |
|
22 | + string $zip, |
|
23 | + string $country, |
|
24 | + string $CNT_ISO |
|
25 | + ): ?string; |
|
26 | 26 | } |
@@ -17,151 +17,151 @@ |
||
17 | 17 | */ |
18 | 18 | class FqcnLocator extends Locator |
19 | 19 | { |
20 | - /** |
|
21 | - * @var array $FQCNs |
|
22 | - */ |
|
23 | - protected $FQCNs = []; |
|
24 | - |
|
25 | - /** |
|
26 | - * @var array $namespaces |
|
27 | - */ |
|
28 | - protected $namespaces = []; |
|
29 | - |
|
30 | - |
|
31 | - /** |
|
32 | - * @param string|null $namespace |
|
33 | - * @param string|null $namespace_base_dir |
|
34 | - */ |
|
35 | - protected function setNamespace(?string $namespace, ?string $namespace_base_dir) |
|
36 | - { |
|
37 | - if (! is_string($namespace)) { |
|
38 | - throw new InvalidDataTypeException('$namespace', $namespace, 'string'); |
|
39 | - } |
|
40 | - if (! is_string($namespace_base_dir)) { |
|
41 | - throw new InvalidDataTypeException('$namespace_base_dir', $namespace_base_dir, 'string'); |
|
42 | - } |
|
43 | - $this->namespaces[ $namespace ] = $namespace_base_dir; |
|
44 | - } |
|
45 | - |
|
46 | - |
|
47 | - /** |
|
48 | - * @return array |
|
49 | - */ |
|
50 | - public function getFQCNs(): array |
|
51 | - { |
|
52 | - return $this->FQCNs; |
|
53 | - } |
|
54 | - |
|
55 | - |
|
56 | - /** |
|
57 | - * @return int |
|
58 | - */ |
|
59 | - public function count(): int |
|
60 | - { |
|
61 | - return count($this->FQCNs); |
|
62 | - } |
|
63 | - |
|
64 | - |
|
65 | - /** |
|
66 | - * given a valid namespace, will find all files that match the provided mask |
|
67 | - * |
|
68 | - * @param string|array $namespaces |
|
69 | - * @return array |
|
70 | - * @throws InvalidClassException |
|
71 | - * @throws InvalidDataTypeException |
|
72 | - */ |
|
73 | - public function locate($namespaces): array |
|
74 | - { |
|
75 | - if (! (is_string($namespaces) || is_array($namespaces))) { |
|
76 | - throw new InvalidDataTypeException('$namespaces', $namespaces, 'string or array'); |
|
77 | - } |
|
78 | - foreach ((array) $namespaces as $namespace) { |
|
79 | - foreach ($this->findFQCNsByNamespace($namespace) as $key => $file) { |
|
80 | - $this->FQCNs[ $key ] = $file; |
|
81 | - } |
|
82 | - } |
|
83 | - $this->FQCNs = array_unique($this->FQCNs, SORT_STRING); |
|
84 | - return $this->FQCNs; |
|
85 | - } |
|
86 | - |
|
87 | - |
|
88 | - /** |
|
89 | - * given a partial namespace, will find all files in that folder |
|
90 | - * ** PLZ NOTE ** |
|
91 | - * This assumes that all files within the specified folder should be loaded |
|
92 | - * |
|
93 | - * @param string $partial_namespace |
|
94 | - * @return array |
|
95 | - * @throws InvalidClassException |
|
96 | - * @throws InvalidDataTypeException |
|
97 | - */ |
|
98 | - protected function findFQCNsByNamespace(string $partial_namespace): array |
|
99 | - { |
|
100 | - $iterator = new FilesystemIterator( |
|
101 | - $this->getDirectoryFromPartialNamespace($partial_namespace) |
|
102 | - ); |
|
103 | - $iterator->setFlags(FilesystemIterator::CURRENT_AS_FILEINFO); |
|
104 | - $iterator->setFlags(FilesystemIterator::UNIX_PATHS); |
|
105 | - if (iterator_count($iterator) === 0) { |
|
106 | - return []; |
|
107 | - } |
|
108 | - $FQCNs = []; |
|
109 | - foreach ($iterator as $file) { |
|
110 | - if ($file->isFile() && $file->getExtension() === 'php') { |
|
111 | - $file_name = $file->getPath() . '/' . $file->getBasename('.php'); |
|
112 | - foreach ($this->namespaces as $namespace => $base_dir) { |
|
113 | - $namespace .= Psr4Autoloader::NS; |
|
114 | - if (strpos($file_name, $base_dir) === 0) { |
|
115 | - $FQCNs[] = Psr4Autoloader::NS . str_replace( |
|
116 | - [$base_dir, '/'], |
|
117 | - [$namespace, Psr4Autoloader::NS], |
|
118 | - $file_name |
|
119 | - ); |
|
120 | - } |
|
121 | - } |
|
122 | - } |
|
123 | - } |
|
124 | - return array_unique($FQCNs, SORT_STRING); |
|
125 | - } |
|
126 | - |
|
127 | - |
|
128 | - /** |
|
129 | - * getDirectoryFromPartialNamespace |
|
130 | - * |
|
131 | - * @param string $partial_namespace almost fully qualified class name ? |
|
132 | - * @return string |
|
133 | - * @throws InvalidDataTypeException |
|
134 | - * @throws InvalidClassException |
|
135 | - */ |
|
136 | - protected function getDirectoryFromPartialNamespace(string $partial_namespace): string |
|
137 | - { |
|
138 | - if (empty($partial_namespace)) { |
|
139 | - throw new InvalidClassException($partial_namespace); |
|
140 | - } |
|
141 | - // load our PSR-4 Autoloader so we can get the list of registered namespaces from it |
|
142 | - $psr4_loader = EE_Psr4AutoloaderInit::psr4_loader(); |
|
143 | - // breakup the incoming namespace into segments so we can loop thru them |
|
144 | - $namespace_segments = explode(Psr4Autoloader::NS, trim($partial_namespace, Psr4Autoloader::NS)); |
|
145 | - // we're only interested in the Vendor and secondary base, so pull those from the array |
|
146 | - $vendor_base = array_slice($namespace_segments, 0, 2); |
|
147 | - $namespace = $prefix = null; |
|
148 | - while (! empty($vendor_base)) { |
|
149 | - $namespace = implode(Psr4Autoloader::NS, $vendor_base); |
|
150 | - // check if there's a base directory registered for that namespace |
|
151 | - $prefix = $psr4_loader->prefixes($namespace . Psr4Autoloader::NS); |
|
152 | - if (! empty($prefix) && ! empty($prefix[0])) { |
|
153 | - // found one! |
|
154 | - break; |
|
155 | - } |
|
156 | - // remove base and try vendor only portion of namespace |
|
157 | - array_pop($vendor_base); |
|
158 | - } |
|
159 | - // nope? then the incoming namespace is invalid |
|
160 | - if (empty($prefix) || empty($prefix[0])) { |
|
161 | - throw new InvalidClassException($partial_namespace); |
|
162 | - } |
|
163 | - $this->setNamespace($namespace, $prefix[0]); |
|
164 | - // but if it's good, add that base directory to the rest of the path, and return it |
|
165 | - return $prefix[0] . implode('/', array_diff($namespace_segments, $vendor_base)) . '/'; |
|
166 | - } |
|
20 | + /** |
|
21 | + * @var array $FQCNs |
|
22 | + */ |
|
23 | + protected $FQCNs = []; |
|
24 | + |
|
25 | + /** |
|
26 | + * @var array $namespaces |
|
27 | + */ |
|
28 | + protected $namespaces = []; |
|
29 | + |
|
30 | + |
|
31 | + /** |
|
32 | + * @param string|null $namespace |
|
33 | + * @param string|null $namespace_base_dir |
|
34 | + */ |
|
35 | + protected function setNamespace(?string $namespace, ?string $namespace_base_dir) |
|
36 | + { |
|
37 | + if (! is_string($namespace)) { |
|
38 | + throw new InvalidDataTypeException('$namespace', $namespace, 'string'); |
|
39 | + } |
|
40 | + if (! is_string($namespace_base_dir)) { |
|
41 | + throw new InvalidDataTypeException('$namespace_base_dir', $namespace_base_dir, 'string'); |
|
42 | + } |
|
43 | + $this->namespaces[ $namespace ] = $namespace_base_dir; |
|
44 | + } |
|
45 | + |
|
46 | + |
|
47 | + /** |
|
48 | + * @return array |
|
49 | + */ |
|
50 | + public function getFQCNs(): array |
|
51 | + { |
|
52 | + return $this->FQCNs; |
|
53 | + } |
|
54 | + |
|
55 | + |
|
56 | + /** |
|
57 | + * @return int |
|
58 | + */ |
|
59 | + public function count(): int |
|
60 | + { |
|
61 | + return count($this->FQCNs); |
|
62 | + } |
|
63 | + |
|
64 | + |
|
65 | + /** |
|
66 | + * given a valid namespace, will find all files that match the provided mask |
|
67 | + * |
|
68 | + * @param string|array $namespaces |
|
69 | + * @return array |
|
70 | + * @throws InvalidClassException |
|
71 | + * @throws InvalidDataTypeException |
|
72 | + */ |
|
73 | + public function locate($namespaces): array |
|
74 | + { |
|
75 | + if (! (is_string($namespaces) || is_array($namespaces))) { |
|
76 | + throw new InvalidDataTypeException('$namespaces', $namespaces, 'string or array'); |
|
77 | + } |
|
78 | + foreach ((array) $namespaces as $namespace) { |
|
79 | + foreach ($this->findFQCNsByNamespace($namespace) as $key => $file) { |
|
80 | + $this->FQCNs[ $key ] = $file; |
|
81 | + } |
|
82 | + } |
|
83 | + $this->FQCNs = array_unique($this->FQCNs, SORT_STRING); |
|
84 | + return $this->FQCNs; |
|
85 | + } |
|
86 | + |
|
87 | + |
|
88 | + /** |
|
89 | + * given a partial namespace, will find all files in that folder |
|
90 | + * ** PLZ NOTE ** |
|
91 | + * This assumes that all files within the specified folder should be loaded |
|
92 | + * |
|
93 | + * @param string $partial_namespace |
|
94 | + * @return array |
|
95 | + * @throws InvalidClassException |
|
96 | + * @throws InvalidDataTypeException |
|
97 | + */ |
|
98 | + protected function findFQCNsByNamespace(string $partial_namespace): array |
|
99 | + { |
|
100 | + $iterator = new FilesystemIterator( |
|
101 | + $this->getDirectoryFromPartialNamespace($partial_namespace) |
|
102 | + ); |
|
103 | + $iterator->setFlags(FilesystemIterator::CURRENT_AS_FILEINFO); |
|
104 | + $iterator->setFlags(FilesystemIterator::UNIX_PATHS); |
|
105 | + if (iterator_count($iterator) === 0) { |
|
106 | + return []; |
|
107 | + } |
|
108 | + $FQCNs = []; |
|
109 | + foreach ($iterator as $file) { |
|
110 | + if ($file->isFile() && $file->getExtension() === 'php') { |
|
111 | + $file_name = $file->getPath() . '/' . $file->getBasename('.php'); |
|
112 | + foreach ($this->namespaces as $namespace => $base_dir) { |
|
113 | + $namespace .= Psr4Autoloader::NS; |
|
114 | + if (strpos($file_name, $base_dir) === 0) { |
|
115 | + $FQCNs[] = Psr4Autoloader::NS . str_replace( |
|
116 | + [$base_dir, '/'], |
|
117 | + [$namespace, Psr4Autoloader::NS], |
|
118 | + $file_name |
|
119 | + ); |
|
120 | + } |
|
121 | + } |
|
122 | + } |
|
123 | + } |
|
124 | + return array_unique($FQCNs, SORT_STRING); |
|
125 | + } |
|
126 | + |
|
127 | + |
|
128 | + /** |
|
129 | + * getDirectoryFromPartialNamespace |
|
130 | + * |
|
131 | + * @param string $partial_namespace almost fully qualified class name ? |
|
132 | + * @return string |
|
133 | + * @throws InvalidDataTypeException |
|
134 | + * @throws InvalidClassException |
|
135 | + */ |
|
136 | + protected function getDirectoryFromPartialNamespace(string $partial_namespace): string |
|
137 | + { |
|
138 | + if (empty($partial_namespace)) { |
|
139 | + throw new InvalidClassException($partial_namespace); |
|
140 | + } |
|
141 | + // load our PSR-4 Autoloader so we can get the list of registered namespaces from it |
|
142 | + $psr4_loader = EE_Psr4AutoloaderInit::psr4_loader(); |
|
143 | + // breakup the incoming namespace into segments so we can loop thru them |
|
144 | + $namespace_segments = explode(Psr4Autoloader::NS, trim($partial_namespace, Psr4Autoloader::NS)); |
|
145 | + // we're only interested in the Vendor and secondary base, so pull those from the array |
|
146 | + $vendor_base = array_slice($namespace_segments, 0, 2); |
|
147 | + $namespace = $prefix = null; |
|
148 | + while (! empty($vendor_base)) { |
|
149 | + $namespace = implode(Psr4Autoloader::NS, $vendor_base); |
|
150 | + // check if there's a base directory registered for that namespace |
|
151 | + $prefix = $psr4_loader->prefixes($namespace . Psr4Autoloader::NS); |
|
152 | + if (! empty($prefix) && ! empty($prefix[0])) { |
|
153 | + // found one! |
|
154 | + break; |
|
155 | + } |
|
156 | + // remove base and try vendor only portion of namespace |
|
157 | + array_pop($vendor_base); |
|
158 | + } |
|
159 | + // nope? then the incoming namespace is invalid |
|
160 | + if (empty($prefix) || empty($prefix[0])) { |
|
161 | + throw new InvalidClassException($partial_namespace); |
|
162 | + } |
|
163 | + $this->setNamespace($namespace, $prefix[0]); |
|
164 | + // but if it's good, add that base directory to the rest of the path, and return it |
|
165 | + return $prefix[0] . implode('/', array_diff($namespace_segments, $vendor_base)) . '/'; |
|
166 | + } |
|
167 | 167 | } |
@@ -34,13 +34,13 @@ discard block |
||
34 | 34 | */ |
35 | 35 | protected function setNamespace(?string $namespace, ?string $namespace_base_dir) |
36 | 36 | { |
37 | - if (! is_string($namespace)) { |
|
37 | + if ( ! is_string($namespace)) { |
|
38 | 38 | throw new InvalidDataTypeException('$namespace', $namespace, 'string'); |
39 | 39 | } |
40 | - if (! is_string($namespace_base_dir)) { |
|
40 | + if ( ! is_string($namespace_base_dir)) { |
|
41 | 41 | throw new InvalidDataTypeException('$namespace_base_dir', $namespace_base_dir, 'string'); |
42 | 42 | } |
43 | - $this->namespaces[ $namespace ] = $namespace_base_dir; |
|
43 | + $this->namespaces[$namespace] = $namespace_base_dir; |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | |
@@ -72,12 +72,12 @@ discard block |
||
72 | 72 | */ |
73 | 73 | public function locate($namespaces): array |
74 | 74 | { |
75 | - if (! (is_string($namespaces) || is_array($namespaces))) { |
|
75 | + if ( ! (is_string($namespaces) || is_array($namespaces))) { |
|
76 | 76 | throw new InvalidDataTypeException('$namespaces', $namespaces, 'string or array'); |
77 | 77 | } |
78 | 78 | foreach ((array) $namespaces as $namespace) { |
79 | 79 | foreach ($this->findFQCNsByNamespace($namespace) as $key => $file) { |
80 | - $this->FQCNs[ $key ] = $file; |
|
80 | + $this->FQCNs[$key] = $file; |
|
81 | 81 | } |
82 | 82 | } |
83 | 83 | $this->FQCNs = array_unique($this->FQCNs, SORT_STRING); |
@@ -108,11 +108,11 @@ discard block |
||
108 | 108 | $FQCNs = []; |
109 | 109 | foreach ($iterator as $file) { |
110 | 110 | if ($file->isFile() && $file->getExtension() === 'php') { |
111 | - $file_name = $file->getPath() . '/' . $file->getBasename('.php'); |
|
111 | + $file_name = $file->getPath().'/'.$file->getBasename('.php'); |
|
112 | 112 | foreach ($this->namespaces as $namespace => $base_dir) { |
113 | 113 | $namespace .= Psr4Autoloader::NS; |
114 | 114 | if (strpos($file_name, $base_dir) === 0) { |
115 | - $FQCNs[] = Psr4Autoloader::NS . str_replace( |
|
115 | + $FQCNs[] = Psr4Autoloader::NS.str_replace( |
|
116 | 116 | [$base_dir, '/'], |
117 | 117 | [$namespace, Psr4Autoloader::NS], |
118 | 118 | $file_name |
@@ -145,11 +145,11 @@ discard block |
||
145 | 145 | // we're only interested in the Vendor and secondary base, so pull those from the array |
146 | 146 | $vendor_base = array_slice($namespace_segments, 0, 2); |
147 | 147 | $namespace = $prefix = null; |
148 | - while (! empty($vendor_base)) { |
|
148 | + while ( ! empty($vendor_base)) { |
|
149 | 149 | $namespace = implode(Psr4Autoloader::NS, $vendor_base); |
150 | 150 | // check if there's a base directory registered for that namespace |
151 | - $prefix = $psr4_loader->prefixes($namespace . Psr4Autoloader::NS); |
|
152 | - if (! empty($prefix) && ! empty($prefix[0])) { |
|
151 | + $prefix = $psr4_loader->prefixes($namespace.Psr4Autoloader::NS); |
|
152 | + if ( ! empty($prefix) && ! empty($prefix[0])) { |
|
153 | 153 | // found one! |
154 | 154 | break; |
155 | 155 | } |
@@ -162,6 +162,6 @@ discard block |
||
162 | 162 | } |
163 | 163 | $this->setNamespace($namespace, $prefix[0]); |
164 | 164 | // but if it's good, add that base directory to the rest of the path, and return it |
165 | - return $prefix[0] . implode('/', array_diff($namespace_segments, $vendor_base)) . '/'; |
|
165 | + return $prefix[0].implode('/', array_diff($namespace_segments, $vendor_base)).'/'; |
|
166 | 166 | } |
167 | 167 | } |
@@ -15,125 +15,125 @@ |
||
15 | 15 | */ |
16 | 16 | class Response implements InterminableInterface, ResponseInterface, ReservedInstanceInterface |
17 | 17 | { |
18 | - /** |
|
19 | - * @var array $notice |
|
20 | - */ |
|
21 | - protected $notice = []; |
|
22 | - |
|
23 | - /** |
|
24 | - * rendered output to be returned to WP |
|
25 | - * |
|
26 | - * @var array |
|
27 | - */ |
|
28 | - protected $output = []; |
|
29 | - |
|
30 | - /** |
|
31 | - * @var bool |
|
32 | - */ |
|
33 | - protected $request_terminated = false; |
|
34 | - |
|
35 | - /** |
|
36 | - * @var bool $deactivate_plugin |
|
37 | - */ |
|
38 | - protected $deactivate_plugin = false; |
|
39 | - |
|
40 | - |
|
41 | - /** |
|
42 | - * EE_Response constructor. |
|
43 | - */ |
|
44 | - public function __construct() |
|
45 | - { |
|
46 | - $this->terminateRequest(false); |
|
47 | - } |
|
48 | - |
|
49 | - |
|
50 | - /** |
|
51 | - * @param $key |
|
52 | - * @param $value |
|
53 | - * @return void |
|
54 | - */ |
|
55 | - public function setNotice($key, $value) |
|
56 | - { |
|
57 | - $this->notice[ $key ] = $value; |
|
58 | - } |
|
59 | - |
|
60 | - |
|
61 | - /** |
|
62 | - * @param $key |
|
63 | - * @return mixed |
|
64 | - */ |
|
65 | - public function getNotice($key) |
|
66 | - { |
|
67 | - return $this->notice[ $key ] ?? null; |
|
68 | - } |
|
69 | - |
|
70 | - |
|
71 | - /** |
|
72 | - * @return array |
|
73 | - */ |
|
74 | - public function getNotices(): array |
|
75 | - { |
|
76 | - return $this->notice; |
|
77 | - } |
|
78 | - |
|
79 | - |
|
80 | - /** |
|
81 | - * @param string $string |
|
82 | - * @param bool $append |
|
83 | - */ |
|
84 | - public function addOutput($string, $append = true) |
|
85 | - { |
|
86 | - if ($append) { |
|
87 | - $this->output[] = $string; |
|
88 | - return; |
|
89 | - } |
|
90 | - array_unshift($this->output, $string); |
|
91 | - } |
|
92 | - |
|
93 | - |
|
94 | - /** |
|
95 | - * @param bool $as_string |
|
96 | - * @param string $separator |
|
97 | - * @return array|string |
|
98 | - */ |
|
99 | - public function getOutput($as_string = true, $separator = PHP_EOL) |
|
100 | - { |
|
101 | - return $as_string ? implode($separator, $this->output) : $this->output ; |
|
102 | - } |
|
103 | - |
|
104 | - |
|
105 | - /** |
|
106 | - * @return bool |
|
107 | - */ |
|
108 | - public function requestTerminated(): bool |
|
109 | - { |
|
110 | - return $this->request_terminated; |
|
111 | - } |
|
112 | - |
|
113 | - |
|
114 | - /** |
|
115 | - * @param bool $request_terminated |
|
116 | - */ |
|
117 | - public function terminateRequest($request_terminated = true) |
|
118 | - { |
|
119 | - $this->request_terminated = filter_var($request_terminated, FILTER_VALIDATE_BOOLEAN); |
|
120 | - } |
|
121 | - |
|
122 | - |
|
123 | - /** |
|
124 | - * @return bool |
|
125 | - */ |
|
126 | - public function pluginDeactivated(): bool |
|
127 | - { |
|
128 | - return $this->deactivate_plugin; |
|
129 | - } |
|
130 | - |
|
131 | - |
|
132 | - /** |
|
133 | - * sets $deactivate_plugin to true |
|
134 | - */ |
|
135 | - public function deactivatePlugin() |
|
136 | - { |
|
137 | - $this->deactivate_plugin = true; |
|
138 | - } |
|
18 | + /** |
|
19 | + * @var array $notice |
|
20 | + */ |
|
21 | + protected $notice = []; |
|
22 | + |
|
23 | + /** |
|
24 | + * rendered output to be returned to WP |
|
25 | + * |
|
26 | + * @var array |
|
27 | + */ |
|
28 | + protected $output = []; |
|
29 | + |
|
30 | + /** |
|
31 | + * @var bool |
|
32 | + */ |
|
33 | + protected $request_terminated = false; |
|
34 | + |
|
35 | + /** |
|
36 | + * @var bool $deactivate_plugin |
|
37 | + */ |
|
38 | + protected $deactivate_plugin = false; |
|
39 | + |
|
40 | + |
|
41 | + /** |
|
42 | + * EE_Response constructor. |
|
43 | + */ |
|
44 | + public function __construct() |
|
45 | + { |
|
46 | + $this->terminateRequest(false); |
|
47 | + } |
|
48 | + |
|
49 | + |
|
50 | + /** |
|
51 | + * @param $key |
|
52 | + * @param $value |
|
53 | + * @return void |
|
54 | + */ |
|
55 | + public function setNotice($key, $value) |
|
56 | + { |
|
57 | + $this->notice[ $key ] = $value; |
|
58 | + } |
|
59 | + |
|
60 | + |
|
61 | + /** |
|
62 | + * @param $key |
|
63 | + * @return mixed |
|
64 | + */ |
|
65 | + public function getNotice($key) |
|
66 | + { |
|
67 | + return $this->notice[ $key ] ?? null; |
|
68 | + } |
|
69 | + |
|
70 | + |
|
71 | + /** |
|
72 | + * @return array |
|
73 | + */ |
|
74 | + public function getNotices(): array |
|
75 | + { |
|
76 | + return $this->notice; |
|
77 | + } |
|
78 | + |
|
79 | + |
|
80 | + /** |
|
81 | + * @param string $string |
|
82 | + * @param bool $append |
|
83 | + */ |
|
84 | + public function addOutput($string, $append = true) |
|
85 | + { |
|
86 | + if ($append) { |
|
87 | + $this->output[] = $string; |
|
88 | + return; |
|
89 | + } |
|
90 | + array_unshift($this->output, $string); |
|
91 | + } |
|
92 | + |
|
93 | + |
|
94 | + /** |
|
95 | + * @param bool $as_string |
|
96 | + * @param string $separator |
|
97 | + * @return array|string |
|
98 | + */ |
|
99 | + public function getOutput($as_string = true, $separator = PHP_EOL) |
|
100 | + { |
|
101 | + return $as_string ? implode($separator, $this->output) : $this->output ; |
|
102 | + } |
|
103 | + |
|
104 | + |
|
105 | + /** |
|
106 | + * @return bool |
|
107 | + */ |
|
108 | + public function requestTerminated(): bool |
|
109 | + { |
|
110 | + return $this->request_terminated; |
|
111 | + } |
|
112 | + |
|
113 | + |
|
114 | + /** |
|
115 | + * @param bool $request_terminated |
|
116 | + */ |
|
117 | + public function terminateRequest($request_terminated = true) |
|
118 | + { |
|
119 | + $this->request_terminated = filter_var($request_terminated, FILTER_VALIDATE_BOOLEAN); |
|
120 | + } |
|
121 | + |
|
122 | + |
|
123 | + /** |
|
124 | + * @return bool |
|
125 | + */ |
|
126 | + public function pluginDeactivated(): bool |
|
127 | + { |
|
128 | + return $this->deactivate_plugin; |
|
129 | + } |
|
130 | + |
|
131 | + |
|
132 | + /** |
|
133 | + * sets $deactivate_plugin to true |
|
134 | + */ |
|
135 | + public function deactivatePlugin() |
|
136 | + { |
|
137 | + $this->deactivate_plugin = true; |
|
138 | + } |
|
139 | 139 | } |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | */ |
55 | 55 | public function setNotice($key, $value) |
56 | 56 | { |
57 | - $this->notice[ $key ] = $value; |
|
57 | + $this->notice[$key] = $value; |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | */ |
65 | 65 | public function getNotice($key) |
66 | 66 | { |
67 | - return $this->notice[ $key ] ?? null; |
|
67 | + return $this->notice[$key] ?? null; |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | */ |
99 | 99 | public function getOutput($as_string = true, $separator = PHP_EOL) |
100 | 100 | { |
101 | - return $as_string ? implode($separator, $this->output) : $this->output ; |
|
101 | + return $as_string ? implode($separator, $this->output) : $this->output; |
|
102 | 102 | } |
103 | 103 | |
104 | 104 |
@@ -14,285 +14,285 @@ |
||
14 | 14 | */ |
15 | 15 | class AllowedTags implements InterminableInterface |
16 | 16 | { |
17 | - /** |
|
18 | - * @var array[] |
|
19 | - */ |
|
20 | - private static $attributes = [ |
|
21 | - 'accept-charset' => 1, |
|
22 | - 'action' => 1, |
|
23 | - 'alt' => 1, |
|
24 | - 'allow' => 1, |
|
25 | - 'allowfullscreen' => 1, |
|
26 | - 'align' => 1, |
|
27 | - 'aria-*' => 1, |
|
28 | - 'autocomplete' => 1, |
|
29 | - 'bgcolor' => 1, |
|
30 | - 'border' => 1, |
|
31 | - 'cellpadding' => 1, |
|
32 | - 'cellspacing' => 1, |
|
33 | - 'checked' => 1, |
|
34 | - 'class' => 1, |
|
35 | - 'cols' => 1, |
|
36 | - 'content' => 1, |
|
37 | - 'data-*' => 1, |
|
38 | - 'dir' => 1, |
|
39 | - 'disabled' => 1, |
|
40 | - 'enctype' => 1, |
|
41 | - 'extension' => 1, |
|
42 | - 'for' => 1, |
|
43 | - 'frameborder' => 1, |
|
44 | - 'height' => 1, |
|
45 | - 'href' => 1, |
|
46 | - 'id' => 1, |
|
47 | - 'itemprop' => 1, |
|
48 | - 'itemscope' => 1, |
|
49 | - 'itemtype' => 1, |
|
50 | - 'label' => 1, |
|
51 | - 'lang' => 1, |
|
52 | - 'leftmargin' => 1, |
|
53 | - 'marginheight' => 1, |
|
54 | - 'marginwidth' => 1, |
|
55 | - 'max' => 1, |
|
56 | - 'maxlength' => 1, |
|
57 | - 'media' => 1, |
|
58 | - 'method' => 1, |
|
59 | - 'min' => 1, |
|
60 | - 'multiple' => 1, |
|
61 | - 'name' => 1, |
|
62 | - 'novalidate' => 1, |
|
63 | - 'placeholder' => 1, |
|
64 | - 'property' => 1, |
|
65 | - 'readonly' => 1, |
|
66 | - 'rel' => 1, |
|
67 | - 'required' => 1, |
|
68 | - 'rows' => 1, |
|
69 | - 'selected' => 1, |
|
70 | - 'src' => 1, |
|
71 | - 'size' => 1, |
|
72 | - 'style' => 1, |
|
73 | - 'step' => 1, |
|
74 | - 'tabindex' => 1, |
|
75 | - 'target' => 1, |
|
76 | - 'title' => 1, |
|
77 | - 'topmargin' => 1, |
|
78 | - 'type' => 1, |
|
79 | - 'value' => 1, |
|
80 | - 'width' => 1, |
|
81 | - ]; |
|
82 | - |
|
83 | - |
|
84 | - /** |
|
85 | - * @var array |
|
86 | - */ |
|
87 | - private static $tags = [ |
|
88 | - 'a', |
|
89 | - 'abbr', |
|
90 | - 'b', |
|
91 | - 'br', |
|
92 | - 'code', |
|
93 | - 'div', |
|
94 | - 'em', |
|
95 | - 'h1', |
|
96 | - 'h2', |
|
97 | - 'h3', |
|
98 | - 'h4', |
|
99 | - 'h5', |
|
100 | - 'h6', |
|
101 | - 'hr', |
|
102 | - 'i', |
|
103 | - 'img', |
|
104 | - 'li', |
|
105 | - 'ol', |
|
106 | - 'p', |
|
107 | - 'pre', |
|
108 | - 'small', |
|
109 | - 'span', |
|
110 | - 'strong', |
|
111 | - 'table', |
|
112 | - 'td', |
|
113 | - 'tr', |
|
114 | - 'ul', |
|
115 | - ]; |
|
116 | - |
|
117 | - |
|
118 | - /** |
|
119 | - * @var array |
|
120 | - */ |
|
121 | - private static $allowed_tags; |
|
122 | - |
|
123 | - |
|
124 | - /** |
|
125 | - * @var array |
|
126 | - */ |
|
127 | - private static $allowed_with_embed_tags; |
|
128 | - |
|
129 | - |
|
130 | - /** |
|
131 | - * @var array |
|
132 | - */ |
|
133 | - private static $allowed_with_form_tags; |
|
134 | - |
|
135 | - |
|
136 | - /** |
|
137 | - * @var array |
|
138 | - */ |
|
139 | - private static $allowed_with_script_and_style_tags; |
|
140 | - |
|
141 | - /** |
|
142 | - * @var array |
|
143 | - */ |
|
144 | - private static $allowed_with_full_tags; |
|
145 | - |
|
146 | - |
|
147 | - /** |
|
148 | - * merges additional tags and attributes into the WP post tags |
|
149 | - */ |
|
150 | - private static function initializeAllowedTags() |
|
151 | - { |
|
152 | - $allowed_post_tags = wp_kses_allowed_html('post'); |
|
153 | - $allowed_tags = []; |
|
154 | - foreach (AllowedTags::$tags as $tag) { |
|
155 | - $allowed_tags[ $tag ] = AllowedTags::$attributes; |
|
156 | - } |
|
157 | - AllowedTags::$allowed_tags = array_merge_recursive($allowed_post_tags, $allowed_tags); |
|
158 | - } |
|
159 | - |
|
160 | - |
|
161 | - /** |
|
162 | - * merges embed tags and attributes into the EE all tags |
|
163 | - */ |
|
164 | - private static function initializeWithEmbedTags() |
|
165 | - { |
|
166 | - $all_tags = AllowedTags::getAllowedTags(); |
|
167 | - $embed_tags = [ |
|
168 | - 'iframe' => AllowedTags::$attributes |
|
169 | - ]; |
|
170 | - AllowedTags::$allowed_with_embed_tags = array_merge_recursive($all_tags, $embed_tags); |
|
171 | - } |
|
172 | - |
|
173 | - |
|
174 | - /** |
|
175 | - * merges form tags and attributes into the EE all tags |
|
176 | - */ |
|
177 | - private static function initializeWithFormTags() |
|
178 | - { |
|
179 | - $all_tags = AllowedTags::getAllowedTags(); |
|
180 | - $form_tags = [ |
|
181 | - 'form' => AllowedTags::$attributes, |
|
182 | - 'label' => AllowedTags::$attributes, |
|
183 | - 'input' => AllowedTags::$attributes, |
|
184 | - 'select' => AllowedTags::$attributes, |
|
185 | - 'option' => AllowedTags::$attributes, |
|
186 | - 'optgroup' => AllowedTags::$attributes, |
|
187 | - 'textarea' => AllowedTags::$attributes, |
|
188 | - 'button' => AllowedTags::$attributes, |
|
189 | - 'fieldset' => AllowedTags::$attributes, |
|
190 | - 'output' => AllowedTags::$attributes, |
|
191 | - ]; |
|
192 | - AllowedTags::$allowed_with_form_tags = array_merge_recursive($all_tags, $form_tags); |
|
193 | - } |
|
194 | - |
|
195 | - |
|
196 | - /** |
|
197 | - * merges form script and style tags and attributes into the EE all tags |
|
198 | - */ |
|
199 | - private static function initializeWithScriptAndStyleTags() |
|
200 | - { |
|
201 | - $all_tags = AllowedTags::getAllowedTags(); |
|
202 | - $script_and_style_tags = [ |
|
203 | - 'script' => AllowedTags::$attributes, |
|
204 | - 'style' => AllowedTags::$attributes, |
|
205 | - 'link' => AllowedTags::$attributes, |
|
206 | - 'noscript' => AllowedTags::$attributes, |
|
207 | - ]; |
|
208 | - AllowedTags::$allowed_with_script_and_style_tags = array_merge_recursive($all_tags, $script_and_style_tags); |
|
209 | - } |
|
210 | - |
|
211 | - /** |
|
212 | - * merges all head and body tags and attributes into the EE all tags |
|
213 | - */ |
|
214 | - private static function initializeWithFullTags() |
|
215 | - { |
|
216 | - $all_tags = AllowedTags::getAllowedTags(); |
|
217 | - $full_tags = [ |
|
218 | - 'script' => AllowedTags::$attributes, |
|
219 | - 'style' => AllowedTags::$attributes, |
|
220 | - 'link' => AllowedTags::$attributes, |
|
221 | - 'title' => AllowedTags::$attributes, |
|
222 | - 'meta' => AllowedTags::$attributes, |
|
223 | - 'iframe' => AllowedTags::$attributes, |
|
224 | - 'form' => AllowedTags::$attributes, |
|
225 | - 'label' => AllowedTags::$attributes, |
|
226 | - 'input' => AllowedTags::$attributes, |
|
227 | - 'select' => AllowedTags::$attributes, |
|
228 | - 'option' => AllowedTags::$attributes, |
|
229 | - 'optgroup' => AllowedTags::$attributes, |
|
230 | - 'textarea' => AllowedTags::$attributes, |
|
231 | - 'button' => AllowedTags::$attributes, |
|
232 | - 'fieldset' => AllowedTags::$attributes, |
|
233 | - 'output' => AllowedTags::$attributes, |
|
234 | - 'noscript' => AllowedTags::$attributes, |
|
235 | - ]; |
|
236 | - AllowedTags::$allowed_with_full_tags = array_merge_recursive($all_tags, $full_tags); |
|
237 | - } |
|
238 | - |
|
239 | - |
|
240 | - /** |
|
241 | - * @return array[] |
|
242 | - */ |
|
243 | - public static function getAllowedTags() |
|
244 | - { |
|
245 | - if (empty(AllowedTags::$allowed_tags)) { |
|
246 | - AllowedTags::initializeAllowedTags(); |
|
247 | - } |
|
248 | - return AllowedTags::$allowed_tags; |
|
249 | - } |
|
250 | - |
|
251 | - |
|
252 | - /** |
|
253 | - * @return array[] |
|
254 | - */ |
|
255 | - public static function getWithEmbedTags() |
|
256 | - { |
|
257 | - if (empty(AllowedTags::$allowed_with_embed_tags)) { |
|
258 | - AllowedTags::initializeWithEmbedTags(); |
|
259 | - } |
|
260 | - return AllowedTags::$allowed_with_embed_tags; |
|
261 | - } |
|
262 | - |
|
263 | - |
|
264 | - /** |
|
265 | - * @return array[] |
|
266 | - */ |
|
267 | - public static function getWithFormTags() |
|
268 | - { |
|
269 | - if (empty(AllowedTags::$allowed_with_form_tags)) { |
|
270 | - AllowedTags::initializeWithFormTags(); |
|
271 | - } |
|
272 | - return AllowedTags::$allowed_with_form_tags; |
|
273 | - } |
|
274 | - |
|
275 | - |
|
276 | - /** |
|
277 | - * @return array[] |
|
278 | - */ |
|
279 | - public static function getWithScriptAndStyleTags() |
|
280 | - { |
|
281 | - if (empty(AllowedTags::$allowed_with_script_and_style_tags)) { |
|
282 | - AllowedTags::initializeWithScriptAndStyleTags(); |
|
283 | - } |
|
284 | - return AllowedTags::$allowed_with_script_and_style_tags; |
|
285 | - } |
|
286 | - |
|
287 | - |
|
288 | - /** |
|
289 | - * @return array[] |
|
290 | - */ |
|
291 | - public static function getWithFullTags() |
|
292 | - { |
|
293 | - if (empty(AllowedTags::$allowed_with_full_tags)) { |
|
294 | - AllowedTags::initializeWithFullTags(); |
|
295 | - } |
|
296 | - return AllowedTags::$allowed_with_full_tags; |
|
297 | - } |
|
17 | + /** |
|
18 | + * @var array[] |
|
19 | + */ |
|
20 | + private static $attributes = [ |
|
21 | + 'accept-charset' => 1, |
|
22 | + 'action' => 1, |
|
23 | + 'alt' => 1, |
|
24 | + 'allow' => 1, |
|
25 | + 'allowfullscreen' => 1, |
|
26 | + 'align' => 1, |
|
27 | + 'aria-*' => 1, |
|
28 | + 'autocomplete' => 1, |
|
29 | + 'bgcolor' => 1, |
|
30 | + 'border' => 1, |
|
31 | + 'cellpadding' => 1, |
|
32 | + 'cellspacing' => 1, |
|
33 | + 'checked' => 1, |
|
34 | + 'class' => 1, |
|
35 | + 'cols' => 1, |
|
36 | + 'content' => 1, |
|
37 | + 'data-*' => 1, |
|
38 | + 'dir' => 1, |
|
39 | + 'disabled' => 1, |
|
40 | + 'enctype' => 1, |
|
41 | + 'extension' => 1, |
|
42 | + 'for' => 1, |
|
43 | + 'frameborder' => 1, |
|
44 | + 'height' => 1, |
|
45 | + 'href' => 1, |
|
46 | + 'id' => 1, |
|
47 | + 'itemprop' => 1, |
|
48 | + 'itemscope' => 1, |
|
49 | + 'itemtype' => 1, |
|
50 | + 'label' => 1, |
|
51 | + 'lang' => 1, |
|
52 | + 'leftmargin' => 1, |
|
53 | + 'marginheight' => 1, |
|
54 | + 'marginwidth' => 1, |
|
55 | + 'max' => 1, |
|
56 | + 'maxlength' => 1, |
|
57 | + 'media' => 1, |
|
58 | + 'method' => 1, |
|
59 | + 'min' => 1, |
|
60 | + 'multiple' => 1, |
|
61 | + 'name' => 1, |
|
62 | + 'novalidate' => 1, |
|
63 | + 'placeholder' => 1, |
|
64 | + 'property' => 1, |
|
65 | + 'readonly' => 1, |
|
66 | + 'rel' => 1, |
|
67 | + 'required' => 1, |
|
68 | + 'rows' => 1, |
|
69 | + 'selected' => 1, |
|
70 | + 'src' => 1, |
|
71 | + 'size' => 1, |
|
72 | + 'style' => 1, |
|
73 | + 'step' => 1, |
|
74 | + 'tabindex' => 1, |
|
75 | + 'target' => 1, |
|
76 | + 'title' => 1, |
|
77 | + 'topmargin' => 1, |
|
78 | + 'type' => 1, |
|
79 | + 'value' => 1, |
|
80 | + 'width' => 1, |
|
81 | + ]; |
|
82 | + |
|
83 | + |
|
84 | + /** |
|
85 | + * @var array |
|
86 | + */ |
|
87 | + private static $tags = [ |
|
88 | + 'a', |
|
89 | + 'abbr', |
|
90 | + 'b', |
|
91 | + 'br', |
|
92 | + 'code', |
|
93 | + 'div', |
|
94 | + 'em', |
|
95 | + 'h1', |
|
96 | + 'h2', |
|
97 | + 'h3', |
|
98 | + 'h4', |
|
99 | + 'h5', |
|
100 | + 'h6', |
|
101 | + 'hr', |
|
102 | + 'i', |
|
103 | + 'img', |
|
104 | + 'li', |
|
105 | + 'ol', |
|
106 | + 'p', |
|
107 | + 'pre', |
|
108 | + 'small', |
|
109 | + 'span', |
|
110 | + 'strong', |
|
111 | + 'table', |
|
112 | + 'td', |
|
113 | + 'tr', |
|
114 | + 'ul', |
|
115 | + ]; |
|
116 | + |
|
117 | + |
|
118 | + /** |
|
119 | + * @var array |
|
120 | + */ |
|
121 | + private static $allowed_tags; |
|
122 | + |
|
123 | + |
|
124 | + /** |
|
125 | + * @var array |
|
126 | + */ |
|
127 | + private static $allowed_with_embed_tags; |
|
128 | + |
|
129 | + |
|
130 | + /** |
|
131 | + * @var array |
|
132 | + */ |
|
133 | + private static $allowed_with_form_tags; |
|
134 | + |
|
135 | + |
|
136 | + /** |
|
137 | + * @var array |
|
138 | + */ |
|
139 | + private static $allowed_with_script_and_style_tags; |
|
140 | + |
|
141 | + /** |
|
142 | + * @var array |
|
143 | + */ |
|
144 | + private static $allowed_with_full_tags; |
|
145 | + |
|
146 | + |
|
147 | + /** |
|
148 | + * merges additional tags and attributes into the WP post tags |
|
149 | + */ |
|
150 | + private static function initializeAllowedTags() |
|
151 | + { |
|
152 | + $allowed_post_tags = wp_kses_allowed_html('post'); |
|
153 | + $allowed_tags = []; |
|
154 | + foreach (AllowedTags::$tags as $tag) { |
|
155 | + $allowed_tags[ $tag ] = AllowedTags::$attributes; |
|
156 | + } |
|
157 | + AllowedTags::$allowed_tags = array_merge_recursive($allowed_post_tags, $allowed_tags); |
|
158 | + } |
|
159 | + |
|
160 | + |
|
161 | + /** |
|
162 | + * merges embed tags and attributes into the EE all tags |
|
163 | + */ |
|
164 | + private static function initializeWithEmbedTags() |
|
165 | + { |
|
166 | + $all_tags = AllowedTags::getAllowedTags(); |
|
167 | + $embed_tags = [ |
|
168 | + 'iframe' => AllowedTags::$attributes |
|
169 | + ]; |
|
170 | + AllowedTags::$allowed_with_embed_tags = array_merge_recursive($all_tags, $embed_tags); |
|
171 | + } |
|
172 | + |
|
173 | + |
|
174 | + /** |
|
175 | + * merges form tags and attributes into the EE all tags |
|
176 | + */ |
|
177 | + private static function initializeWithFormTags() |
|
178 | + { |
|
179 | + $all_tags = AllowedTags::getAllowedTags(); |
|
180 | + $form_tags = [ |
|
181 | + 'form' => AllowedTags::$attributes, |
|
182 | + 'label' => AllowedTags::$attributes, |
|
183 | + 'input' => AllowedTags::$attributes, |
|
184 | + 'select' => AllowedTags::$attributes, |
|
185 | + 'option' => AllowedTags::$attributes, |
|
186 | + 'optgroup' => AllowedTags::$attributes, |
|
187 | + 'textarea' => AllowedTags::$attributes, |
|
188 | + 'button' => AllowedTags::$attributes, |
|
189 | + 'fieldset' => AllowedTags::$attributes, |
|
190 | + 'output' => AllowedTags::$attributes, |
|
191 | + ]; |
|
192 | + AllowedTags::$allowed_with_form_tags = array_merge_recursive($all_tags, $form_tags); |
|
193 | + } |
|
194 | + |
|
195 | + |
|
196 | + /** |
|
197 | + * merges form script and style tags and attributes into the EE all tags |
|
198 | + */ |
|
199 | + private static function initializeWithScriptAndStyleTags() |
|
200 | + { |
|
201 | + $all_tags = AllowedTags::getAllowedTags(); |
|
202 | + $script_and_style_tags = [ |
|
203 | + 'script' => AllowedTags::$attributes, |
|
204 | + 'style' => AllowedTags::$attributes, |
|
205 | + 'link' => AllowedTags::$attributes, |
|
206 | + 'noscript' => AllowedTags::$attributes, |
|
207 | + ]; |
|
208 | + AllowedTags::$allowed_with_script_and_style_tags = array_merge_recursive($all_tags, $script_and_style_tags); |
|
209 | + } |
|
210 | + |
|
211 | + /** |
|
212 | + * merges all head and body tags and attributes into the EE all tags |
|
213 | + */ |
|
214 | + private static function initializeWithFullTags() |
|
215 | + { |
|
216 | + $all_tags = AllowedTags::getAllowedTags(); |
|
217 | + $full_tags = [ |
|
218 | + 'script' => AllowedTags::$attributes, |
|
219 | + 'style' => AllowedTags::$attributes, |
|
220 | + 'link' => AllowedTags::$attributes, |
|
221 | + 'title' => AllowedTags::$attributes, |
|
222 | + 'meta' => AllowedTags::$attributes, |
|
223 | + 'iframe' => AllowedTags::$attributes, |
|
224 | + 'form' => AllowedTags::$attributes, |
|
225 | + 'label' => AllowedTags::$attributes, |
|
226 | + 'input' => AllowedTags::$attributes, |
|
227 | + 'select' => AllowedTags::$attributes, |
|
228 | + 'option' => AllowedTags::$attributes, |
|
229 | + 'optgroup' => AllowedTags::$attributes, |
|
230 | + 'textarea' => AllowedTags::$attributes, |
|
231 | + 'button' => AllowedTags::$attributes, |
|
232 | + 'fieldset' => AllowedTags::$attributes, |
|
233 | + 'output' => AllowedTags::$attributes, |
|
234 | + 'noscript' => AllowedTags::$attributes, |
|
235 | + ]; |
|
236 | + AllowedTags::$allowed_with_full_tags = array_merge_recursive($all_tags, $full_tags); |
|
237 | + } |
|
238 | + |
|
239 | + |
|
240 | + /** |
|
241 | + * @return array[] |
|
242 | + */ |
|
243 | + public static function getAllowedTags() |
|
244 | + { |
|
245 | + if (empty(AllowedTags::$allowed_tags)) { |
|
246 | + AllowedTags::initializeAllowedTags(); |
|
247 | + } |
|
248 | + return AllowedTags::$allowed_tags; |
|
249 | + } |
|
250 | + |
|
251 | + |
|
252 | + /** |
|
253 | + * @return array[] |
|
254 | + */ |
|
255 | + public static function getWithEmbedTags() |
|
256 | + { |
|
257 | + if (empty(AllowedTags::$allowed_with_embed_tags)) { |
|
258 | + AllowedTags::initializeWithEmbedTags(); |
|
259 | + } |
|
260 | + return AllowedTags::$allowed_with_embed_tags; |
|
261 | + } |
|
262 | + |
|
263 | + |
|
264 | + /** |
|
265 | + * @return array[] |
|
266 | + */ |
|
267 | + public static function getWithFormTags() |
|
268 | + { |
|
269 | + if (empty(AllowedTags::$allowed_with_form_tags)) { |
|
270 | + AllowedTags::initializeWithFormTags(); |
|
271 | + } |
|
272 | + return AllowedTags::$allowed_with_form_tags; |
|
273 | + } |
|
274 | + |
|
275 | + |
|
276 | + /** |
|
277 | + * @return array[] |
|
278 | + */ |
|
279 | + public static function getWithScriptAndStyleTags() |
|
280 | + { |
|
281 | + if (empty(AllowedTags::$allowed_with_script_and_style_tags)) { |
|
282 | + AllowedTags::initializeWithScriptAndStyleTags(); |
|
283 | + } |
|
284 | + return AllowedTags::$allowed_with_script_and_style_tags; |
|
285 | + } |
|
286 | + |
|
287 | + |
|
288 | + /** |
|
289 | + * @return array[] |
|
290 | + */ |
|
291 | + public static function getWithFullTags() |
|
292 | + { |
|
293 | + if (empty(AllowedTags::$allowed_with_full_tags)) { |
|
294 | + AllowedTags::initializeWithFullTags(); |
|
295 | + } |
|
296 | + return AllowedTags::$allowed_with_full_tags; |
|
297 | + } |
|
298 | 298 | } |
@@ -7,67 +7,67 @@ |
||
7 | 7 | |
8 | 8 | class RequestSanitizer implements InterminableInterface |
9 | 9 | { |
10 | - /** |
|
11 | - * Will sanitize the supplied request parameter based on the specified data type |
|
12 | - * |
|
13 | - * @param mixed $param the supplied request parameter |
|
14 | - * @param string $type the specified data type (default: "string") |
|
15 | - * valid values: "bool", "float", "int", "key", "url", or "string" |
|
16 | - * @param bool $is_array if true, then $param will be treated as an array of $type |
|
17 | - * @param string $delimiter if $param is a CSV like value (ex: 1,2,3,4,5...) then this is the value separator |
|
18 | - * @return array|bool|float|int|string |
|
19 | - * @since 4.10.14.p |
|
20 | - */ |
|
21 | - public function clean($param, $type = DataType::STRING, $is_array = false, $delimiter = '') |
|
22 | - { |
|
23 | - if ($delimiter !== '' && is_string($param)) { |
|
24 | - $param = explode($delimiter, $param); |
|
25 | - $is_array = is_array($param); |
|
26 | - // unset the delimiter else this function will recurse forever when we loop over the array of results |
|
27 | - $delimiter = ''; |
|
28 | - } |
|
29 | - // check if we are getting an improperly typed array and correct |
|
30 | - $is_array = $is_array && is_array($param); |
|
31 | - if ($is_array) { |
|
32 | - $values = []; |
|
33 | - foreach ((array) $param as $key => $value) { |
|
34 | - $values[ $key ] = $this->clean($value, $type, is_array($value), $delimiter); |
|
35 | - } |
|
36 | - return $values; |
|
37 | - } |
|
38 | - return $this->sanitizeParam($param, $type); |
|
39 | - } |
|
10 | + /** |
|
11 | + * Will sanitize the supplied request parameter based on the specified data type |
|
12 | + * |
|
13 | + * @param mixed $param the supplied request parameter |
|
14 | + * @param string $type the specified data type (default: "string") |
|
15 | + * valid values: "bool", "float", "int", "key", "url", or "string" |
|
16 | + * @param bool $is_array if true, then $param will be treated as an array of $type |
|
17 | + * @param string $delimiter if $param is a CSV like value (ex: 1,2,3,4,5...) then this is the value separator |
|
18 | + * @return array|bool|float|int|string |
|
19 | + * @since 4.10.14.p |
|
20 | + */ |
|
21 | + public function clean($param, $type = DataType::STRING, $is_array = false, $delimiter = '') |
|
22 | + { |
|
23 | + if ($delimiter !== '' && is_string($param)) { |
|
24 | + $param = explode($delimiter, $param); |
|
25 | + $is_array = is_array($param); |
|
26 | + // unset the delimiter else this function will recurse forever when we loop over the array of results |
|
27 | + $delimiter = ''; |
|
28 | + } |
|
29 | + // check if we are getting an improperly typed array and correct |
|
30 | + $is_array = $is_array && is_array($param); |
|
31 | + if ($is_array) { |
|
32 | + $values = []; |
|
33 | + foreach ((array) $param as $key => $value) { |
|
34 | + $values[ $key ] = $this->clean($value, $type, is_array($value), $delimiter); |
|
35 | + } |
|
36 | + return $values; |
|
37 | + } |
|
38 | + return $this->sanitizeParam($param, $type); |
|
39 | + } |
|
40 | 40 | |
41 | 41 | |
42 | - /** |
|
43 | - * @param mixed $param |
|
44 | - * @param string $type |
|
45 | - * @return array|float|int|mixed|string|string[]|null |
|
46 | - * @since 4.10.20.p |
|
47 | - */ |
|
48 | - public function sanitizeParam($param, $type = DataType::STRING) |
|
49 | - { |
|
50 | - switch ($type) { |
|
51 | - case DataType::BOOL: |
|
52 | - return filter_var($param, FILTER_VALIDATE_BOOLEAN); |
|
53 | - case DataType::FLOAT: |
|
54 | - return (float) $param; |
|
55 | - case DataType::FQCN: |
|
56 | - return preg_replace('[^\\\w\d]', '', $param); |
|
57 | - case DataType::HTML: |
|
58 | - $allowed_tags = AllowedTags::getAllowedTags(); |
|
59 | - return wp_kses($param, $allowed_tags); |
|
60 | - case DataType::INT: |
|
61 | - return (int) $param; |
|
62 | - case DataType::KEY: |
|
63 | - return sanitize_key($param); |
|
64 | - case DataType::TITLE: |
|
65 | - return sanitize_title($param); |
|
66 | - case DataType::URL: |
|
67 | - return esc_url_raw($param); |
|
68 | - case DataType::STRING: |
|
69 | - default: |
|
70 | - return sanitize_text_field($param); |
|
71 | - } |
|
72 | - } |
|
42 | + /** |
|
43 | + * @param mixed $param |
|
44 | + * @param string $type |
|
45 | + * @return array|float|int|mixed|string|string[]|null |
|
46 | + * @since 4.10.20.p |
|
47 | + */ |
|
48 | + public function sanitizeParam($param, $type = DataType::STRING) |
|
49 | + { |
|
50 | + switch ($type) { |
|
51 | + case DataType::BOOL: |
|
52 | + return filter_var($param, FILTER_VALIDATE_BOOLEAN); |
|
53 | + case DataType::FLOAT: |
|
54 | + return (float) $param; |
|
55 | + case DataType::FQCN: |
|
56 | + return preg_replace('[^\\\w\d]', '', $param); |
|
57 | + case DataType::HTML: |
|
58 | + $allowed_tags = AllowedTags::getAllowedTags(); |
|
59 | + return wp_kses($param, $allowed_tags); |
|
60 | + case DataType::INT: |
|
61 | + return (int) $param; |
|
62 | + case DataType::KEY: |
|
63 | + return sanitize_key($param); |
|
64 | + case DataType::TITLE: |
|
65 | + return sanitize_title($param); |
|
66 | + case DataType::URL: |
|
67 | + return esc_url_raw($param); |
|
68 | + case DataType::STRING: |
|
69 | + default: |
|
70 | + return sanitize_text_field($param); |
|
71 | + } |
|
72 | + } |
|
73 | 73 | } |
@@ -13,25 +13,25 @@ |
||
13 | 13 | */ |
14 | 14 | class AttributesSanitizer implements InterminableInterface |
15 | 15 | { |
16 | - /** |
|
17 | - * @param string $attributes |
|
18 | - * @param array $allowed_tags |
|
19 | - * @param string $tag |
|
20 | - * @return mixed|string |
|
21 | - */ |
|
22 | - public static function clean(string $attributes, array $allowed_tags, string $tag = 'div') |
|
23 | - { |
|
24 | - if (trim($attributes) === '') { |
|
25 | - return ''; |
|
26 | - } |
|
27 | - $html = '<' . $tag . ' ' . $attributes . '>'; |
|
28 | - $escaped = wp_kses($html, $allowed_tags); |
|
29 | - $start = strpos($escaped, ' '); |
|
30 | - $end = strpos($escaped, '>'); |
|
31 | - if ($start === false || $end === false) { |
|
32 | - return ''; |
|
33 | - } |
|
34 | - $length = $end - $start; |
|
35 | - return trim(substr($escaped, $start, $length)); |
|
36 | - } |
|
16 | + /** |
|
17 | + * @param string $attributes |
|
18 | + * @param array $allowed_tags |
|
19 | + * @param string $tag |
|
20 | + * @return mixed|string |
|
21 | + */ |
|
22 | + public static function clean(string $attributes, array $allowed_tags, string $tag = 'div') |
|
23 | + { |
|
24 | + if (trim($attributes) === '') { |
|
25 | + return ''; |
|
26 | + } |
|
27 | + $html = '<' . $tag . ' ' . $attributes . '>'; |
|
28 | + $escaped = wp_kses($html, $allowed_tags); |
|
29 | + $start = strpos($escaped, ' '); |
|
30 | + $end = strpos($escaped, '>'); |
|
31 | + if ($start === false || $end === false) { |
|
32 | + return ''; |
|
33 | + } |
|
34 | + $length = $end - $start; |
|
35 | + return trim(substr($escaped, $start, $length)); |
|
36 | + } |
|
37 | 37 | } |
@@ -13,60 +13,60 @@ |
||
13 | 13 | */ |
14 | 14 | class ServerSanitizer implements InterminableInterface |
15 | 15 | { |
16 | - /** |
|
17 | - * @param string $key |
|
18 | - * @param string $value |
|
19 | - * @return mixed|string |
|
20 | - */ |
|
21 | - public function clean($key, $value) |
|
22 | - { |
|
23 | - switch ($key) { |
|
24 | - case 'AUTH_TYPE': |
|
25 | - $valid_types = [ |
|
26 | - 'Basic', |
|
27 | - 'Bearer', |
|
28 | - 'Digest', |
|
29 | - 'HOBA', |
|
30 | - 'Mutual', |
|
31 | - 'Negotiate', |
|
32 | - 'OAuth', |
|
33 | - 'SCRAM-SHA-1', |
|
34 | - 'SCRAM-SHA-256', |
|
35 | - 'vapid', |
|
36 | - ]; |
|
37 | - return in_array($value, $valid_types, true) ? $value : 'Basic'; |
|
38 | - case 'argc': |
|
39 | - case 'HTTP_DNT': |
|
40 | - case 'HTTP_UPGRADE_INSECURE_REQUESTS': |
|
41 | - case 'SERVER_PORT': |
|
42 | - case 'REMOTE_PORT': |
|
43 | - case 'REQUEST_TIME': |
|
44 | - return (int) filter_var($value, FILTER_SANITIZE_NUMBER_INT); |
|
45 | - case 'REQUEST_TIME_FLOAT': |
|
46 | - return (float) filter_var($value, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
47 | - case 'REQUEST_METHOD': |
|
48 | - $valid_types = [ |
|
49 | - 'CONNECT', |
|
50 | - 'DELETE', |
|
51 | - 'GET', |
|
52 | - 'HEAD', |
|
53 | - 'OPTIONS', |
|
54 | - 'PATCH', |
|
55 | - 'POST', |
|
56 | - 'PUT', |
|
57 | - 'TRACE', |
|
58 | - ]; |
|
59 | - return in_array($value, $valid_types, true) ? $value : 'GET'; |
|
60 | - case 'HTTP_HOST': |
|
61 | - case 'QUERY_STRING': |
|
62 | - case 'REQUEST_URI': |
|
63 | - case 'SCRIPT_NAME': |
|
64 | - case 'SERVER_NAME': |
|
65 | - return filter_var($value, FILTER_SANITIZE_URL); |
|
66 | - case 'SERVER_ADMIN': |
|
67 | - return filter_var($value, FILTER_SANITIZE_EMAIL); |
|
68 | - default: |
|
69 | - return filter_var($value, FILTER_UNSAFE_RAW); |
|
70 | - } |
|
71 | - } |
|
16 | + /** |
|
17 | + * @param string $key |
|
18 | + * @param string $value |
|
19 | + * @return mixed|string |
|
20 | + */ |
|
21 | + public function clean($key, $value) |
|
22 | + { |
|
23 | + switch ($key) { |
|
24 | + case 'AUTH_TYPE': |
|
25 | + $valid_types = [ |
|
26 | + 'Basic', |
|
27 | + 'Bearer', |
|
28 | + 'Digest', |
|
29 | + 'HOBA', |
|
30 | + 'Mutual', |
|
31 | + 'Negotiate', |
|
32 | + 'OAuth', |
|
33 | + 'SCRAM-SHA-1', |
|
34 | + 'SCRAM-SHA-256', |
|
35 | + 'vapid', |
|
36 | + ]; |
|
37 | + return in_array($value, $valid_types, true) ? $value : 'Basic'; |
|
38 | + case 'argc': |
|
39 | + case 'HTTP_DNT': |
|
40 | + case 'HTTP_UPGRADE_INSECURE_REQUESTS': |
|
41 | + case 'SERVER_PORT': |
|
42 | + case 'REMOTE_PORT': |
|
43 | + case 'REQUEST_TIME': |
|
44 | + return (int) filter_var($value, FILTER_SANITIZE_NUMBER_INT); |
|
45 | + case 'REQUEST_TIME_FLOAT': |
|
46 | + return (float) filter_var($value, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
47 | + case 'REQUEST_METHOD': |
|
48 | + $valid_types = [ |
|
49 | + 'CONNECT', |
|
50 | + 'DELETE', |
|
51 | + 'GET', |
|
52 | + 'HEAD', |
|
53 | + 'OPTIONS', |
|
54 | + 'PATCH', |
|
55 | + 'POST', |
|
56 | + 'PUT', |
|
57 | + 'TRACE', |
|
58 | + ]; |
|
59 | + return in_array($value, $valid_types, true) ? $value : 'GET'; |
|
60 | + case 'HTTP_HOST': |
|
61 | + case 'QUERY_STRING': |
|
62 | + case 'REQUEST_URI': |
|
63 | + case 'SCRIPT_NAME': |
|
64 | + case 'SERVER_NAME': |
|
65 | + return filter_var($value, FILTER_SANITIZE_URL); |
|
66 | + case 'SERVER_ADMIN': |
|
67 | + return filter_var($value, FILTER_SANITIZE_EMAIL); |
|
68 | + default: |
|
69 | + return filter_var($value, FILTER_UNSAFE_RAW); |
|
70 | + } |
|
71 | + } |
|
72 | 72 | } |
@@ -25,52 +25,52 @@ |
||
25 | 25 | */ |
26 | 26 | abstract class Middleware implements InterminableInterface, RequestDecoratorInterface |
27 | 27 | { |
28 | - /** |
|
29 | - * @var RequestDecoratorInterface $request_stack_app |
|
30 | - */ |
|
31 | - protected $request_stack_app; |
|
28 | + /** |
|
29 | + * @var RequestDecoratorInterface $request_stack_app |
|
30 | + */ |
|
31 | + protected $request_stack_app; |
|
32 | 32 | |
33 | - /** |
|
34 | - * @var RequestInterface $request |
|
35 | - */ |
|
36 | - protected $request; |
|
33 | + /** |
|
34 | + * @var RequestInterface $request |
|
35 | + */ |
|
36 | + protected $request; |
|
37 | 37 | |
38 | - /** |
|
39 | - * @var ResponseInterface $response |
|
40 | - */ |
|
41 | - protected $response; |
|
38 | + /** |
|
39 | + * @var ResponseInterface $response |
|
40 | + */ |
|
41 | + protected $response; |
|
42 | 42 | |
43 | - /** |
|
44 | - * @var LoaderInterface |
|
45 | - */ |
|
46 | - protected $loader; |
|
43 | + /** |
|
44 | + * @var LoaderInterface |
|
45 | + */ |
|
46 | + protected $loader; |
|
47 | 47 | |
48 | 48 | |
49 | - /** |
|
50 | - * @param RequestDecoratorInterface $request_stack_app |
|
51 | - * @param LoaderInterface $loader |
|
52 | - */ |
|
53 | - public function __construct(RequestDecoratorInterface $request_stack_app, LoaderInterface $loader) |
|
54 | - { |
|
55 | - $this->request_stack_app = $request_stack_app; |
|
56 | - $this->loader = $loader; |
|
57 | - } |
|
49 | + /** |
|
50 | + * @param RequestDecoratorInterface $request_stack_app |
|
51 | + * @param LoaderInterface $loader |
|
52 | + */ |
|
53 | + public function __construct(RequestDecoratorInterface $request_stack_app, LoaderInterface $loader) |
|
54 | + { |
|
55 | + $this->request_stack_app = $request_stack_app; |
|
56 | + $this->loader = $loader; |
|
57 | + } |
|
58 | 58 | |
59 | 59 | |
60 | - /** |
|
61 | - * process_request_stack |
|
62 | - * |
|
63 | - * @param RequestInterface $request |
|
64 | - * @param ResponseInterface $response |
|
65 | - * @return ResponseInterface |
|
66 | - */ |
|
67 | - protected function processRequestStack(RequestInterface $request, ResponseInterface $response) |
|
68 | - { |
|
69 | - $this->request = $request; |
|
70 | - $this->response = $response; |
|
71 | - if (! $this->response->requestTerminated()) { |
|
72 | - $this->response = $this->request_stack_app->handleRequest($this->request, $this->response); |
|
73 | - } |
|
74 | - return $this->response; |
|
75 | - } |
|
60 | + /** |
|
61 | + * process_request_stack |
|
62 | + * |
|
63 | + * @param RequestInterface $request |
|
64 | + * @param ResponseInterface $response |
|
65 | + * @return ResponseInterface |
|
66 | + */ |
|
67 | + protected function processRequestStack(RequestInterface $request, ResponseInterface $response) |
|
68 | + { |
|
69 | + $this->request = $request; |
|
70 | + $this->response = $response; |
|
71 | + if (! $this->response->requestTerminated()) { |
|
72 | + $this->response = $this->request_stack_app->handleRequest($this->request, $this->response); |
|
73 | + } |
|
74 | + return $this->response; |
|
75 | + } |
|
76 | 76 | } |
@@ -25,123 +25,123 @@ |
||
25 | 25 | */ |
26 | 26 | class BootstrapDependencyInjectionContainer implements InterminableInterface |
27 | 27 | { |
28 | - /** |
|
29 | - * @var EE_Dependency_Map $dependency_map |
|
30 | - */ |
|
31 | - protected $dependency_map; |
|
32 | - |
|
33 | - /** |
|
34 | - * @type LoaderInterface $loader |
|
35 | - */ |
|
36 | - protected $loader; |
|
37 | - |
|
38 | - /** |
|
39 | - * @var EE_Registry $registry |
|
40 | - */ |
|
41 | - protected $registry; |
|
42 | - |
|
43 | - /** |
|
44 | - * @var ClassInterfaceCache $class_cache |
|
45 | - */ |
|
46 | - private $class_cache; |
|
47 | - |
|
48 | - /** |
|
49 | - * @var Mirror |
|
50 | - */ |
|
51 | - private $mirror; |
|
52 | - |
|
53 | - /** |
|
54 | - * @var ObjectIdentifier |
|
55 | - */ |
|
56 | - private $object_identifier; |
|
57 | - |
|
58 | - |
|
59 | - /** |
|
60 | - * Can't use this just yet until we exorcise some more of our singleton usage from core |
|
61 | - */ |
|
62 | - public function buildDependencyInjectionContainer() |
|
63 | - { |
|
64 | - // build DI container |
|
65 | - // $OpenCoffeeShop = new EventEspresso\core\services\container\OpenCoffeeShop(); |
|
66 | - // $OpenCoffeeShop->addRecipes(); |
|
67 | - // $CoffeeShop = $OpenCoffeeShop->CoffeeShop(); |
|
68 | - } |
|
69 | - |
|
70 | - |
|
71 | - /** |
|
72 | - * Setups EE_Registry and EE_Dependency_Map |
|
73 | - * |
|
74 | - * @throws EE_Error |
|
75 | - */ |
|
76 | - public function buildLegacyDependencyInjectionContainer() |
|
77 | - { |
|
78 | - $this->class_cache = new ClassInterfaceCache(); |
|
79 | - $this->object_identifier = new ObjectIdentifier($this->class_cache); |
|
80 | - $this->mirror = new Mirror(); |
|
81 | - // EE_Dependency_Map: info about how to load classes required by other classes |
|
82 | - espresso_load_required( |
|
83 | - 'EE_Dependency_Map', |
|
84 | - EE_CORE . 'EE_Dependency_Map.core.php' |
|
85 | - ); |
|
86 | - $this->dependency_map = EE_Dependency_Map::instance($this->class_cache); |
|
87 | - // EE_Registry: central repository for classes (legacy) |
|
88 | - espresso_load_required( |
|
89 | - 'EE_Registry', |
|
90 | - EE_CORE . 'EE_Registry.core.php' |
|
91 | - ); |
|
92 | - $this->registry = EE_Registry::instance( |
|
93 | - $this->dependency_map, |
|
94 | - $this->mirror, |
|
95 | - $this->class_cache, |
|
96 | - $this->object_identifier |
|
97 | - ); |
|
98 | - } |
|
99 | - |
|
100 | - |
|
101 | - /** |
|
102 | - * Performs initial setup for the generic Loader |
|
103 | - * |
|
104 | - * @throws InvalidDataTypeException |
|
105 | - * @throws InvalidInterfaceException |
|
106 | - * @throws InvalidArgumentException |
|
107 | - */ |
|
108 | - public function buildLoader() |
|
109 | - { |
|
110 | - $this->loader = LoaderFactory::getLoader( |
|
111 | - $this->registry, |
|
112 | - $this->class_cache, |
|
113 | - $this->object_identifier |
|
114 | - ); |
|
115 | - $this->loader->share('EventEspresso\core\services\loaders\ClassInterfaceCache', $this->class_cache); |
|
116 | - $this->loader->share('EventEspresso\core\services\loaders\ObjectIdentifier', $this->object_identifier); |
|
117 | - $this->loader->share('EventEspresso\core\services\container\Mirror', $this->mirror); |
|
118 | - $this->dependency_map->setLoader($this->loader); |
|
119 | - } |
|
120 | - |
|
121 | - |
|
122 | - /** |
|
123 | - * @return EE_Dependency_Map |
|
124 | - */ |
|
125 | - public function getDependencyMap() |
|
126 | - { |
|
127 | - return $this->dependency_map; |
|
128 | - } |
|
129 | - |
|
130 | - |
|
131 | - /** |
|
132 | - * @return EE_Registry |
|
133 | - */ |
|
134 | - public function getRegistry() |
|
135 | - { |
|
136 | - return $this->registry; |
|
137 | - } |
|
138 | - |
|
139 | - |
|
140 | - /** |
|
141 | - * @return LoaderInterface |
|
142 | - */ |
|
143 | - public function getLoader() |
|
144 | - { |
|
145 | - return $this->loader; |
|
146 | - } |
|
28 | + /** |
|
29 | + * @var EE_Dependency_Map $dependency_map |
|
30 | + */ |
|
31 | + protected $dependency_map; |
|
32 | + |
|
33 | + /** |
|
34 | + * @type LoaderInterface $loader |
|
35 | + */ |
|
36 | + protected $loader; |
|
37 | + |
|
38 | + /** |
|
39 | + * @var EE_Registry $registry |
|
40 | + */ |
|
41 | + protected $registry; |
|
42 | + |
|
43 | + /** |
|
44 | + * @var ClassInterfaceCache $class_cache |
|
45 | + */ |
|
46 | + private $class_cache; |
|
47 | + |
|
48 | + /** |
|
49 | + * @var Mirror |
|
50 | + */ |
|
51 | + private $mirror; |
|
52 | + |
|
53 | + /** |
|
54 | + * @var ObjectIdentifier |
|
55 | + */ |
|
56 | + private $object_identifier; |
|
57 | + |
|
58 | + |
|
59 | + /** |
|
60 | + * Can't use this just yet until we exorcise some more of our singleton usage from core |
|
61 | + */ |
|
62 | + public function buildDependencyInjectionContainer() |
|
63 | + { |
|
64 | + // build DI container |
|
65 | + // $OpenCoffeeShop = new EventEspresso\core\services\container\OpenCoffeeShop(); |
|
66 | + // $OpenCoffeeShop->addRecipes(); |
|
67 | + // $CoffeeShop = $OpenCoffeeShop->CoffeeShop(); |
|
68 | + } |
|
69 | + |
|
70 | + |
|
71 | + /** |
|
72 | + * Setups EE_Registry and EE_Dependency_Map |
|
73 | + * |
|
74 | + * @throws EE_Error |
|
75 | + */ |
|
76 | + public function buildLegacyDependencyInjectionContainer() |
|
77 | + { |
|
78 | + $this->class_cache = new ClassInterfaceCache(); |
|
79 | + $this->object_identifier = new ObjectIdentifier($this->class_cache); |
|
80 | + $this->mirror = new Mirror(); |
|
81 | + // EE_Dependency_Map: info about how to load classes required by other classes |
|
82 | + espresso_load_required( |
|
83 | + 'EE_Dependency_Map', |
|
84 | + EE_CORE . 'EE_Dependency_Map.core.php' |
|
85 | + ); |
|
86 | + $this->dependency_map = EE_Dependency_Map::instance($this->class_cache); |
|
87 | + // EE_Registry: central repository for classes (legacy) |
|
88 | + espresso_load_required( |
|
89 | + 'EE_Registry', |
|
90 | + EE_CORE . 'EE_Registry.core.php' |
|
91 | + ); |
|
92 | + $this->registry = EE_Registry::instance( |
|
93 | + $this->dependency_map, |
|
94 | + $this->mirror, |
|
95 | + $this->class_cache, |
|
96 | + $this->object_identifier |
|
97 | + ); |
|
98 | + } |
|
99 | + |
|
100 | + |
|
101 | + /** |
|
102 | + * Performs initial setup for the generic Loader |
|
103 | + * |
|
104 | + * @throws InvalidDataTypeException |
|
105 | + * @throws InvalidInterfaceException |
|
106 | + * @throws InvalidArgumentException |
|
107 | + */ |
|
108 | + public function buildLoader() |
|
109 | + { |
|
110 | + $this->loader = LoaderFactory::getLoader( |
|
111 | + $this->registry, |
|
112 | + $this->class_cache, |
|
113 | + $this->object_identifier |
|
114 | + ); |
|
115 | + $this->loader->share('EventEspresso\core\services\loaders\ClassInterfaceCache', $this->class_cache); |
|
116 | + $this->loader->share('EventEspresso\core\services\loaders\ObjectIdentifier', $this->object_identifier); |
|
117 | + $this->loader->share('EventEspresso\core\services\container\Mirror', $this->mirror); |
|
118 | + $this->dependency_map->setLoader($this->loader); |
|
119 | + } |
|
120 | + |
|
121 | + |
|
122 | + /** |
|
123 | + * @return EE_Dependency_Map |
|
124 | + */ |
|
125 | + public function getDependencyMap() |
|
126 | + { |
|
127 | + return $this->dependency_map; |
|
128 | + } |
|
129 | + |
|
130 | + |
|
131 | + /** |
|
132 | + * @return EE_Registry |
|
133 | + */ |
|
134 | + public function getRegistry() |
|
135 | + { |
|
136 | + return $this->registry; |
|
137 | + } |
|
138 | + |
|
139 | + |
|
140 | + /** |
|
141 | + * @return LoaderInterface |
|
142 | + */ |
|
143 | + public function getLoader() |
|
144 | + { |
|
145 | + return $this->loader; |
|
146 | + } |
|
147 | 147 | } |