@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | */ |
94 | 94 | private function setSource($source) |
95 | 95 | { |
96 | - if (! is_string($source)) { |
|
96 | + if ( ! is_string($source)) { |
|
97 | 97 | throw new InvalidDataTypeException( |
98 | 98 | '$source', |
99 | 99 | $source, |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | */ |
127 | 127 | public function setVersion($version = EVENT_ESPRESSO_VERSION) |
128 | 128 | { |
129 | - if (! is_string($version)) { |
|
129 | + if ( ! is_string($version)) { |
|
130 | 130 | throw new InvalidDataTypeException( |
131 | 131 | '$version', |
132 | 132 | $version, |
@@ -16,136 +16,136 @@ |
||
16 | 16 | abstract class BrowserAsset extends Asset |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * @var string $source |
|
21 | - */ |
|
22 | - private $source; |
|
23 | - |
|
24 | - /** |
|
25 | - * @var array $dependencies |
|
26 | - */ |
|
27 | - private $dependencies; |
|
28 | - |
|
29 | - /** |
|
30 | - * @var string $version |
|
31 | - */ |
|
32 | - private $version; |
|
33 | - |
|
34 | - |
|
35 | - /** |
|
36 | - * Asset constructor. |
|
37 | - * |
|
38 | - * @param string $type |
|
39 | - * @param string $handle |
|
40 | - * @param string $source |
|
41 | - * @param array $dependencies |
|
42 | - * @param DomainInterface $domain |
|
43 | - * @throws InvalidDataTypeException |
|
44 | - */ |
|
45 | - public function __construct($type, $handle, $source, array $dependencies, DomainInterface $domain) |
|
46 | - { |
|
47 | - parent::__construct($type, $handle, $domain); |
|
48 | - $this->setSource($source); |
|
49 | - $this->setDependencies($dependencies); |
|
50 | - } |
|
51 | - |
|
52 | - |
|
53 | - /** |
|
54 | - * @since $VID:$ |
|
55 | - */ |
|
56 | - abstract public function enqueueAsset(); |
|
57 | - |
|
58 | - |
|
59 | - /** |
|
60 | - * @return array |
|
61 | - */ |
|
62 | - public function dependencies() |
|
63 | - { |
|
64 | - return $this->dependencies; |
|
65 | - } |
|
66 | - |
|
67 | - |
|
68 | - /** |
|
69 | - * @param array $dependencies |
|
70 | - */ |
|
71 | - private function setDependencies(array $dependencies) |
|
72 | - { |
|
73 | - $this->dependencies = $dependencies; |
|
74 | - } |
|
75 | - |
|
76 | - |
|
77 | - /** |
|
78 | - * @since $VID:$ |
|
79 | - * @return bool |
|
80 | - */ |
|
81 | - public function hasDependencies() |
|
82 | - { |
|
83 | - return count($this->dependencies) > 0; |
|
84 | - } |
|
85 | - |
|
86 | - |
|
87 | - /** |
|
88 | - * @return string |
|
89 | - */ |
|
90 | - public function source() |
|
91 | - { |
|
92 | - return $this->source; |
|
93 | - } |
|
94 | - |
|
95 | - |
|
96 | - /** |
|
97 | - * @param string $source |
|
98 | - * @throws InvalidDataTypeException |
|
99 | - */ |
|
100 | - private function setSource($source) |
|
101 | - { |
|
102 | - if (! is_string($source)) { |
|
103 | - throw new InvalidDataTypeException( |
|
104 | - '$source', |
|
105 | - $source, |
|
106 | - 'string' |
|
107 | - ); |
|
108 | - } |
|
109 | - $this->source = $source; |
|
110 | - } |
|
111 | - |
|
112 | - |
|
113 | - /** |
|
114 | - * @return string |
|
115 | - * @throws InvalidDataTypeException |
|
116 | - */ |
|
117 | - public function version() |
|
118 | - { |
|
119 | - // if version is NOT set and this asset was NOT built for distribution, |
|
120 | - // then set the version equal to the EE core plugin version |
|
121 | - if ( |
|
122 | - $this->version === null |
|
123 | - && ( |
|
124 | - substr($this->source, -8) !== Asset::FILE_EXTENSION_DISTRIBUTION_JS |
|
125 | - || substr($this->source, -9) !== Asset::FILE_EXTENSION_DISTRIBUTION_CSS |
|
126 | - ) |
|
127 | - ) { |
|
128 | - $this->setVersion(); |
|
129 | - } |
|
130 | - return $this->version; |
|
131 | - } |
|
132 | - |
|
133 | - |
|
134 | - /** |
|
135 | - * @param string $version |
|
136 | - * @return BrowserAsset |
|
137 | - * @throws InvalidDataTypeException |
|
138 | - */ |
|
139 | - public function setVersion($version = EVENT_ESPRESSO_VERSION) |
|
140 | - { |
|
141 | - if (! is_string($version)) { |
|
142 | - throw new InvalidDataTypeException( |
|
143 | - '$version', |
|
144 | - $version, |
|
145 | - 'string' |
|
146 | - ); |
|
147 | - } |
|
148 | - $this->version = $version; |
|
149 | - return $this; |
|
150 | - } |
|
19 | + /** |
|
20 | + * @var string $source |
|
21 | + */ |
|
22 | + private $source; |
|
23 | + |
|
24 | + /** |
|
25 | + * @var array $dependencies |
|
26 | + */ |
|
27 | + private $dependencies; |
|
28 | + |
|
29 | + /** |
|
30 | + * @var string $version |
|
31 | + */ |
|
32 | + private $version; |
|
33 | + |
|
34 | + |
|
35 | + /** |
|
36 | + * Asset constructor. |
|
37 | + * |
|
38 | + * @param string $type |
|
39 | + * @param string $handle |
|
40 | + * @param string $source |
|
41 | + * @param array $dependencies |
|
42 | + * @param DomainInterface $domain |
|
43 | + * @throws InvalidDataTypeException |
|
44 | + */ |
|
45 | + public function __construct($type, $handle, $source, array $dependencies, DomainInterface $domain) |
|
46 | + { |
|
47 | + parent::__construct($type, $handle, $domain); |
|
48 | + $this->setSource($source); |
|
49 | + $this->setDependencies($dependencies); |
|
50 | + } |
|
51 | + |
|
52 | + |
|
53 | + /** |
|
54 | + * @since $VID:$ |
|
55 | + */ |
|
56 | + abstract public function enqueueAsset(); |
|
57 | + |
|
58 | + |
|
59 | + /** |
|
60 | + * @return array |
|
61 | + */ |
|
62 | + public function dependencies() |
|
63 | + { |
|
64 | + return $this->dependencies; |
|
65 | + } |
|
66 | + |
|
67 | + |
|
68 | + /** |
|
69 | + * @param array $dependencies |
|
70 | + */ |
|
71 | + private function setDependencies(array $dependencies) |
|
72 | + { |
|
73 | + $this->dependencies = $dependencies; |
|
74 | + } |
|
75 | + |
|
76 | + |
|
77 | + /** |
|
78 | + * @since $VID:$ |
|
79 | + * @return bool |
|
80 | + */ |
|
81 | + public function hasDependencies() |
|
82 | + { |
|
83 | + return count($this->dependencies) > 0; |
|
84 | + } |
|
85 | + |
|
86 | + |
|
87 | + /** |
|
88 | + * @return string |
|
89 | + */ |
|
90 | + public function source() |
|
91 | + { |
|
92 | + return $this->source; |
|
93 | + } |
|
94 | + |
|
95 | + |
|
96 | + /** |
|
97 | + * @param string $source |
|
98 | + * @throws InvalidDataTypeException |
|
99 | + */ |
|
100 | + private function setSource($source) |
|
101 | + { |
|
102 | + if (! is_string($source)) { |
|
103 | + throw new InvalidDataTypeException( |
|
104 | + '$source', |
|
105 | + $source, |
|
106 | + 'string' |
|
107 | + ); |
|
108 | + } |
|
109 | + $this->source = $source; |
|
110 | + } |
|
111 | + |
|
112 | + |
|
113 | + /** |
|
114 | + * @return string |
|
115 | + * @throws InvalidDataTypeException |
|
116 | + */ |
|
117 | + public function version() |
|
118 | + { |
|
119 | + // if version is NOT set and this asset was NOT built for distribution, |
|
120 | + // then set the version equal to the EE core plugin version |
|
121 | + if ( |
|
122 | + $this->version === null |
|
123 | + && ( |
|
124 | + substr($this->source, -8) !== Asset::FILE_EXTENSION_DISTRIBUTION_JS |
|
125 | + || substr($this->source, -9) !== Asset::FILE_EXTENSION_DISTRIBUTION_CSS |
|
126 | + ) |
|
127 | + ) { |
|
128 | + $this->setVersion(); |
|
129 | + } |
|
130 | + return $this->version; |
|
131 | + } |
|
132 | + |
|
133 | + |
|
134 | + /** |
|
135 | + * @param string $version |
|
136 | + * @return BrowserAsset |
|
137 | + * @throws InvalidDataTypeException |
|
138 | + */ |
|
139 | + public function setVersion($version = EVENT_ESPRESSO_VERSION) |
|
140 | + { |
|
141 | + if (! is_string($version)) { |
|
142 | + throw new InvalidDataTypeException( |
|
143 | + '$version', |
|
144 | + $version, |
|
145 | + 'string' |
|
146 | + ); |
|
147 | + } |
|
148 | + $this->version = $version; |
|
149 | + return $this; |
|
150 | + } |
|
151 | 151 | } |
@@ -54,7 +54,7 @@ |
||
54 | 54 | */ |
55 | 55 | private function setMedia($media) |
56 | 56 | { |
57 | - if (! is_string($media)) { |
|
57 | + if ( ! is_string($media)) { |
|
58 | 58 | throw new InvalidDataTypeException( |
59 | 59 | '$media', |
60 | 60 | $media, |
@@ -16,60 +16,60 @@ |
||
16 | 16 | class StylesheetAsset extends BrowserAsset |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * @var string $media |
|
21 | - */ |
|
22 | - private $media; |
|
19 | + /** |
|
20 | + * @var string $media |
|
21 | + */ |
|
22 | + private $media; |
|
23 | 23 | |
24 | 24 | |
25 | - /** |
|
26 | - * CssFile constructor. |
|
27 | - * |
|
28 | - * @param $handle |
|
29 | - * @param string $source |
|
30 | - * @param array $dependencies |
|
31 | - * @param DomainInterface $domain |
|
32 | - * @param $media |
|
33 | - * @throws InvalidDataTypeException |
|
34 | - */ |
|
35 | - public function __construct($handle, $source, array $dependencies, DomainInterface $domain, $media = 'all') |
|
36 | - { |
|
37 | - parent::__construct(Asset::TYPE_CSS, $handle, $source, $dependencies, $domain); |
|
38 | - $this->setMedia($media); |
|
39 | - } |
|
25 | + /** |
|
26 | + * CssFile constructor. |
|
27 | + * |
|
28 | + * @param $handle |
|
29 | + * @param string $source |
|
30 | + * @param array $dependencies |
|
31 | + * @param DomainInterface $domain |
|
32 | + * @param $media |
|
33 | + * @throws InvalidDataTypeException |
|
34 | + */ |
|
35 | + public function __construct($handle, $source, array $dependencies, DomainInterface $domain, $media = 'all') |
|
36 | + { |
|
37 | + parent::__construct(Asset::TYPE_CSS, $handle, $source, $dependencies, $domain); |
|
38 | + $this->setMedia($media); |
|
39 | + } |
|
40 | 40 | |
41 | 41 | |
42 | - /** |
|
43 | - * @return string |
|
44 | - */ |
|
45 | - public function media() |
|
46 | - { |
|
47 | - return $this->media; |
|
48 | - } |
|
42 | + /** |
|
43 | + * @return string |
|
44 | + */ |
|
45 | + public function media() |
|
46 | + { |
|
47 | + return $this->media; |
|
48 | + } |
|
49 | 49 | |
50 | 50 | |
51 | - /** |
|
52 | - * @param string $media |
|
53 | - * @throws InvalidDataTypeException |
|
54 | - */ |
|
55 | - private function setMedia($media) |
|
56 | - { |
|
57 | - if (! is_string($media)) { |
|
58 | - throw new InvalidDataTypeException( |
|
59 | - '$media', |
|
60 | - $media, |
|
61 | - 'string' |
|
62 | - ); |
|
63 | - } |
|
64 | - $this->media = $media; |
|
65 | - } |
|
51 | + /** |
|
52 | + * @param string $media |
|
53 | + * @throws InvalidDataTypeException |
|
54 | + */ |
|
55 | + private function setMedia($media) |
|
56 | + { |
|
57 | + if (! is_string($media)) { |
|
58 | + throw new InvalidDataTypeException( |
|
59 | + '$media', |
|
60 | + $media, |
|
61 | + 'string' |
|
62 | + ); |
|
63 | + } |
|
64 | + $this->media = $media; |
|
65 | + } |
|
66 | 66 | |
67 | 67 | |
68 | - /** |
|
69 | - * @since $VID:$ |
|
70 | - */ |
|
71 | - public function enqueueAsset() |
|
72 | - { |
|
73 | - wp_enqueue_style($this->handle()); |
|
74 | - } |
|
68 | + /** |
|
69 | + * @since $VID:$ |
|
70 | + */ |
|
71 | + public function enqueueAsset() |
|
72 | + { |
|
73 | + wp_enqueue_style($this->handle()); |
|
74 | + } |
|
75 | 75 | } |
@@ -21,471 +21,471 @@ |
||
21 | 21 | class Collection extends SplObjectStorage implements CollectionInterface |
22 | 22 | { |
23 | 23 | |
24 | - /** |
|
25 | - * a unique string for identifying this collection |
|
26 | - * |
|
27 | - * @type string $collection_identifier |
|
28 | - */ |
|
29 | - protected $collection_identifier; |
|
30 | - |
|
31 | - /** |
|
32 | - * an interface (or class) name to be used for restricting the type of objects added to the storage |
|
33 | - * this should be set from within the child class constructor |
|
34 | - * |
|
35 | - * @type string $interface |
|
36 | - */ |
|
37 | - protected $collection_interface; |
|
38 | - |
|
39 | - |
|
40 | - /** |
|
41 | - * Collection constructor |
|
42 | - * |
|
43 | - * @param string $collection_interface |
|
44 | - * @throws InvalidInterfaceException |
|
45 | - */ |
|
46 | - public function __construct($collection_interface) |
|
47 | - { |
|
48 | - $this->setCollectionInterface($collection_interface); |
|
49 | - $this->setCollectionIdentifier(); |
|
50 | - } |
|
51 | - |
|
52 | - |
|
53 | - /** |
|
54 | - * @return string |
|
55 | - */ |
|
56 | - public function collectionIdentifier() |
|
57 | - { |
|
58 | - return $this->collection_identifier; |
|
59 | - } |
|
60 | - |
|
61 | - |
|
62 | - /** |
|
63 | - * creates a very readable unique 9 character identifier like: CF2-532-DAC |
|
64 | - * and appends it to the non-qualified class name, ex: ThingCollection-CF2-532-DAC |
|
65 | - * |
|
66 | - * @return void |
|
67 | - */ |
|
68 | - protected function setCollectionIdentifier() |
|
69 | - { |
|
70 | - // hash a few collection details |
|
71 | - $identifier = md5(spl_object_hash($this) . $this->collection_interface . time()); |
|
72 | - // grab a few characters from the start, middle, and end of the hash |
|
73 | - $id = array(); |
|
74 | - for ($x = 0; $x < 19; $x += 9) { |
|
75 | - $id[] = substr($identifier, $x, 3); |
|
76 | - } |
|
77 | - $identifier = basename(str_replace('\\', '/', get_class($this))); |
|
78 | - $identifier .= '-' . strtoupper(implode('-', $id)); |
|
79 | - $this->collection_identifier = $identifier; |
|
80 | - } |
|
81 | - |
|
82 | - |
|
83 | - /** |
|
84 | - * setCollectionInterface |
|
85 | - * |
|
86 | - * @access protected |
|
87 | - * @param string $collection_interface |
|
88 | - * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
89 | - */ |
|
90 | - protected function setCollectionInterface($collection_interface) |
|
91 | - { |
|
92 | - if (! (interface_exists($collection_interface) || class_exists($collection_interface))) { |
|
93 | - throw new InvalidInterfaceException($collection_interface); |
|
94 | - } |
|
95 | - $this->collection_interface = $collection_interface; |
|
96 | - } |
|
97 | - |
|
98 | - |
|
99 | - /** |
|
100 | - * add |
|
101 | - * attaches an object to the Collection |
|
102 | - * and sets any supplied data associated with the current iterator entry |
|
103 | - * by calling EE_Object_Collection::set_identifier() |
|
104 | - * |
|
105 | - * @access public |
|
106 | - * @param $object |
|
107 | - * @param mixed $identifier |
|
108 | - * @return bool |
|
109 | - * @throws InvalidEntityException |
|
110 | - * @throws DuplicateCollectionIdentifierException |
|
111 | - */ |
|
112 | - public function add($object, $identifier = null) |
|
113 | - { |
|
114 | - if (! $object instanceof $this->collection_interface) { |
|
115 | - throw new InvalidEntityException($object, $this->collection_interface); |
|
116 | - } |
|
117 | - if ($this->contains($object)) { |
|
118 | - throw new DuplicateCollectionIdentifierException($identifier); |
|
119 | - } |
|
120 | - $this->attach($object); |
|
121 | - $this->setIdentifier($object, $identifier); |
|
122 | - return $this->contains($object); |
|
123 | - } |
|
124 | - |
|
125 | - |
|
126 | - /** |
|
127 | - * setIdentifier |
|
128 | - * Sets the data associated with an object in the Collection |
|
129 | - * if no $identifier is supplied, then the spl_object_hash() is used |
|
130 | - * |
|
131 | - * @access public |
|
132 | - * @param $object |
|
133 | - * @param mixed $identifier |
|
134 | - * @return bool |
|
135 | - */ |
|
136 | - public function setIdentifier($object, $identifier = null) |
|
137 | - { |
|
138 | - $identifier = ! empty($identifier) |
|
139 | - ? $identifier |
|
140 | - : spl_object_hash($object); |
|
141 | - $this->rewind(); |
|
142 | - while ($this->valid()) { |
|
143 | - if ($object === $this->current()) { |
|
144 | - $this->setInfo($identifier); |
|
145 | - $this->rewind(); |
|
146 | - return true; |
|
147 | - } |
|
148 | - $this->next(); |
|
149 | - } |
|
150 | - return false; |
|
151 | - } |
|
152 | - |
|
153 | - |
|
154 | - /** |
|
155 | - * get |
|
156 | - * finds and returns an object in the Collection based on the identifier that was set using addObject() |
|
157 | - * PLZ NOTE: the pointer is reset to the beginning of the collection before returning |
|
158 | - * |
|
159 | - * @access public |
|
160 | - * @param mixed $identifier |
|
161 | - * @return mixed |
|
162 | - */ |
|
163 | - public function get($identifier) |
|
164 | - { |
|
165 | - $this->rewind(); |
|
166 | - while ($this->valid()) { |
|
167 | - if ($identifier === $this->getInfo()) { |
|
168 | - $object = $this->current(); |
|
169 | - $this->rewind(); |
|
170 | - return $object; |
|
171 | - } |
|
172 | - $this->next(); |
|
173 | - } |
|
174 | - return null; |
|
175 | - } |
|
176 | - |
|
177 | - |
|
178 | - /** |
|
179 | - * has |
|
180 | - * returns TRUE or FALSE |
|
181 | - * depending on whether the object is within the Collection |
|
182 | - * based on the supplied $identifier |
|
183 | - * |
|
184 | - * @access public |
|
185 | - * @param mixed $identifier |
|
186 | - * @return bool |
|
187 | - */ |
|
188 | - public function has($identifier) |
|
189 | - { |
|
190 | - $this->rewind(); |
|
191 | - while ($this->valid()) { |
|
192 | - if ($identifier === $this->getInfo()) { |
|
193 | - $this->rewind(); |
|
194 | - return true; |
|
195 | - } |
|
196 | - $this->next(); |
|
197 | - } |
|
198 | - return false; |
|
199 | - } |
|
200 | - |
|
201 | - |
|
202 | - /** |
|
203 | - * hasObject |
|
204 | - * returns TRUE or FALSE depending on whether the supplied object is within the Collection |
|
205 | - * |
|
206 | - * @access public |
|
207 | - * @param $object |
|
208 | - * @return bool |
|
209 | - */ |
|
210 | - public function hasObject($object) |
|
211 | - { |
|
212 | - return $this->contains($object); |
|
213 | - } |
|
214 | - |
|
215 | - |
|
216 | - /** |
|
217 | - * hasObjects |
|
218 | - * returns true if there are objects within the Collection, and false if it is empty |
|
219 | - * |
|
220 | - * @access public |
|
221 | - * @return bool |
|
222 | - */ |
|
223 | - public function hasObjects() |
|
224 | - { |
|
225 | - return $this->count() !== 0; |
|
226 | - } |
|
227 | - |
|
228 | - |
|
229 | - /** |
|
230 | - * isEmpty |
|
231 | - * returns true if there are no objects within the Collection, and false if there are |
|
232 | - * |
|
233 | - * @access public |
|
234 | - * @return bool |
|
235 | - */ |
|
236 | - public function isEmpty() |
|
237 | - { |
|
238 | - return $this->count() === 0; |
|
239 | - } |
|
240 | - |
|
241 | - |
|
242 | - /** |
|
243 | - * remove |
|
244 | - * detaches an object from the Collection |
|
245 | - * |
|
246 | - * @access public |
|
247 | - * @param $object |
|
248 | - * @return bool |
|
249 | - */ |
|
250 | - public function remove($object) |
|
251 | - { |
|
252 | - $this->detach($object); |
|
253 | - return true; |
|
254 | - } |
|
255 | - |
|
256 | - |
|
257 | - /** |
|
258 | - * setCurrent |
|
259 | - * advances pointer to the object whose identifier matches that which was provided |
|
260 | - * |
|
261 | - * @access public |
|
262 | - * @param mixed $identifier |
|
263 | - * @return boolean |
|
264 | - */ |
|
265 | - public function setCurrent($identifier) |
|
266 | - { |
|
267 | - $this->rewind(); |
|
268 | - while ($this->valid()) { |
|
269 | - if ($identifier === $this->getInfo()) { |
|
270 | - return true; |
|
271 | - } |
|
272 | - $this->next(); |
|
273 | - } |
|
274 | - return false; |
|
275 | - } |
|
276 | - |
|
277 | - |
|
278 | - /** |
|
279 | - * setCurrentUsingObject |
|
280 | - * advances pointer to the provided object |
|
281 | - * |
|
282 | - * @access public |
|
283 | - * @param $object |
|
284 | - * @return boolean |
|
285 | - */ |
|
286 | - public function setCurrentUsingObject($object) |
|
287 | - { |
|
288 | - $this->rewind(); |
|
289 | - while ($this->valid()) { |
|
290 | - if ($this->current() === $object) { |
|
291 | - return true; |
|
292 | - } |
|
293 | - $this->next(); |
|
294 | - } |
|
295 | - return false; |
|
296 | - } |
|
297 | - |
|
298 | - |
|
299 | - /** |
|
300 | - * Returns the object occupying the index before the current object, |
|
301 | - * unless this is already the first object, in which case it just returns the first object |
|
302 | - * |
|
303 | - * @return mixed |
|
304 | - */ |
|
305 | - public function previous() |
|
306 | - { |
|
307 | - $index = $this->indexOf($this->current()); |
|
308 | - if ($index === 0) { |
|
309 | - return $this->current(); |
|
310 | - } |
|
311 | - $index--; |
|
312 | - return $this->objectAtIndex($index); |
|
313 | - } |
|
314 | - |
|
315 | - |
|
316 | - /** |
|
317 | - * Returns the index of a given object, or false if not found |
|
318 | - * |
|
319 | - * @see http://stackoverflow.com/a/8736013 |
|
320 | - * @param $object |
|
321 | - * @return boolean|int|string |
|
322 | - */ |
|
323 | - public function indexOf($object) |
|
324 | - { |
|
325 | - if (! $this->contains($object)) { |
|
326 | - return false; |
|
327 | - } |
|
328 | - foreach ($this as $index => $obj) { |
|
329 | - if ($obj === $object) { |
|
330 | - return $index; |
|
331 | - } |
|
332 | - } |
|
333 | - return false; |
|
334 | - } |
|
335 | - |
|
336 | - |
|
337 | - /** |
|
338 | - * Returns the object at the given index |
|
339 | - * |
|
340 | - * @see http://stackoverflow.com/a/8736013 |
|
341 | - * @param int $index |
|
342 | - * @return mixed |
|
343 | - */ |
|
344 | - public function objectAtIndex($index) |
|
345 | - { |
|
346 | - $iterator = new LimitIterator($this, $index, 1); |
|
347 | - $iterator->rewind(); |
|
348 | - return $iterator->current(); |
|
349 | - } |
|
350 | - |
|
351 | - |
|
352 | - /** |
|
353 | - * Returns the sequence of objects as specified by the offset and length |
|
354 | - * |
|
355 | - * @see http://stackoverflow.com/a/8736013 |
|
356 | - * @param int $offset |
|
357 | - * @param int $length |
|
358 | - * @return array |
|
359 | - */ |
|
360 | - public function slice($offset, $length) |
|
361 | - { |
|
362 | - $slice = array(); |
|
363 | - $iterator = new LimitIterator($this, $offset, $length); |
|
364 | - foreach ($iterator as $object) { |
|
365 | - $slice[] = $object; |
|
366 | - } |
|
367 | - return $slice; |
|
368 | - } |
|
369 | - |
|
370 | - |
|
371 | - /** |
|
372 | - * Inserts an object at a certain point |
|
373 | - * |
|
374 | - * @see http://stackoverflow.com/a/8736013 |
|
375 | - * @param mixed $object A single object |
|
376 | - * @param int $index |
|
377 | - * @param mixed $identifier |
|
378 | - * @return bool |
|
379 | - * @throws DuplicateCollectionIdentifierException |
|
380 | - * @throws InvalidEntityException |
|
381 | - */ |
|
382 | - public function insertObjectAt($object, $index, $identifier = null) |
|
383 | - { |
|
384 | - // check to ensure that objects don't already exist in the collection |
|
385 | - if ($this->has($identifier)) { |
|
386 | - throw new DuplicateCollectionIdentifierException($identifier); |
|
387 | - } |
|
388 | - // detach any objects at or past this index |
|
389 | - $remaining_objects = array(); |
|
390 | - if ($index < $this->count()) { |
|
391 | - $remaining_objects = $this->slice($index, $this->count() - $index); |
|
392 | - foreach ($remaining_objects as $key => $remaining_object) { |
|
393 | - // we need to grab the identifiers for each object and use them as keys |
|
394 | - $remaining_objects[ $remaining_object->getInfo() ] = $remaining_object; |
|
395 | - // and then remove the object from the current tracking array |
|
396 | - unset($remaining_objects[ $key ]); |
|
397 | - // and then remove it from the Collection |
|
398 | - $this->detach($remaining_object); |
|
399 | - } |
|
400 | - } |
|
401 | - // add the new object we're splicing in |
|
402 | - $this->add($object, $identifier); |
|
403 | - // attach the objects we previously detached |
|
404 | - foreach ($remaining_objects as $key => $remaining_object) { |
|
405 | - $this->add($remaining_object, $key); |
|
406 | - } |
|
407 | - return $this->contains($object); |
|
408 | - } |
|
409 | - |
|
410 | - |
|
411 | - /** |
|
412 | - * Inserts an object (or an array of objects) at a certain point |
|
413 | - * |
|
414 | - * @see http://stackoverflow.com/a/8736013 |
|
415 | - * @param mixed $objects A single object or an array of objects |
|
416 | - * @param int $index |
|
417 | - */ |
|
418 | - public function insertAt($objects, $index) |
|
419 | - { |
|
420 | - if (! is_array($objects)) { |
|
421 | - $objects = array($objects); |
|
422 | - } |
|
423 | - // check to ensure that objects don't already exist in the collection |
|
424 | - foreach ($objects as $key => $object) { |
|
425 | - if ($this->contains($object)) { |
|
426 | - unset($objects[ $key ]); |
|
427 | - } |
|
428 | - } |
|
429 | - // do we have any objects left? |
|
430 | - if (! $objects) { |
|
431 | - return; |
|
432 | - } |
|
433 | - // detach any objects at or past this index |
|
434 | - $remaining = array(); |
|
435 | - if ($index < $this->count()) { |
|
436 | - $remaining = $this->slice($index, $this->count() - $index); |
|
437 | - foreach ($remaining as $object) { |
|
438 | - $this->detach($object); |
|
439 | - } |
|
440 | - } |
|
441 | - // add the new objects we're splicing in |
|
442 | - foreach ($objects as $object) { |
|
443 | - $this->attach($object); |
|
444 | - } |
|
445 | - // attach the objects we previously detached |
|
446 | - foreach ($remaining as $object) { |
|
447 | - $this->attach($object); |
|
448 | - } |
|
449 | - } |
|
450 | - |
|
451 | - |
|
452 | - /** |
|
453 | - * Removes the object at the given index |
|
454 | - * |
|
455 | - * @see http://stackoverflow.com/a/8736013 |
|
456 | - * @param int $index |
|
457 | - */ |
|
458 | - public function removeAt($index) |
|
459 | - { |
|
460 | - $this->detach($this->objectAtIndex($index)); |
|
461 | - } |
|
462 | - |
|
463 | - |
|
464 | - /** |
|
465 | - * detaches ALL objects from the Collection |
|
466 | - */ |
|
467 | - public function detachAll() |
|
468 | - { |
|
469 | - $this->rewind(); |
|
470 | - while ($this->valid()) { |
|
471 | - $object = $this->current(); |
|
472 | - $this->next(); |
|
473 | - $this->detach($object); |
|
474 | - } |
|
475 | - } |
|
476 | - |
|
477 | - |
|
478 | - /** |
|
479 | - * unsets and detaches ALL objects from the Collection |
|
480 | - */ |
|
481 | - public function trashAndDetachAll() |
|
482 | - { |
|
483 | - $this->rewind(); |
|
484 | - while ($this->valid()) { |
|
485 | - $object = $this->current(); |
|
486 | - $this->next(); |
|
487 | - $this->detach($object); |
|
488 | - unset($object); |
|
489 | - } |
|
490 | - } |
|
24 | + /** |
|
25 | + * a unique string for identifying this collection |
|
26 | + * |
|
27 | + * @type string $collection_identifier |
|
28 | + */ |
|
29 | + protected $collection_identifier; |
|
30 | + |
|
31 | + /** |
|
32 | + * an interface (or class) name to be used for restricting the type of objects added to the storage |
|
33 | + * this should be set from within the child class constructor |
|
34 | + * |
|
35 | + * @type string $interface |
|
36 | + */ |
|
37 | + protected $collection_interface; |
|
38 | + |
|
39 | + |
|
40 | + /** |
|
41 | + * Collection constructor |
|
42 | + * |
|
43 | + * @param string $collection_interface |
|
44 | + * @throws InvalidInterfaceException |
|
45 | + */ |
|
46 | + public function __construct($collection_interface) |
|
47 | + { |
|
48 | + $this->setCollectionInterface($collection_interface); |
|
49 | + $this->setCollectionIdentifier(); |
|
50 | + } |
|
51 | + |
|
52 | + |
|
53 | + /** |
|
54 | + * @return string |
|
55 | + */ |
|
56 | + public function collectionIdentifier() |
|
57 | + { |
|
58 | + return $this->collection_identifier; |
|
59 | + } |
|
60 | + |
|
61 | + |
|
62 | + /** |
|
63 | + * creates a very readable unique 9 character identifier like: CF2-532-DAC |
|
64 | + * and appends it to the non-qualified class name, ex: ThingCollection-CF2-532-DAC |
|
65 | + * |
|
66 | + * @return void |
|
67 | + */ |
|
68 | + protected function setCollectionIdentifier() |
|
69 | + { |
|
70 | + // hash a few collection details |
|
71 | + $identifier = md5(spl_object_hash($this) . $this->collection_interface . time()); |
|
72 | + // grab a few characters from the start, middle, and end of the hash |
|
73 | + $id = array(); |
|
74 | + for ($x = 0; $x < 19; $x += 9) { |
|
75 | + $id[] = substr($identifier, $x, 3); |
|
76 | + } |
|
77 | + $identifier = basename(str_replace('\\', '/', get_class($this))); |
|
78 | + $identifier .= '-' . strtoupper(implode('-', $id)); |
|
79 | + $this->collection_identifier = $identifier; |
|
80 | + } |
|
81 | + |
|
82 | + |
|
83 | + /** |
|
84 | + * setCollectionInterface |
|
85 | + * |
|
86 | + * @access protected |
|
87 | + * @param string $collection_interface |
|
88 | + * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
89 | + */ |
|
90 | + protected function setCollectionInterface($collection_interface) |
|
91 | + { |
|
92 | + if (! (interface_exists($collection_interface) || class_exists($collection_interface))) { |
|
93 | + throw new InvalidInterfaceException($collection_interface); |
|
94 | + } |
|
95 | + $this->collection_interface = $collection_interface; |
|
96 | + } |
|
97 | + |
|
98 | + |
|
99 | + /** |
|
100 | + * add |
|
101 | + * attaches an object to the Collection |
|
102 | + * and sets any supplied data associated with the current iterator entry |
|
103 | + * by calling EE_Object_Collection::set_identifier() |
|
104 | + * |
|
105 | + * @access public |
|
106 | + * @param $object |
|
107 | + * @param mixed $identifier |
|
108 | + * @return bool |
|
109 | + * @throws InvalidEntityException |
|
110 | + * @throws DuplicateCollectionIdentifierException |
|
111 | + */ |
|
112 | + public function add($object, $identifier = null) |
|
113 | + { |
|
114 | + if (! $object instanceof $this->collection_interface) { |
|
115 | + throw new InvalidEntityException($object, $this->collection_interface); |
|
116 | + } |
|
117 | + if ($this->contains($object)) { |
|
118 | + throw new DuplicateCollectionIdentifierException($identifier); |
|
119 | + } |
|
120 | + $this->attach($object); |
|
121 | + $this->setIdentifier($object, $identifier); |
|
122 | + return $this->contains($object); |
|
123 | + } |
|
124 | + |
|
125 | + |
|
126 | + /** |
|
127 | + * setIdentifier |
|
128 | + * Sets the data associated with an object in the Collection |
|
129 | + * if no $identifier is supplied, then the spl_object_hash() is used |
|
130 | + * |
|
131 | + * @access public |
|
132 | + * @param $object |
|
133 | + * @param mixed $identifier |
|
134 | + * @return bool |
|
135 | + */ |
|
136 | + public function setIdentifier($object, $identifier = null) |
|
137 | + { |
|
138 | + $identifier = ! empty($identifier) |
|
139 | + ? $identifier |
|
140 | + : spl_object_hash($object); |
|
141 | + $this->rewind(); |
|
142 | + while ($this->valid()) { |
|
143 | + if ($object === $this->current()) { |
|
144 | + $this->setInfo($identifier); |
|
145 | + $this->rewind(); |
|
146 | + return true; |
|
147 | + } |
|
148 | + $this->next(); |
|
149 | + } |
|
150 | + return false; |
|
151 | + } |
|
152 | + |
|
153 | + |
|
154 | + /** |
|
155 | + * get |
|
156 | + * finds and returns an object in the Collection based on the identifier that was set using addObject() |
|
157 | + * PLZ NOTE: the pointer is reset to the beginning of the collection before returning |
|
158 | + * |
|
159 | + * @access public |
|
160 | + * @param mixed $identifier |
|
161 | + * @return mixed |
|
162 | + */ |
|
163 | + public function get($identifier) |
|
164 | + { |
|
165 | + $this->rewind(); |
|
166 | + while ($this->valid()) { |
|
167 | + if ($identifier === $this->getInfo()) { |
|
168 | + $object = $this->current(); |
|
169 | + $this->rewind(); |
|
170 | + return $object; |
|
171 | + } |
|
172 | + $this->next(); |
|
173 | + } |
|
174 | + return null; |
|
175 | + } |
|
176 | + |
|
177 | + |
|
178 | + /** |
|
179 | + * has |
|
180 | + * returns TRUE or FALSE |
|
181 | + * depending on whether the object is within the Collection |
|
182 | + * based on the supplied $identifier |
|
183 | + * |
|
184 | + * @access public |
|
185 | + * @param mixed $identifier |
|
186 | + * @return bool |
|
187 | + */ |
|
188 | + public function has($identifier) |
|
189 | + { |
|
190 | + $this->rewind(); |
|
191 | + while ($this->valid()) { |
|
192 | + if ($identifier === $this->getInfo()) { |
|
193 | + $this->rewind(); |
|
194 | + return true; |
|
195 | + } |
|
196 | + $this->next(); |
|
197 | + } |
|
198 | + return false; |
|
199 | + } |
|
200 | + |
|
201 | + |
|
202 | + /** |
|
203 | + * hasObject |
|
204 | + * returns TRUE or FALSE depending on whether the supplied object is within the Collection |
|
205 | + * |
|
206 | + * @access public |
|
207 | + * @param $object |
|
208 | + * @return bool |
|
209 | + */ |
|
210 | + public function hasObject($object) |
|
211 | + { |
|
212 | + return $this->contains($object); |
|
213 | + } |
|
214 | + |
|
215 | + |
|
216 | + /** |
|
217 | + * hasObjects |
|
218 | + * returns true if there are objects within the Collection, and false if it is empty |
|
219 | + * |
|
220 | + * @access public |
|
221 | + * @return bool |
|
222 | + */ |
|
223 | + public function hasObjects() |
|
224 | + { |
|
225 | + return $this->count() !== 0; |
|
226 | + } |
|
227 | + |
|
228 | + |
|
229 | + /** |
|
230 | + * isEmpty |
|
231 | + * returns true if there are no objects within the Collection, and false if there are |
|
232 | + * |
|
233 | + * @access public |
|
234 | + * @return bool |
|
235 | + */ |
|
236 | + public function isEmpty() |
|
237 | + { |
|
238 | + return $this->count() === 0; |
|
239 | + } |
|
240 | + |
|
241 | + |
|
242 | + /** |
|
243 | + * remove |
|
244 | + * detaches an object from the Collection |
|
245 | + * |
|
246 | + * @access public |
|
247 | + * @param $object |
|
248 | + * @return bool |
|
249 | + */ |
|
250 | + public function remove($object) |
|
251 | + { |
|
252 | + $this->detach($object); |
|
253 | + return true; |
|
254 | + } |
|
255 | + |
|
256 | + |
|
257 | + /** |
|
258 | + * setCurrent |
|
259 | + * advances pointer to the object whose identifier matches that which was provided |
|
260 | + * |
|
261 | + * @access public |
|
262 | + * @param mixed $identifier |
|
263 | + * @return boolean |
|
264 | + */ |
|
265 | + public function setCurrent($identifier) |
|
266 | + { |
|
267 | + $this->rewind(); |
|
268 | + while ($this->valid()) { |
|
269 | + if ($identifier === $this->getInfo()) { |
|
270 | + return true; |
|
271 | + } |
|
272 | + $this->next(); |
|
273 | + } |
|
274 | + return false; |
|
275 | + } |
|
276 | + |
|
277 | + |
|
278 | + /** |
|
279 | + * setCurrentUsingObject |
|
280 | + * advances pointer to the provided object |
|
281 | + * |
|
282 | + * @access public |
|
283 | + * @param $object |
|
284 | + * @return boolean |
|
285 | + */ |
|
286 | + public function setCurrentUsingObject($object) |
|
287 | + { |
|
288 | + $this->rewind(); |
|
289 | + while ($this->valid()) { |
|
290 | + if ($this->current() === $object) { |
|
291 | + return true; |
|
292 | + } |
|
293 | + $this->next(); |
|
294 | + } |
|
295 | + return false; |
|
296 | + } |
|
297 | + |
|
298 | + |
|
299 | + /** |
|
300 | + * Returns the object occupying the index before the current object, |
|
301 | + * unless this is already the first object, in which case it just returns the first object |
|
302 | + * |
|
303 | + * @return mixed |
|
304 | + */ |
|
305 | + public function previous() |
|
306 | + { |
|
307 | + $index = $this->indexOf($this->current()); |
|
308 | + if ($index === 0) { |
|
309 | + return $this->current(); |
|
310 | + } |
|
311 | + $index--; |
|
312 | + return $this->objectAtIndex($index); |
|
313 | + } |
|
314 | + |
|
315 | + |
|
316 | + /** |
|
317 | + * Returns the index of a given object, or false if not found |
|
318 | + * |
|
319 | + * @see http://stackoverflow.com/a/8736013 |
|
320 | + * @param $object |
|
321 | + * @return boolean|int|string |
|
322 | + */ |
|
323 | + public function indexOf($object) |
|
324 | + { |
|
325 | + if (! $this->contains($object)) { |
|
326 | + return false; |
|
327 | + } |
|
328 | + foreach ($this as $index => $obj) { |
|
329 | + if ($obj === $object) { |
|
330 | + return $index; |
|
331 | + } |
|
332 | + } |
|
333 | + return false; |
|
334 | + } |
|
335 | + |
|
336 | + |
|
337 | + /** |
|
338 | + * Returns the object at the given index |
|
339 | + * |
|
340 | + * @see http://stackoverflow.com/a/8736013 |
|
341 | + * @param int $index |
|
342 | + * @return mixed |
|
343 | + */ |
|
344 | + public function objectAtIndex($index) |
|
345 | + { |
|
346 | + $iterator = new LimitIterator($this, $index, 1); |
|
347 | + $iterator->rewind(); |
|
348 | + return $iterator->current(); |
|
349 | + } |
|
350 | + |
|
351 | + |
|
352 | + /** |
|
353 | + * Returns the sequence of objects as specified by the offset and length |
|
354 | + * |
|
355 | + * @see http://stackoverflow.com/a/8736013 |
|
356 | + * @param int $offset |
|
357 | + * @param int $length |
|
358 | + * @return array |
|
359 | + */ |
|
360 | + public function slice($offset, $length) |
|
361 | + { |
|
362 | + $slice = array(); |
|
363 | + $iterator = new LimitIterator($this, $offset, $length); |
|
364 | + foreach ($iterator as $object) { |
|
365 | + $slice[] = $object; |
|
366 | + } |
|
367 | + return $slice; |
|
368 | + } |
|
369 | + |
|
370 | + |
|
371 | + /** |
|
372 | + * Inserts an object at a certain point |
|
373 | + * |
|
374 | + * @see http://stackoverflow.com/a/8736013 |
|
375 | + * @param mixed $object A single object |
|
376 | + * @param int $index |
|
377 | + * @param mixed $identifier |
|
378 | + * @return bool |
|
379 | + * @throws DuplicateCollectionIdentifierException |
|
380 | + * @throws InvalidEntityException |
|
381 | + */ |
|
382 | + public function insertObjectAt($object, $index, $identifier = null) |
|
383 | + { |
|
384 | + // check to ensure that objects don't already exist in the collection |
|
385 | + if ($this->has($identifier)) { |
|
386 | + throw new DuplicateCollectionIdentifierException($identifier); |
|
387 | + } |
|
388 | + // detach any objects at or past this index |
|
389 | + $remaining_objects = array(); |
|
390 | + if ($index < $this->count()) { |
|
391 | + $remaining_objects = $this->slice($index, $this->count() - $index); |
|
392 | + foreach ($remaining_objects as $key => $remaining_object) { |
|
393 | + // we need to grab the identifiers for each object and use them as keys |
|
394 | + $remaining_objects[ $remaining_object->getInfo() ] = $remaining_object; |
|
395 | + // and then remove the object from the current tracking array |
|
396 | + unset($remaining_objects[ $key ]); |
|
397 | + // and then remove it from the Collection |
|
398 | + $this->detach($remaining_object); |
|
399 | + } |
|
400 | + } |
|
401 | + // add the new object we're splicing in |
|
402 | + $this->add($object, $identifier); |
|
403 | + // attach the objects we previously detached |
|
404 | + foreach ($remaining_objects as $key => $remaining_object) { |
|
405 | + $this->add($remaining_object, $key); |
|
406 | + } |
|
407 | + return $this->contains($object); |
|
408 | + } |
|
409 | + |
|
410 | + |
|
411 | + /** |
|
412 | + * Inserts an object (or an array of objects) at a certain point |
|
413 | + * |
|
414 | + * @see http://stackoverflow.com/a/8736013 |
|
415 | + * @param mixed $objects A single object or an array of objects |
|
416 | + * @param int $index |
|
417 | + */ |
|
418 | + public function insertAt($objects, $index) |
|
419 | + { |
|
420 | + if (! is_array($objects)) { |
|
421 | + $objects = array($objects); |
|
422 | + } |
|
423 | + // check to ensure that objects don't already exist in the collection |
|
424 | + foreach ($objects as $key => $object) { |
|
425 | + if ($this->contains($object)) { |
|
426 | + unset($objects[ $key ]); |
|
427 | + } |
|
428 | + } |
|
429 | + // do we have any objects left? |
|
430 | + if (! $objects) { |
|
431 | + return; |
|
432 | + } |
|
433 | + // detach any objects at or past this index |
|
434 | + $remaining = array(); |
|
435 | + if ($index < $this->count()) { |
|
436 | + $remaining = $this->slice($index, $this->count() - $index); |
|
437 | + foreach ($remaining as $object) { |
|
438 | + $this->detach($object); |
|
439 | + } |
|
440 | + } |
|
441 | + // add the new objects we're splicing in |
|
442 | + foreach ($objects as $object) { |
|
443 | + $this->attach($object); |
|
444 | + } |
|
445 | + // attach the objects we previously detached |
|
446 | + foreach ($remaining as $object) { |
|
447 | + $this->attach($object); |
|
448 | + } |
|
449 | + } |
|
450 | + |
|
451 | + |
|
452 | + /** |
|
453 | + * Removes the object at the given index |
|
454 | + * |
|
455 | + * @see http://stackoverflow.com/a/8736013 |
|
456 | + * @param int $index |
|
457 | + */ |
|
458 | + public function removeAt($index) |
|
459 | + { |
|
460 | + $this->detach($this->objectAtIndex($index)); |
|
461 | + } |
|
462 | + |
|
463 | + |
|
464 | + /** |
|
465 | + * detaches ALL objects from the Collection |
|
466 | + */ |
|
467 | + public function detachAll() |
|
468 | + { |
|
469 | + $this->rewind(); |
|
470 | + while ($this->valid()) { |
|
471 | + $object = $this->current(); |
|
472 | + $this->next(); |
|
473 | + $this->detach($object); |
|
474 | + } |
|
475 | + } |
|
476 | + |
|
477 | + |
|
478 | + /** |
|
479 | + * unsets and detaches ALL objects from the Collection |
|
480 | + */ |
|
481 | + public function trashAndDetachAll() |
|
482 | + { |
|
483 | + $this->rewind(); |
|
484 | + while ($this->valid()) { |
|
485 | + $object = $this->current(); |
|
486 | + $this->next(); |
|
487 | + $this->detach($object); |
|
488 | + unset($object); |
|
489 | + } |
|
490 | + } |
|
491 | 491 | } |
@@ -68,14 +68,14 @@ discard block |
||
68 | 68 | protected function setCollectionIdentifier() |
69 | 69 | { |
70 | 70 | // hash a few collection details |
71 | - $identifier = md5(spl_object_hash($this) . $this->collection_interface . time()); |
|
71 | + $identifier = md5(spl_object_hash($this).$this->collection_interface.time()); |
|
72 | 72 | // grab a few characters from the start, middle, and end of the hash |
73 | 73 | $id = array(); |
74 | 74 | for ($x = 0; $x < 19; $x += 9) { |
75 | 75 | $id[] = substr($identifier, $x, 3); |
76 | 76 | } |
77 | 77 | $identifier = basename(str_replace('\\', '/', get_class($this))); |
78 | - $identifier .= '-' . strtoupper(implode('-', $id)); |
|
78 | + $identifier .= '-'.strtoupper(implode('-', $id)); |
|
79 | 79 | $this->collection_identifier = $identifier; |
80 | 80 | } |
81 | 81 | |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | */ |
90 | 90 | protected function setCollectionInterface($collection_interface) |
91 | 91 | { |
92 | - if (! (interface_exists($collection_interface) || class_exists($collection_interface))) { |
|
92 | + if ( ! (interface_exists($collection_interface) || class_exists($collection_interface))) { |
|
93 | 93 | throw new InvalidInterfaceException($collection_interface); |
94 | 94 | } |
95 | 95 | $this->collection_interface = $collection_interface; |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | */ |
112 | 112 | public function add($object, $identifier = null) |
113 | 113 | { |
114 | - if (! $object instanceof $this->collection_interface) { |
|
114 | + if ( ! $object instanceof $this->collection_interface) { |
|
115 | 115 | throw new InvalidEntityException($object, $this->collection_interface); |
116 | 116 | } |
117 | 117 | if ($this->contains($object)) { |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | */ |
323 | 323 | public function indexOf($object) |
324 | 324 | { |
325 | - if (! $this->contains($object)) { |
|
325 | + if ( ! $this->contains($object)) { |
|
326 | 326 | return false; |
327 | 327 | } |
328 | 328 | foreach ($this as $index => $obj) { |
@@ -391,9 +391,9 @@ discard block |
||
391 | 391 | $remaining_objects = $this->slice($index, $this->count() - $index); |
392 | 392 | foreach ($remaining_objects as $key => $remaining_object) { |
393 | 393 | // we need to grab the identifiers for each object and use them as keys |
394 | - $remaining_objects[ $remaining_object->getInfo() ] = $remaining_object; |
|
394 | + $remaining_objects[$remaining_object->getInfo()] = $remaining_object; |
|
395 | 395 | // and then remove the object from the current tracking array |
396 | - unset($remaining_objects[ $key ]); |
|
396 | + unset($remaining_objects[$key]); |
|
397 | 397 | // and then remove it from the Collection |
398 | 398 | $this->detach($remaining_object); |
399 | 399 | } |
@@ -417,17 +417,17 @@ discard block |
||
417 | 417 | */ |
418 | 418 | public function insertAt($objects, $index) |
419 | 419 | { |
420 | - if (! is_array($objects)) { |
|
420 | + if ( ! is_array($objects)) { |
|
421 | 421 | $objects = array($objects); |
422 | 422 | } |
423 | 423 | // check to ensure that objects don't already exist in the collection |
424 | 424 | foreach ($objects as $key => $object) { |
425 | 425 | if ($this->contains($object)) { |
426 | - unset($objects[ $key ]); |
|
426 | + unset($objects[$key]); |
|
427 | 427 | } |
428 | 428 | } |
429 | 429 | // do we have any objects left? |
430 | - if (! $objects) { |
|
430 | + if ( ! $objects) { |
|
431 | 431 | return; |
432 | 432 | } |
433 | 433 | // detach any objects at or past this index |
@@ -16,24 +16,24 @@ |
||
16 | 16 | */ |
17 | 17 | class AssetRegistrationException extends RuntimeException |
18 | 18 | { |
19 | - /** |
|
20 | - * @param $script_handle |
|
21 | - * @param string $message |
|
22 | - * @param int $code |
|
23 | - * @param Exception|null $previous |
|
24 | - */ |
|
25 | - public function __construct($script_handle, $message = '', $code = 0, Exception $previous = null) |
|
26 | - { |
|
27 | - if (empty($message)) { |
|
28 | - $message = sprintf( |
|
29 | - esc_html_x( |
|
30 | - 'The "%1$s" script could not be registered with WordPress core.', |
|
31 | - 'The "script-handle" script could not be registered with WordPress core.', |
|
32 | - 'event_espresso' |
|
33 | - ), |
|
34 | - $script_handle |
|
35 | - ); |
|
36 | - } |
|
37 | - parent::__construct($message, $code, $previous); |
|
38 | - } |
|
19 | + /** |
|
20 | + * @param $script_handle |
|
21 | + * @param string $message |
|
22 | + * @param int $code |
|
23 | + * @param Exception|null $previous |
|
24 | + */ |
|
25 | + public function __construct($script_handle, $message = '', $code = 0, Exception $previous = null) |
|
26 | + { |
|
27 | + if (empty($message)) { |
|
28 | + $message = sprintf( |
|
29 | + esc_html_x( |
|
30 | + 'The "%1$s" script could not be registered with WordPress core.', |
|
31 | + 'The "script-handle" script could not be registered with WordPress core.', |
|
32 | + 'event_espresso' |
|
33 | + ), |
|
34 | + $script_handle |
|
35 | + ); |
|
36 | + } |
|
37 | + parent::__construct($message, $code, $previous); |
|
38 | + } |
|
39 | 39 | } |
40 | 40 | \ No newline at end of file |
@@ -16,20 +16,20 @@ |
||
16 | 16 | interface PrivacyPolicyInterface |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * Returns the translated name to display in this privacy policy's section's title |
|
21 | - * |
|
22 | - * @return string |
|
23 | - */ |
|
24 | - public function getName(); |
|
19 | + /** |
|
20 | + * Returns the translated name to display in this privacy policy's section's title |
|
21 | + * |
|
22 | + * @return string |
|
23 | + */ |
|
24 | + public function getName(); |
|
25 | 25 | |
26 | 26 | |
27 | - /** |
|
28 | - * Returns the suggested privacy policy content for this plugin. May contain HTML |
|
29 | - * |
|
30 | - * @return string |
|
31 | - */ |
|
32 | - public function getContent(); |
|
27 | + /** |
|
28 | + * Returns the suggested privacy policy content for this plugin. May contain HTML |
|
29 | + * |
|
30 | + * @return string |
|
31 | + */ |
|
32 | + public function getContent(); |
|
33 | 33 | } |
34 | 34 | // End of file PrivacyPolicyInterface.php |
35 | 35 | // Location: EventEspresso\core\domain\services\admin/PrivacyPolicyInterface.php |
@@ -4,7 +4,6 @@ |
||
4 | 4 | |
5 | 5 | use EE_Registration; |
6 | 6 | use EE_Ticket; |
7 | -use EEM_Answer; |
|
8 | 7 | use EEM_Registration; |
9 | 8 | use EventEspresso\core\services\privacy\export\PersonalDataExporterInterface; |
10 | 9 |
@@ -18,133 +18,133 @@ |
||
18 | 18 | */ |
19 | 19 | class ExportRegistration implements PersonalDataExporterInterface |
20 | 20 | { |
21 | - /** |
|
22 | - * @var EEM_Registration |
|
23 | - */ |
|
24 | - protected $registration_model; |
|
21 | + /** |
|
22 | + * @var EEM_Registration |
|
23 | + */ |
|
24 | + protected $registration_model; |
|
25 | 25 | |
26 | - /** |
|
27 | - * ExportRegistration constructor. |
|
28 | - * |
|
29 | - * @param EEM_Registration $registration_model |
|
30 | - */ |
|
31 | - public function __construct(EEM_Registration $registration_model) |
|
32 | - { |
|
33 | - $this->registration_model = $registration_model; |
|
34 | - } |
|
26 | + /** |
|
27 | + * ExportRegistration constructor. |
|
28 | + * |
|
29 | + * @param EEM_Registration $registration_model |
|
30 | + */ |
|
31 | + public function __construct(EEM_Registration $registration_model) |
|
32 | + { |
|
33 | + $this->registration_model = $registration_model; |
|
34 | + } |
|
35 | 35 | |
36 | 36 | |
37 | - /** |
|
38 | - * Returns data for export. |
|
39 | - * |
|
40 | - * @param string $email_address , |
|
41 | - * @param int $page starts at 1, not 0 |
|
42 | - * @return array { |
|
43 | - * @type array $data { |
|
44 | - * @type array { |
|
45 | - * @type string $group_id (not translated, same for all exports) |
|
46 | - * @type string $group_label (translated string) |
|
47 | - * @type string|int $item_id |
|
48 | - * @type array $data { |
|
49 | - * @type array { |
|
50 | - * @type string $name what's shown in the left-column of the export row |
|
51 | - * @type string $value what's showin the right-column of the export row |
|
52 | - * } |
|
53 | - * } |
|
54 | - * } |
|
55 | - * } |
|
56 | - * } |
|
57 | - */ |
|
58 | - public function export($email_address, $page = 1) |
|
59 | - { |
|
60 | - $page_size = 10; |
|
61 | - $registrations = $this->registration_model->get_all( |
|
62 | - array( |
|
63 | - array( |
|
64 | - 'Attendee.ATT_email' => $email_address, |
|
65 | - ), |
|
66 | - 'limit' => array( |
|
67 | - ($page - 1) * $page_size, |
|
68 | - $page_size, |
|
69 | - ), |
|
70 | - ) |
|
71 | - ); |
|
72 | - $export_fields = array_intersect_key( |
|
73 | - $this->registration_model->field_settings(), |
|
74 | - array_flip( |
|
75 | - array( |
|
76 | - 'REG_code', |
|
77 | - 'REG_date', |
|
78 | - 'REG_final_price', |
|
79 | - 'REG_paid', |
|
80 | - 'REG_url_link', |
|
81 | - 'REG_count', |
|
82 | - 'REG_group_size', |
|
83 | - 'REG_att_is_going', |
|
84 | - ) |
|
85 | - ) |
|
86 | - ); |
|
87 | - $export_items = array(); |
|
88 | - $found_something = false; |
|
89 | - foreach ($registrations as $registration) { |
|
90 | - /** |
|
91 | - * @var $registration EE_Registration |
|
92 | - */ |
|
93 | - $found_something = true; |
|
94 | - $data = array(); |
|
95 | - foreach ($export_fields as $field_name => $field_obj) { |
|
96 | - $data[] = array( |
|
97 | - 'name' => $field_obj->get_nicename(), |
|
98 | - 'value' => $registration->get_pretty($field_name), |
|
99 | - ); |
|
100 | - } |
|
101 | - $answers = $registration->answers( |
|
102 | - array( |
|
103 | - 'force_join' => array( |
|
104 | - 'Question', |
|
105 | - ), |
|
106 | - ) |
|
107 | - ); |
|
108 | - foreach ($answers as $answer) { |
|
109 | - $data[] = array( |
|
110 | - 'name' => $answer->question()->display_text(), |
|
111 | - 'value' => $answer->pretty_value(), |
|
112 | - ); |
|
113 | - } |
|
114 | - $ticket = $registration->ticket(); |
|
115 | - if ($ticket instanceof EE_Ticket) { |
|
116 | - $data[] = array( |
|
117 | - 'name' => esc_html__('Ticket', 'event_espresso'), |
|
118 | - 'value' => $ticket->name_and_info(), |
|
119 | - ); |
|
120 | - $data[] = array( |
|
121 | - 'name' => esc_html__('Event', 'event_espresso'), |
|
122 | - 'value' => $ticket->get_event_name(), |
|
123 | - ); |
|
124 | - } |
|
37 | + /** |
|
38 | + * Returns data for export. |
|
39 | + * |
|
40 | + * @param string $email_address , |
|
41 | + * @param int $page starts at 1, not 0 |
|
42 | + * @return array { |
|
43 | + * @type array $data { |
|
44 | + * @type array { |
|
45 | + * @type string $group_id (not translated, same for all exports) |
|
46 | + * @type string $group_label (translated string) |
|
47 | + * @type string|int $item_id |
|
48 | + * @type array $data { |
|
49 | + * @type array { |
|
50 | + * @type string $name what's shown in the left-column of the export row |
|
51 | + * @type string $value what's showin the right-column of the export row |
|
52 | + * } |
|
53 | + * } |
|
54 | + * } |
|
55 | + * } |
|
56 | + * } |
|
57 | + */ |
|
58 | + public function export($email_address, $page = 1) |
|
59 | + { |
|
60 | + $page_size = 10; |
|
61 | + $registrations = $this->registration_model->get_all( |
|
62 | + array( |
|
63 | + array( |
|
64 | + 'Attendee.ATT_email' => $email_address, |
|
65 | + ), |
|
66 | + 'limit' => array( |
|
67 | + ($page - 1) * $page_size, |
|
68 | + $page_size, |
|
69 | + ), |
|
70 | + ) |
|
71 | + ); |
|
72 | + $export_fields = array_intersect_key( |
|
73 | + $this->registration_model->field_settings(), |
|
74 | + array_flip( |
|
75 | + array( |
|
76 | + 'REG_code', |
|
77 | + 'REG_date', |
|
78 | + 'REG_final_price', |
|
79 | + 'REG_paid', |
|
80 | + 'REG_url_link', |
|
81 | + 'REG_count', |
|
82 | + 'REG_group_size', |
|
83 | + 'REG_att_is_going', |
|
84 | + ) |
|
85 | + ) |
|
86 | + ); |
|
87 | + $export_items = array(); |
|
88 | + $found_something = false; |
|
89 | + foreach ($registrations as $registration) { |
|
90 | + /** |
|
91 | + * @var $registration EE_Registration |
|
92 | + */ |
|
93 | + $found_something = true; |
|
94 | + $data = array(); |
|
95 | + foreach ($export_fields as $field_name => $field_obj) { |
|
96 | + $data[] = array( |
|
97 | + 'name' => $field_obj->get_nicename(), |
|
98 | + 'value' => $registration->get_pretty($field_name), |
|
99 | + ); |
|
100 | + } |
|
101 | + $answers = $registration->answers( |
|
102 | + array( |
|
103 | + 'force_join' => array( |
|
104 | + 'Question', |
|
105 | + ), |
|
106 | + ) |
|
107 | + ); |
|
108 | + foreach ($answers as $answer) { |
|
109 | + $data[] = array( |
|
110 | + 'name' => $answer->question()->display_text(), |
|
111 | + 'value' => $answer->pretty_value(), |
|
112 | + ); |
|
113 | + } |
|
114 | + $ticket = $registration->ticket(); |
|
115 | + if ($ticket instanceof EE_Ticket) { |
|
116 | + $data[] = array( |
|
117 | + 'name' => esc_html__('Ticket', 'event_espresso'), |
|
118 | + 'value' => $ticket->name_and_info(), |
|
119 | + ); |
|
120 | + $data[] = array( |
|
121 | + 'name' => esc_html__('Event', 'event_espresso'), |
|
122 | + 'value' => $ticket->get_event_name(), |
|
123 | + ); |
|
124 | + } |
|
125 | 125 | |
126 | - $export_items[] = array( |
|
127 | - 'group_id' => 'registration', |
|
128 | - 'group_label' => esc_html__('Event Registrations', 'event_espresso'), |
|
129 | - 'item_id' => $registration->ID(), |
|
130 | - 'data' => $data, |
|
131 | - ); |
|
132 | - } |
|
133 | - return array( |
|
134 | - 'data' => $export_items, |
|
135 | - 'done' => ! $found_something, |
|
136 | - ); |
|
137 | - } |
|
126 | + $export_items[] = array( |
|
127 | + 'group_id' => 'registration', |
|
128 | + 'group_label' => esc_html__('Event Registrations', 'event_espresso'), |
|
129 | + 'item_id' => $registration->ID(), |
|
130 | + 'data' => $data, |
|
131 | + ); |
|
132 | + } |
|
133 | + return array( |
|
134 | + 'data' => $export_items, |
|
135 | + 'done' => ! $found_something, |
|
136 | + ); |
|
137 | + } |
|
138 | 138 | |
139 | - /** |
|
140 | - * Gets the Translated name of this exporter |
|
141 | - * |
|
142 | - * @return string |
|
143 | - */ |
|
144 | - public function name() |
|
145 | - { |
|
146 | - return esc_html__('Event Espresso Registration Data Exporter', 'event_espresso'); |
|
147 | - } |
|
139 | + /** |
|
140 | + * Gets the Translated name of this exporter |
|
141 | + * |
|
142 | + * @return string |
|
143 | + */ |
|
144 | + public function name() |
|
145 | + { |
|
146 | + return esc_html__('Event Espresso Registration Data Exporter', 'event_espresso'); |
|
147 | + } |
|
148 | 148 | } |
149 | 149 | // End of file ExportRegistration.php |
150 | 150 | // Location: EventEspresso\core\domain\services\admin\privacy\export/ExportRegistration.php |
@@ -15,106 +15,106 @@ |
||
15 | 15 | */ |
16 | 16 | class ExportTransaction implements PersonalDataExporterInterface |
17 | 17 | { |
18 | - /** |
|
19 | - * @var EEM_Transaction $transaction_model |
|
20 | - */ |
|
21 | - protected $transaction_model; |
|
18 | + /** |
|
19 | + * @var EEM_Transaction $transaction_model |
|
20 | + */ |
|
21 | + protected $transaction_model; |
|
22 | 22 | |
23 | - /** |
|
24 | - * ExportTransaction constructor. |
|
25 | - * |
|
26 | - * @param $transaction_model |
|
27 | - */ |
|
28 | - public function __construct(EEM_Transaction $transaction_model) |
|
29 | - { |
|
30 | - $this->transaction_model = $transaction_model; |
|
31 | - } |
|
23 | + /** |
|
24 | + * ExportTransaction constructor. |
|
25 | + * |
|
26 | + * @param $transaction_model |
|
27 | + */ |
|
28 | + public function __construct(EEM_Transaction $transaction_model) |
|
29 | + { |
|
30 | + $this->transaction_model = $transaction_model; |
|
31 | + } |
|
32 | 32 | |
33 | 33 | |
34 | - /** |
|
35 | - * Returns data for export. |
|
36 | - * |
|
37 | - * @param string $email_address , |
|
38 | - * @param int $page starts at 1, not 0 |
|
39 | - * @return array { |
|
40 | - * @type array $data { |
|
41 | - * @type array { |
|
42 | - * @type string $group_id (not translated, same for all exports) |
|
43 | - * @type string $group_label (translated string) |
|
44 | - * @type string|int $item_id |
|
45 | - * @type array $data { |
|
46 | - * @type array { |
|
47 | - * @type string $name what's shown in the left-column of the export row |
|
48 | - * @type string $value what's showin the right-column of the export row |
|
49 | - * } |
|
50 | - * } |
|
51 | - * } |
|
52 | - * } |
|
53 | - * } |
|
54 | - */ |
|
55 | - public function export($email_address, $page = 1) |
|
56 | - { |
|
57 | - $page_size = 10; |
|
58 | - $transactions = $this->transaction_model->get_all( |
|
59 | - array( |
|
60 | - array( |
|
61 | - 'Registration.Attendee.ATT_email' => $email_address, |
|
62 | - ), |
|
63 | - 'limit' => array( |
|
64 | - ($page - 1) * $page_size, |
|
65 | - $page_size, |
|
66 | - ), |
|
67 | - ) |
|
68 | - ); |
|
69 | - $export_fields = array_intersect_key( |
|
70 | - EEM_Transaction::instance()->field_settings(), |
|
71 | - array_flip( |
|
72 | - array( |
|
73 | - 'TXN_timestamp', |
|
74 | - 'TXN_total', |
|
75 | - 'TXN_paid', |
|
76 | - 'TXN_session_data', |
|
77 | - ) |
|
78 | - ) |
|
79 | - ); |
|
80 | - $export_items = array(); |
|
81 | - $found_something = false; |
|
82 | - foreach ($transactions as $transaction) { |
|
83 | - $found_something = true; |
|
84 | - $data = array(); |
|
85 | - foreach ($export_fields as $field_name => $field_obj) { |
|
86 | - if ($field_name === 'TXN_session_data') { |
|
87 | - $value = $transaction->get_pretty($field_name, 'print_r'); |
|
88 | - } else { |
|
89 | - $value = $transaction->get_pretty($field_name); |
|
90 | - } |
|
91 | - $data[] = array( |
|
92 | - 'name' => $field_obj->get_nicename(), |
|
93 | - 'value' => $value, |
|
94 | - ); |
|
95 | - } |
|
96 | - $export_items[] = array( |
|
97 | - 'group_id' => 'transactions', |
|
98 | - 'group_label' => esc_html__('Transactions', 'event_espresso'), |
|
99 | - 'item_id' => $transaction->ID(), |
|
100 | - 'data' => $data, |
|
101 | - ); |
|
102 | - } |
|
103 | - return array( |
|
104 | - 'data' => $export_items, |
|
105 | - 'done' => ! $found_something, |
|
106 | - ); |
|
107 | - } |
|
34 | + /** |
|
35 | + * Returns data for export. |
|
36 | + * |
|
37 | + * @param string $email_address , |
|
38 | + * @param int $page starts at 1, not 0 |
|
39 | + * @return array { |
|
40 | + * @type array $data { |
|
41 | + * @type array { |
|
42 | + * @type string $group_id (not translated, same for all exports) |
|
43 | + * @type string $group_label (translated string) |
|
44 | + * @type string|int $item_id |
|
45 | + * @type array $data { |
|
46 | + * @type array { |
|
47 | + * @type string $name what's shown in the left-column of the export row |
|
48 | + * @type string $value what's showin the right-column of the export row |
|
49 | + * } |
|
50 | + * } |
|
51 | + * } |
|
52 | + * } |
|
53 | + * } |
|
54 | + */ |
|
55 | + public function export($email_address, $page = 1) |
|
56 | + { |
|
57 | + $page_size = 10; |
|
58 | + $transactions = $this->transaction_model->get_all( |
|
59 | + array( |
|
60 | + array( |
|
61 | + 'Registration.Attendee.ATT_email' => $email_address, |
|
62 | + ), |
|
63 | + 'limit' => array( |
|
64 | + ($page - 1) * $page_size, |
|
65 | + $page_size, |
|
66 | + ), |
|
67 | + ) |
|
68 | + ); |
|
69 | + $export_fields = array_intersect_key( |
|
70 | + EEM_Transaction::instance()->field_settings(), |
|
71 | + array_flip( |
|
72 | + array( |
|
73 | + 'TXN_timestamp', |
|
74 | + 'TXN_total', |
|
75 | + 'TXN_paid', |
|
76 | + 'TXN_session_data', |
|
77 | + ) |
|
78 | + ) |
|
79 | + ); |
|
80 | + $export_items = array(); |
|
81 | + $found_something = false; |
|
82 | + foreach ($transactions as $transaction) { |
|
83 | + $found_something = true; |
|
84 | + $data = array(); |
|
85 | + foreach ($export_fields as $field_name => $field_obj) { |
|
86 | + if ($field_name === 'TXN_session_data') { |
|
87 | + $value = $transaction->get_pretty($field_name, 'print_r'); |
|
88 | + } else { |
|
89 | + $value = $transaction->get_pretty($field_name); |
|
90 | + } |
|
91 | + $data[] = array( |
|
92 | + 'name' => $field_obj->get_nicename(), |
|
93 | + 'value' => $value, |
|
94 | + ); |
|
95 | + } |
|
96 | + $export_items[] = array( |
|
97 | + 'group_id' => 'transactions', |
|
98 | + 'group_label' => esc_html__('Transactions', 'event_espresso'), |
|
99 | + 'item_id' => $transaction->ID(), |
|
100 | + 'data' => $data, |
|
101 | + ); |
|
102 | + } |
|
103 | + return array( |
|
104 | + 'data' => $export_items, |
|
105 | + 'done' => ! $found_something, |
|
106 | + ); |
|
107 | + } |
|
108 | 108 | |
109 | - /** |
|
110 | - * Gets the Translated name of this exporter |
|
111 | - * |
|
112 | - * @return string |
|
113 | - */ |
|
114 | - public function name() |
|
115 | - { |
|
116 | - return esc_html__('Event Espresso Transaction Exporter', 'event_espresso'); |
|
117 | - } |
|
109 | + /** |
|
110 | + * Gets the Translated name of this exporter |
|
111 | + * |
|
112 | + * @return string |
|
113 | + */ |
|
114 | + public function name() |
|
115 | + { |
|
116 | + return esc_html__('Event Espresso Transaction Exporter', 'event_espresso'); |
|
117 | + } |
|
118 | 118 | } |
119 | 119 | // End of file ExportTransaction.php |
120 | 120 | // Location: EventEspresso\core\domain\services\admin\privacy\export/ExportTransaction.php |
@@ -16,112 +16,112 @@ |
||
16 | 16 | */ |
17 | 17 | class ExportCheckins implements PersonalDataExporterInterface |
18 | 18 | { |
19 | - /** |
|
20 | - * @var EEM_Checkin |
|
21 | - */ |
|
22 | - protected $checkin_model; |
|
19 | + /** |
|
20 | + * @var EEM_Checkin |
|
21 | + */ |
|
22 | + protected $checkin_model; |
|
23 | 23 | |
24 | - /** |
|
25 | - * ExportCheckins constructor. |
|
26 | - * |
|
27 | - * @param EEM_Checkin $checkin_model |
|
28 | - */ |
|
29 | - public function __construct(EEM_Checkin $checkin_model) |
|
30 | - { |
|
31 | - $this->checkin_model = $checkin_model; |
|
32 | - } |
|
24 | + /** |
|
25 | + * ExportCheckins constructor. |
|
26 | + * |
|
27 | + * @param EEM_Checkin $checkin_model |
|
28 | + */ |
|
29 | + public function __construct(EEM_Checkin $checkin_model) |
|
30 | + { |
|
31 | + $this->checkin_model = $checkin_model; |
|
32 | + } |
|
33 | 33 | |
34 | 34 | |
35 | - /** |
|
36 | - * Returns data for export. |
|
37 | - * |
|
38 | - * @param string $email_address , |
|
39 | - * @param int $page starts at 1, not 0 |
|
40 | - * @return array { |
|
41 | - * @type array $data { |
|
42 | - * @type array { |
|
43 | - * @type string $group_id (not translated, same for all exports) |
|
44 | - * @type string $group_label (translated string) |
|
45 | - * @type string|int $item_id |
|
46 | - * @type array $data { |
|
47 | - * @type array { |
|
48 | - * @type string $name what's shown in the left-column of the export row |
|
49 | - * @type string $value what's showin the right-column of the export row |
|
50 | - * } |
|
51 | - * } |
|
52 | - * } |
|
53 | - * } |
|
54 | - * } |
|
55 | - */ |
|
56 | - public function export($email_address, $page = 1) |
|
57 | - { |
|
58 | - $page_size = 10; |
|
59 | - $checkins = $this->checkin_model->get_all( |
|
60 | - array( |
|
61 | - array( |
|
62 | - 'Registration.Attendee.ATT_email' => $email_address, |
|
63 | - ), |
|
64 | - 'limit' => array( |
|
65 | - ($page - 1) * $page_size, |
|
66 | - $page_size, |
|
67 | - ), |
|
68 | - 'force_join' => array('Registration.Event'), |
|
69 | - ) |
|
70 | - ); |
|
35 | + /** |
|
36 | + * Returns data for export. |
|
37 | + * |
|
38 | + * @param string $email_address , |
|
39 | + * @param int $page starts at 1, not 0 |
|
40 | + * @return array { |
|
41 | + * @type array $data { |
|
42 | + * @type array { |
|
43 | + * @type string $group_id (not translated, same for all exports) |
|
44 | + * @type string $group_label (translated string) |
|
45 | + * @type string|int $item_id |
|
46 | + * @type array $data { |
|
47 | + * @type array { |
|
48 | + * @type string $name what's shown in the left-column of the export row |
|
49 | + * @type string $value what's showin the right-column of the export row |
|
50 | + * } |
|
51 | + * } |
|
52 | + * } |
|
53 | + * } |
|
54 | + * } |
|
55 | + */ |
|
56 | + public function export($email_address, $page = 1) |
|
57 | + { |
|
58 | + $page_size = 10; |
|
59 | + $checkins = $this->checkin_model->get_all( |
|
60 | + array( |
|
61 | + array( |
|
62 | + 'Registration.Attendee.ATT_email' => $email_address, |
|
63 | + ), |
|
64 | + 'limit' => array( |
|
65 | + ($page - 1) * $page_size, |
|
66 | + $page_size, |
|
67 | + ), |
|
68 | + 'force_join' => array('Registration.Event'), |
|
69 | + ) |
|
70 | + ); |
|
71 | 71 | |
72 | - if (empty($checkins)) { |
|
73 | - return array( |
|
74 | - 'data' => array(), |
|
75 | - 'done' => true, |
|
76 | - ); |
|
77 | - } |
|
72 | + if (empty($checkins)) { |
|
73 | + return array( |
|
74 | + 'data' => array(), |
|
75 | + 'done' => true, |
|
76 | + ); |
|
77 | + } |
|
78 | 78 | |
79 | - $export_items = array(); |
|
80 | - foreach ($checkins as $checkin) { |
|
81 | - $reg = $checkin->get_first_related('Registration'); |
|
82 | - if ($reg instanceof EE_Registration) { |
|
83 | - $event_name = $reg->event_name(); |
|
84 | - } else { |
|
85 | - $event_name = esc_html__('Unknown', 'event_espresso'); |
|
86 | - } |
|
87 | - $export_items[] = |
|
88 | - array( |
|
89 | - 'group_id' => 'check-ins', |
|
90 | - 'group_label' => esc_html__('Event Check-Ins', 'event_espresso'), |
|
91 | - 'item_id' => $checkin->ID(), |
|
92 | - 'data' => array( |
|
93 | - array( |
|
94 | - 'name' => esc_html__('Time', 'event_espresso'), |
|
95 | - 'value' => $checkin->get_pretty('CHK_timestamp'), |
|
96 | - ), |
|
97 | - array( |
|
98 | - 'name' => esc_html__('Check in/out', 'event_espresso'), |
|
99 | - 'value' => $checkin->get('CHK_in') |
|
100 | - ? esc_html__('In', 'event_espresso') |
|
101 | - : esc_html__('Out', 'event_espresso'), |
|
102 | - ), |
|
103 | - array( |
|
104 | - 'name' => esc_html__('Event', 'event_espresso'), |
|
105 | - 'value' => $event_name, |
|
106 | - ), |
|
107 | - ), |
|
108 | - ); |
|
109 | - } |
|
110 | - return array( |
|
111 | - 'data' => $export_items, |
|
112 | - 'done' => true, |
|
113 | - ); |
|
114 | - } |
|
79 | + $export_items = array(); |
|
80 | + foreach ($checkins as $checkin) { |
|
81 | + $reg = $checkin->get_first_related('Registration'); |
|
82 | + if ($reg instanceof EE_Registration) { |
|
83 | + $event_name = $reg->event_name(); |
|
84 | + } else { |
|
85 | + $event_name = esc_html__('Unknown', 'event_espresso'); |
|
86 | + } |
|
87 | + $export_items[] = |
|
88 | + array( |
|
89 | + 'group_id' => 'check-ins', |
|
90 | + 'group_label' => esc_html__('Event Check-Ins', 'event_espresso'), |
|
91 | + 'item_id' => $checkin->ID(), |
|
92 | + 'data' => array( |
|
93 | + array( |
|
94 | + 'name' => esc_html__('Time', 'event_espresso'), |
|
95 | + 'value' => $checkin->get_pretty('CHK_timestamp'), |
|
96 | + ), |
|
97 | + array( |
|
98 | + 'name' => esc_html__('Check in/out', 'event_espresso'), |
|
99 | + 'value' => $checkin->get('CHK_in') |
|
100 | + ? esc_html__('In', 'event_espresso') |
|
101 | + : esc_html__('Out', 'event_espresso'), |
|
102 | + ), |
|
103 | + array( |
|
104 | + 'name' => esc_html__('Event', 'event_espresso'), |
|
105 | + 'value' => $event_name, |
|
106 | + ), |
|
107 | + ), |
|
108 | + ); |
|
109 | + } |
|
110 | + return array( |
|
111 | + 'data' => $export_items, |
|
112 | + 'done' => true, |
|
113 | + ); |
|
114 | + } |
|
115 | 115 | |
116 | - /** |
|
117 | - * Gets the Translated name of this exporter |
|
118 | - * |
|
119 | - * @return string |
|
120 | - */ |
|
121 | - public function name() |
|
122 | - { |
|
123 | - return esc_html__('Event Espresso Checkins Exporter', 'event_espresso'); |
|
124 | - } |
|
116 | + /** |
|
117 | + * Gets the Translated name of this exporter |
|
118 | + * |
|
119 | + * @return string |
|
120 | + */ |
|
121 | + public function name() |
|
122 | + { |
|
123 | + return esc_html__('Event Espresso Checkins Exporter', 'event_espresso'); |
|
124 | + } |
|
125 | 125 | } |
126 | 126 | // End of file ExportCheckins.php |
127 | 127 | // Location: EventEspresso\core\domain\services\admin\privacy\export/ExportCheckins.php |
@@ -15,116 +15,116 @@ |
||
15 | 15 | */ |
16 | 16 | class ExportAttendee implements PersonalDataExporterInterface |
17 | 17 | { |
18 | - /** |
|
19 | - * @var EEM_Attendee |
|
20 | - */ |
|
21 | - protected $attendee_model; |
|
18 | + /** |
|
19 | + * @var EEM_Attendee |
|
20 | + */ |
|
21 | + protected $attendee_model; |
|
22 | 22 | |
23 | - /** |
|
24 | - * ExportAttendee constructor. |
|
25 | - * |
|
26 | - * @param EEM_Attendee $attendee_model |
|
27 | - */ |
|
28 | - public function __construct(EEM_Attendee $attendee_model) |
|
29 | - { |
|
30 | - $this->attendee_model = $attendee_model; |
|
31 | - } |
|
23 | + /** |
|
24 | + * ExportAttendee constructor. |
|
25 | + * |
|
26 | + * @param EEM_Attendee $attendee_model |
|
27 | + */ |
|
28 | + public function __construct(EEM_Attendee $attendee_model) |
|
29 | + { |
|
30 | + $this->attendee_model = $attendee_model; |
|
31 | + } |
|
32 | 32 | |
33 | 33 | |
34 | - /** |
|
35 | - * Returns data for export. |
|
36 | - * |
|
37 | - * @param string $email_address , |
|
38 | - * @param int $page starts at 1, not 0 |
|
39 | - * @return array { |
|
40 | - * @type array $data { |
|
41 | - * @type array { |
|
42 | - * @type string $group_id (not translated, same for all exports) |
|
43 | - * @type string $group_label (translated string) |
|
44 | - * @type string|int $item_id |
|
45 | - * @type array $data { |
|
46 | - * @type array { |
|
47 | - * @type string $name what's shown in the left-column of the export row |
|
48 | - * @type string $value what's showin the right-column of the export row |
|
49 | - * } |
|
50 | - * } |
|
51 | - * } |
|
52 | - * } |
|
53 | - * } |
|
54 | - */ |
|
55 | - public function export($email_address, $page = 1) |
|
56 | - { |
|
57 | - $attendees = $this->attendee_model->get_all( |
|
58 | - array( |
|
59 | - array( |
|
60 | - 'ATT_email' => $email_address, |
|
61 | - ), |
|
62 | - ) |
|
63 | - ); |
|
34 | + /** |
|
35 | + * Returns data for export. |
|
36 | + * |
|
37 | + * @param string $email_address , |
|
38 | + * @param int $page starts at 1, not 0 |
|
39 | + * @return array { |
|
40 | + * @type array $data { |
|
41 | + * @type array { |
|
42 | + * @type string $group_id (not translated, same for all exports) |
|
43 | + * @type string $group_label (translated string) |
|
44 | + * @type string|int $item_id |
|
45 | + * @type array $data { |
|
46 | + * @type array { |
|
47 | + * @type string $name what's shown in the left-column of the export row |
|
48 | + * @type string $value what's showin the right-column of the export row |
|
49 | + * } |
|
50 | + * } |
|
51 | + * } |
|
52 | + * } |
|
53 | + * } |
|
54 | + */ |
|
55 | + public function export($email_address, $page = 1) |
|
56 | + { |
|
57 | + $attendees = $this->attendee_model->get_all( |
|
58 | + array( |
|
59 | + array( |
|
60 | + 'ATT_email' => $email_address, |
|
61 | + ), |
|
62 | + ) |
|
63 | + ); |
|
64 | 64 | |
65 | - if (empty($attendees)) { |
|
66 | - return array( |
|
67 | - 'data' => array(), |
|
68 | - 'done' => true, |
|
69 | - ); |
|
70 | - } |
|
65 | + if (empty($attendees)) { |
|
66 | + return array( |
|
67 | + 'data' => array(), |
|
68 | + 'done' => true, |
|
69 | + ); |
|
70 | + } |
|
71 | 71 | |
72 | - $export_items = array(); |
|
73 | - foreach ($attendees as $attendee) { |
|
74 | - $export_fields = array_intersect_key( |
|
75 | - $this->attendee_model->field_settings(), |
|
76 | - array_flip( |
|
77 | - array( |
|
78 | - 'ATT_fname', |
|
79 | - 'ATT_lname', |
|
80 | - 'ATT_email', |
|
81 | - 'ATT_address1', |
|
82 | - 'ATT_address2', |
|
83 | - 'ATT_city', |
|
84 | - 'STA_ID', |
|
85 | - 'CNT_ISO', |
|
86 | - 'ATT_zip', |
|
87 | - 'ATT_phone', |
|
88 | - ) |
|
89 | - ) |
|
90 | - ); |
|
91 | - $data = array(); |
|
92 | - foreach ($export_fields as $field_name => $field_obj) { |
|
93 | - if ($field_name === 'STA_ID') { |
|
94 | - $value = $attendee->state_name(); |
|
95 | - } elseif ($field_name == 'CNT_ISO') { |
|
96 | - $value = $attendee->country_name(); |
|
97 | - } else { |
|
98 | - $value = $attendee->get_pretty($field_name); |
|
99 | - } |
|
100 | - $data[] = array( |
|
101 | - 'name' => $field_obj->get_nicename(), |
|
102 | - 'value' => $value, |
|
103 | - ); |
|
104 | - } |
|
105 | - $export_items[] = |
|
106 | - array( |
|
107 | - 'group_id' => 'att-' . $attendee->ID(), |
|
108 | - 'group_label' => esc_html__('Contact Profiles', 'event_espresso'), |
|
109 | - 'item_id' => $attendee->ID(), |
|
110 | - 'data' => $data, |
|
111 | - ); |
|
112 | - } |
|
113 | - return array( |
|
114 | - 'data' => $export_items, |
|
115 | - 'done' => true, |
|
116 | - ); |
|
117 | - } |
|
72 | + $export_items = array(); |
|
73 | + foreach ($attendees as $attendee) { |
|
74 | + $export_fields = array_intersect_key( |
|
75 | + $this->attendee_model->field_settings(), |
|
76 | + array_flip( |
|
77 | + array( |
|
78 | + 'ATT_fname', |
|
79 | + 'ATT_lname', |
|
80 | + 'ATT_email', |
|
81 | + 'ATT_address1', |
|
82 | + 'ATT_address2', |
|
83 | + 'ATT_city', |
|
84 | + 'STA_ID', |
|
85 | + 'CNT_ISO', |
|
86 | + 'ATT_zip', |
|
87 | + 'ATT_phone', |
|
88 | + ) |
|
89 | + ) |
|
90 | + ); |
|
91 | + $data = array(); |
|
92 | + foreach ($export_fields as $field_name => $field_obj) { |
|
93 | + if ($field_name === 'STA_ID') { |
|
94 | + $value = $attendee->state_name(); |
|
95 | + } elseif ($field_name == 'CNT_ISO') { |
|
96 | + $value = $attendee->country_name(); |
|
97 | + } else { |
|
98 | + $value = $attendee->get_pretty($field_name); |
|
99 | + } |
|
100 | + $data[] = array( |
|
101 | + 'name' => $field_obj->get_nicename(), |
|
102 | + 'value' => $value, |
|
103 | + ); |
|
104 | + } |
|
105 | + $export_items[] = |
|
106 | + array( |
|
107 | + 'group_id' => 'att-' . $attendee->ID(), |
|
108 | + 'group_label' => esc_html__('Contact Profiles', 'event_espresso'), |
|
109 | + 'item_id' => $attendee->ID(), |
|
110 | + 'data' => $data, |
|
111 | + ); |
|
112 | + } |
|
113 | + return array( |
|
114 | + 'data' => $export_items, |
|
115 | + 'done' => true, |
|
116 | + ); |
|
117 | + } |
|
118 | 118 | |
119 | - /** |
|
120 | - * Gets the Translated name of this exporter |
|
121 | - * |
|
122 | - * @return string |
|
123 | - */ |
|
124 | - public function name() |
|
125 | - { |
|
126 | - return esc_html__('Event Espresso Attendee Data Exporter', 'event_espresso'); |
|
127 | - } |
|
119 | + /** |
|
120 | + * Gets the Translated name of this exporter |
|
121 | + * |
|
122 | + * @return string |
|
123 | + */ |
|
124 | + public function name() |
|
125 | + { |
|
126 | + return esc_html__('Event Espresso Attendee Data Exporter', 'event_espresso'); |
|
127 | + } |
|
128 | 128 | } |
129 | 129 | // End of file ExportAttendee.php |
130 | 130 | // Location: EventEspresso\core\domain\services\admin\privacy\export/ExportAttendee.php |
@@ -104,7 +104,7 @@ |
||
104 | 104 | } |
105 | 105 | $export_items[] = |
106 | 106 | array( |
107 | - 'group_id' => 'att-' . $attendee->ID(), |
|
107 | + 'group_id' => 'att-'.$attendee->ID(), |
|
108 | 108 | 'group_label' => esc_html__('Contact Profiles', 'event_espresso'), |
109 | 109 | 'item_id' => $attendee->ID(), |
110 | 110 | 'data' => $data, |