@@ -194,7 +194,7 @@ discard block  | 
                                                    ||
| 194 | 194 | * PLZ NOTE: the pointer is reset to the beginning of the collection before returning  | 
                                                        
| 195 | 195 | *  | 
                                                        
| 196 | 196 | * @param mixed $identifier  | 
                                                        
| 197 | - * @return mixed  | 
                                                        |
| 197 | + * @return boolean  | 
                                                        |
| 198 | 198 | */  | 
                                                        
| 199 | 199 | public function get($identifier)  | 
                                                        
| 200 | 200 |      { | 
                                                        
@@ -309,7 +309,7 @@ discard block  | 
                                                    ||
| 309 | 309 | * setCurrentUsingObject  | 
                                                        
| 310 | 310 | * advances pointer to the provided object  | 
                                                        
| 311 | 311 | *  | 
                                                        
| 312 | - * @param $object  | 
                                                        |
| 312 | + * @param \EventEspresso\core\libraries\form_sections\form_handlers\SequentialStepForm $object  | 
                                                        |
| 313 | 313 | * @return boolean  | 
                                                        
| 314 | 314 | */  | 
                                                        
| 315 | 315 | public function setCurrentUsingObject($object)  | 
                                                        
@@ -347,7 +347,7 @@ discard block  | 
                                                    ||
| 347 | 347 | *  | 
                                                        
| 348 | 348 | * @see http://stackoverflow.com/a/8736013  | 
                                                        
| 349 | 349 | * @param $object  | 
                                                        
| 350 | - * @return boolean|int|string  | 
                                                        |
| 350 | + * @return integer  | 
                                                        |
| 351 | 351 | */  | 
                                                        
| 352 | 352 | public function indexOf($object)  | 
                                                        
| 353 | 353 |      { | 
                                                        
@@ -66,7 +66,7 @@ discard block  | 
                                                    ||
| 66 | 66 | */  | 
                                                        
| 67 | 67 | protected function setCollectionInterface($collection_interface)  | 
                                                        
| 68 | 68 |      { | 
                                                        
| 69 | -        if (! (interface_exists($collection_interface) || class_exists($collection_interface))) { | 
                                                        |
| 69 | +        if ( ! (interface_exists($collection_interface) || class_exists($collection_interface))) { | 
                                                        |
| 70 | 70 | throw new InvalidInterfaceException($collection_interface);  | 
                                                        
| 71 | 71 | }  | 
                                                        
| 72 | 72 | $this->collection_interface = $collection_interface;  | 
                                                        
@@ -111,13 +111,13 @@ discard block  | 
                                                    ||
| 111 | 111 | protected function setCollectionIdentifier()  | 
                                                        
| 112 | 112 |      { | 
                                                        
| 113 | 113 | // hash a few collection details  | 
                                                        
| 114 | - $identifier = md5(spl_object_hash($this) . $this->collection_interface . time());  | 
                                                        |
| 114 | + $identifier = md5(spl_object_hash($this).$this->collection_interface.time());  | 
                                                        |
| 115 | 115 | // grab a few characters from the start, middle, and end of the hash  | 
                                                        
| 116 | 116 | $id = array();  | 
                                                        
| 117 | 117 |          for ($x = 0; $x < 19; $x += 9) { | 
                                                        
| 118 | 118 | $id[] = substr($identifier, $x, 3);  | 
                                                        
| 119 | 119 | }  | 
                                                        
| 120 | -        $this->collection_identifier = $this->collection_name . '-' . strtoupper(implode('-', $id)); | 
                                                        |
| 120 | +        $this->collection_identifier = $this->collection_name.'-'.strtoupper(implode('-', $id)); | 
                                                        |
| 121 | 121 | }  | 
                                                        
| 122 | 122 | |
| 123 | 123 | |
@@ -135,7 +135,7 @@ discard block  | 
                                                    ||
| 135 | 135 | */  | 
                                                        
| 136 | 136 | public function add($object, $identifier = null)  | 
                                                        
| 137 | 137 |      { | 
                                                        
| 138 | -        if (! $object instanceof $this->collection_interface) { | 
                                                        |
| 138 | +        if ( ! $object instanceof $this->collection_interface) { | 
                                                        |
| 139 | 139 | throw new InvalidEntityException($object, $this->collection_interface);  | 
                                                        
| 140 | 140 | }  | 
                                                        
| 141 | 141 |          if ($this->contains($object)) { | 
                                                        
@@ -351,7 +351,7 @@ discard block  | 
                                                    ||
| 351 | 351 | */  | 
                                                        
| 352 | 352 | public function indexOf($object)  | 
                                                        
| 353 | 353 |      { | 
                                                        
| 354 | -        if (! $this->contains($object)) { | 
                                                        |
| 354 | +        if ( ! $this->contains($object)) { | 
                                                        |
| 355 | 355 | return false;  | 
                                                        
| 356 | 356 | }  | 
                                                        
| 357 | 357 |          foreach ($this as $index => $obj) { | 
                                                        
@@ -420,9 +420,9 @@ discard block  | 
                                                    ||
| 420 | 420 | $remaining_objects = $this->slice($index, $this->count() - $index);  | 
                                                        
| 421 | 421 |              foreach ($remaining_objects as $key => $remaining_object) { | 
                                                        
| 422 | 422 | // we need to grab the identifiers for each object and use them as keys  | 
                                                        
| 423 | - $remaining_objects[ $remaining_object->getInfo() ] = $remaining_object;  | 
                                                        |
| 423 | + $remaining_objects[$remaining_object->getInfo()] = $remaining_object;  | 
                                                        |
| 424 | 424 | // and then remove the object from the current tracking array  | 
                                                        
| 425 | - unset($remaining_objects[ $key ]);  | 
                                                        |
| 425 | + unset($remaining_objects[$key]);  | 
                                                        |
| 426 | 426 | // and then remove it from the Collection  | 
                                                        
| 427 | 427 | $this->detach($remaining_object);  | 
                                                        
| 428 | 428 | }  | 
                                                        
@@ -446,17 +446,17 @@ discard block  | 
                                                    ||
| 446 | 446 | */  | 
                                                        
| 447 | 447 | public function insertAt($objects, $index)  | 
                                                        
| 448 | 448 |      { | 
                                                        
| 449 | -        if (! is_array($objects)) { | 
                                                        |
| 449 | +        if ( ! is_array($objects)) { | 
                                                        |
| 450 | 450 | $objects = array($objects);  | 
                                                        
| 451 | 451 | }  | 
                                                        
| 452 | 452 | // check to ensure that objects don't already exist in the collection  | 
                                                        
| 453 | 453 |          foreach ($objects as $key => $object) { | 
                                                        
| 454 | 454 |              if ($this->contains($object)) { | 
                                                        
| 455 | - unset($objects[ $key ]);  | 
                                                        |
| 455 | + unset($objects[$key]);  | 
                                                        |
| 456 | 456 | }  | 
                                                        
| 457 | 457 | }  | 
                                                        
| 458 | 458 | // do we have any objects left?  | 
                                                        
| 459 | -        if (! $objects) { | 
                                                        |
| 459 | +        if ( ! $objects) { | 
                                                        |
| 460 | 460 | return;  | 
                                                        
| 461 | 461 | }  | 
                                                        
| 462 | 462 | // detach any objects at or past this index  | 
                                                        
@@ -19,504 +19,504 @@  | 
                                                    ||
| 19 | 19 | class Collection extends SplObjectStorage implements CollectionInterface  | 
                                                        
| 20 | 20 |  { | 
                                                        
| 21 | 21 | |
| 22 | - /**  | 
                                                        |
| 23 | - * a unique string for identifying this collection  | 
                                                        |
| 24 | - *  | 
                                                        |
| 25 | - * @type string $collection_identifier  | 
                                                        |
| 26 | - */  | 
                                                        |
| 27 | - protected $collection_identifier;  | 
                                                        |
| 28 | -  | 
                                                        |
| 29 | -  | 
                                                        |
| 30 | - /**  | 
                                                        |
| 31 | - * an interface (or class) name to be used for restricting the type of objects added to the storage  | 
                                                        |
| 32 | - * this should be set from within the child class constructor  | 
                                                        |
| 33 | - *  | 
                                                        |
| 34 | - * @type string $interface  | 
                                                        |
| 35 | - */  | 
                                                        |
| 36 | - protected $collection_interface;  | 
                                                        |
| 37 | -  | 
                                                        |
| 38 | - /**  | 
                                                        |
| 39 | - * a short dash separated string describing the contents of this collection  | 
                                                        |
| 40 | - * used as the base for the $collection_identifier  | 
                                                        |
| 41 | - * defaults to the class short name if not set  | 
                                                        |
| 42 | - *  | 
                                                        |
| 43 | - * @type string $collection_identifier  | 
                                                        |
| 44 | - */  | 
                                                        |
| 45 | - protected $collection_name;  | 
                                                        |
| 46 | -  | 
                                                        |
| 47 | -  | 
                                                        |
| 48 | - /**  | 
                                                        |
| 49 | - * Collection constructor  | 
                                                        |
| 50 | - *  | 
                                                        |
| 51 | - * @param string $collection_interface  | 
                                                        |
| 52 | - * @param string $collection_name  | 
                                                        |
| 53 | - * @throws InvalidInterfaceException  | 
                                                        |
| 54 | - */  | 
                                                        |
| 55 | - public function __construct($collection_interface, $collection_name = '')  | 
                                                        |
| 56 | -    { | 
                                                        |
| 57 | - $this->setCollectionInterface($collection_interface);  | 
                                                        |
| 58 | - $this->setCollectionName($collection_name);  | 
                                                        |
| 59 | - $this->setCollectionIdentifier();  | 
                                                        |
| 60 | - }  | 
                                                        |
| 61 | -  | 
                                                        |
| 62 | -  | 
                                                        |
| 63 | - /**  | 
                                                        |
| 64 | - * setCollectionInterface  | 
                                                        |
| 65 | - *  | 
                                                        |
| 66 | - * @param string $collection_interface  | 
                                                        |
| 67 | - * @throws InvalidInterfaceException  | 
                                                        |
| 68 | - */  | 
                                                        |
| 69 | - protected function setCollectionInterface($collection_interface)  | 
                                                        |
| 70 | -    { | 
                                                        |
| 71 | -        if (! (interface_exists($collection_interface) || class_exists($collection_interface))) { | 
                                                        |
| 72 | - throw new InvalidInterfaceException($collection_interface);  | 
                                                        |
| 73 | - }  | 
                                                        |
| 74 | - $this->collection_interface = $collection_interface;  | 
                                                        |
| 75 | - }  | 
                                                        |
| 76 | -  | 
                                                        |
| 77 | -  | 
                                                        |
| 78 | - /**  | 
                                                        |
| 79 | - * @return string  | 
                                                        |
| 80 | - */  | 
                                                        |
| 81 | - public function collectionName()  | 
                                                        |
| 82 | -    { | 
                                                        |
| 83 | - return $this->collection_name;  | 
                                                        |
| 84 | - }  | 
                                                        |
| 85 | -  | 
                                                        |
| 86 | -  | 
                                                        |
| 87 | - /**  | 
                                                        |
| 88 | - * @param string $collection_name  | 
                                                        |
| 89 | - */  | 
                                                        |
| 90 | - protected function setCollectionName($collection_name)  | 
                                                        |
| 91 | -    { | 
                                                        |
| 92 | - $this->collection_name = ! empty($collection_name)  | 
                                                        |
| 93 | - ? sanitize_key($collection_name)  | 
                                                        |
| 94 | -            : basename(str_replace('\\', '/', get_class($this))); | 
                                                        |
| 95 | - }  | 
                                                        |
| 96 | -  | 
                                                        |
| 97 | -  | 
                                                        |
| 98 | - /**  | 
                                                        |
| 99 | - * @return string  | 
                                                        |
| 100 | - */  | 
                                                        |
| 101 | - public function collectionIdentifier()  | 
                                                        |
| 102 | -    { | 
                                                        |
| 103 | - return $this->collection_identifier;  | 
                                                        |
| 104 | - }  | 
                                                        |
| 105 | -  | 
                                                        |
| 106 | -  | 
                                                        |
| 107 | - /**  | 
                                                        |
| 108 | - * creates a very readable unique 9 character identifier like: CF2-532-DAC  | 
                                                        |
| 109 | - * and appends it to the non-qualified class name, ex: ThingCollection-CF2-532-DAC  | 
                                                        |
| 110 | - *  | 
                                                        |
| 111 | - * @return void  | 
                                                        |
| 112 | - */  | 
                                                        |
| 113 | - protected function setCollectionIdentifier()  | 
                                                        |
| 114 | -    { | 
                                                        |
| 115 | - // hash a few collection details  | 
                                                        |
| 116 | - $identifier = md5(spl_object_hash($this) . $this->collection_interface . time());  | 
                                                        |
| 117 | - // grab a few characters from the start, middle, and end of the hash  | 
                                                        |
| 118 | - $id = array();  | 
                                                        |
| 119 | -        for ($x = 0; $x < 19; $x += 9) { | 
                                                        |
| 120 | - $id[] = substr($identifier, $x, 3);  | 
                                                        |
| 121 | - }  | 
                                                        |
| 122 | -        $this->collection_identifier = $this->collection_name . '-' . strtoupper(implode('-', $id)); | 
                                                        |
| 123 | - }  | 
                                                        |
| 124 | -  | 
                                                        |
| 125 | -  | 
                                                        |
| 126 | - /**  | 
                                                        |
| 127 | - * add  | 
                                                        |
| 128 | - * attaches an object to the Collection  | 
                                                        |
| 129 | - * and sets any supplied data associated with the current iterator entry  | 
                                                        |
| 130 | - * by calling EE_Object_Collection::set_identifier()  | 
                                                        |
| 131 | - *  | 
                                                        |
| 132 | - * @param $object  | 
                                                        |
| 133 | - * @param mixed $identifier  | 
                                                        |
| 134 | - * @return bool  | 
                                                        |
| 135 | - * @throws InvalidEntityException  | 
                                                        |
| 136 | - * @throws DuplicateCollectionIdentifierException  | 
                                                        |
| 137 | - */  | 
                                                        |
| 138 | - public function add($object, $identifier = null)  | 
                                                        |
| 139 | -    { | 
                                                        |
| 140 | -        if (! $object instanceof $this->collection_interface) { | 
                                                        |
| 141 | - throw new InvalidEntityException($object, $this->collection_interface);  | 
                                                        |
| 142 | - }  | 
                                                        |
| 143 | -        if ($this->contains($object)) { | 
                                                        |
| 144 | - throw new DuplicateCollectionIdentifierException($identifier);  | 
                                                        |
| 145 | - }  | 
                                                        |
| 146 | - $this->attach($object);  | 
                                                        |
| 147 | - $this->setIdentifier($object, $identifier);  | 
                                                        |
| 148 | - return $this->contains($object);  | 
                                                        |
| 149 | - }  | 
                                                        |
| 150 | -  | 
                                                        |
| 151 | -  | 
                                                        |
| 152 | - /**  | 
                                                        |
| 153 | - * getIdentifier  | 
                                                        |
| 154 | - * if no $identifier is supplied, then the spl_object_hash() is used  | 
                                                        |
| 155 | - *  | 
                                                        |
| 156 | - * @param $object  | 
                                                        |
| 157 | - * @param mixed $identifier  | 
                                                        |
| 158 | - * @return bool  | 
                                                        |
| 159 | - */  | 
                                                        |
| 160 | - public function getIdentifier($object, $identifier = null)  | 
                                                        |
| 161 | -    { | 
                                                        |
| 162 | - return ! empty($identifier)  | 
                                                        |
| 163 | - ? $identifier  | 
                                                        |
| 164 | - : spl_object_hash($object);  | 
                                                        |
| 165 | - }  | 
                                                        |
| 166 | -  | 
                                                        |
| 167 | -  | 
                                                        |
| 168 | - /**  | 
                                                        |
| 169 | - * setIdentifier  | 
                                                        |
| 170 | - * Sets the data associated with an object in the Collection  | 
                                                        |
| 171 | - * if no $identifier is supplied, then the spl_object_hash() is used  | 
                                                        |
| 172 | - *  | 
                                                        |
| 173 | - * @param $object  | 
                                                        |
| 174 | - * @param mixed $identifier  | 
                                                        |
| 175 | - * @return bool  | 
                                                        |
| 176 | - */  | 
                                                        |
| 177 | - public function setIdentifier($object, $identifier = null)  | 
                                                        |
| 178 | -    { | 
                                                        |
| 179 | - $identifier = $this->getIdentifier($object, $identifier);  | 
                                                        |
| 180 | - $this->rewind();  | 
                                                        |
| 181 | -        while ($this->valid()) { | 
                                                        |
| 182 | -            if ($object === $this->current()) { | 
                                                        |
| 183 | - $this->setInfo($identifier);  | 
                                                        |
| 184 | - $this->rewind();  | 
                                                        |
| 185 | - return true;  | 
                                                        |
| 186 | - }  | 
                                                        |
| 187 | - $this->next();  | 
                                                        |
| 188 | - }  | 
                                                        |
| 189 | - return false;  | 
                                                        |
| 190 | - }  | 
                                                        |
| 191 | -  | 
                                                        |
| 192 | -  | 
                                                        |
| 193 | - /**  | 
                                                        |
| 194 | - * get  | 
                                                        |
| 195 | - * finds and returns an object in the Collection based on the identifier that was set using addObject()  | 
                                                        |
| 196 | - * PLZ NOTE: the pointer is reset to the beginning of the collection before returning  | 
                                                        |
| 197 | - *  | 
                                                        |
| 198 | - * @param mixed $identifier  | 
                                                        |
| 199 | - * @return mixed  | 
                                                        |
| 200 | - */  | 
                                                        |
| 201 | - public function get($identifier)  | 
                                                        |
| 202 | -    { | 
                                                        |
| 203 | - $this->rewind();  | 
                                                        |
| 204 | -        while ($this->valid()) { | 
                                                        |
| 205 | -            if ($identifier === $this->getInfo()) { | 
                                                        |
| 206 | - $object = $this->current();  | 
                                                        |
| 207 | - $this->rewind();  | 
                                                        |
| 208 | - return $object;  | 
                                                        |
| 209 | - }  | 
                                                        |
| 210 | - $this->next();  | 
                                                        |
| 211 | - }  | 
                                                        |
| 212 | - return null;  | 
                                                        |
| 213 | - }  | 
                                                        |
| 214 | -  | 
                                                        |
| 215 | -  | 
                                                        |
| 216 | - /**  | 
                                                        |
| 217 | - * has  | 
                                                        |
| 218 | - * returns TRUE or FALSE  | 
                                                        |
| 219 | - * depending on whether the object is within the Collection  | 
                                                        |
| 220 | - * based on the supplied $identifier  | 
                                                        |
| 221 | - *  | 
                                                        |
| 222 | - * @param mixed $identifier  | 
                                                        |
| 223 | - * @return bool  | 
                                                        |
| 224 | - */  | 
                                                        |
| 225 | - public function has($identifier)  | 
                                                        |
| 226 | -    { | 
                                                        |
| 227 | - $this->rewind();  | 
                                                        |
| 228 | -        while ($this->valid()) { | 
                                                        |
| 229 | -            if ($identifier === $this->getInfo()) { | 
                                                        |
| 230 | - $this->rewind();  | 
                                                        |
| 231 | - return true;  | 
                                                        |
| 232 | - }  | 
                                                        |
| 233 | - $this->next();  | 
                                                        |
| 234 | - }  | 
                                                        |
| 235 | - return false;  | 
                                                        |
| 236 | - }  | 
                                                        |
| 237 | -  | 
                                                        |
| 238 | -  | 
                                                        |
| 239 | - /**  | 
                                                        |
| 240 | - * hasObject  | 
                                                        |
| 241 | - * returns TRUE or FALSE depending on whether the supplied object is within the Collection  | 
                                                        |
| 242 | - *  | 
                                                        |
| 243 | - * @param $object  | 
                                                        |
| 244 | - * @return bool  | 
                                                        |
| 245 | - */  | 
                                                        |
| 246 | - public function hasObject($object)  | 
                                                        |
| 247 | -    { | 
                                                        |
| 248 | - return $this->contains($object);  | 
                                                        |
| 249 | - }  | 
                                                        |
| 250 | -  | 
                                                        |
| 251 | -  | 
                                                        |
| 252 | - /**  | 
                                                        |
| 253 | - * hasObjects  | 
                                                        |
| 254 | - * returns true if there are objects within the Collection, and false if it is empty  | 
                                                        |
| 255 | - *  | 
                                                        |
| 256 | - * @return bool  | 
                                                        |
| 257 | - */  | 
                                                        |
| 258 | - public function hasObjects()  | 
                                                        |
| 259 | -    { | 
                                                        |
| 260 | - return $this->count() !== 0;  | 
                                                        |
| 261 | - }  | 
                                                        |
| 262 | -  | 
                                                        |
| 263 | -  | 
                                                        |
| 264 | - /**  | 
                                                        |
| 265 | - * isEmpty  | 
                                                        |
| 266 | - * returns true if there are no objects within the Collection, and false if there are  | 
                                                        |
| 267 | - *  | 
                                                        |
| 268 | - * @return bool  | 
                                                        |
| 269 | - */  | 
                                                        |
| 270 | - public function isEmpty()  | 
                                                        |
| 271 | -    { | 
                                                        |
| 272 | - return $this->count() === 0;  | 
                                                        |
| 273 | - }  | 
                                                        |
| 274 | -  | 
                                                        |
| 275 | -  | 
                                                        |
| 276 | - /**  | 
                                                        |
| 277 | - * remove  | 
                                                        |
| 278 | - * detaches an object from the Collection  | 
                                                        |
| 279 | - *  | 
                                                        |
| 280 | - * @param $object  | 
                                                        |
| 281 | - * @return bool  | 
                                                        |
| 282 | - */  | 
                                                        |
| 283 | - public function remove($object)  | 
                                                        |
| 284 | -    { | 
                                                        |
| 285 | - $this->detach($object);  | 
                                                        |
| 286 | - return true;  | 
                                                        |
| 287 | - }  | 
                                                        |
| 288 | -  | 
                                                        |
| 289 | -  | 
                                                        |
| 290 | - /**  | 
                                                        |
| 291 | - * setCurrent  | 
                                                        |
| 292 | - * advances pointer to the object whose identifier matches that which was provided  | 
                                                        |
| 293 | - *  | 
                                                        |
| 294 | - * @param mixed $identifier  | 
                                                        |
| 295 | - * @return boolean  | 
                                                        |
| 296 | - */  | 
                                                        |
| 297 | - public function setCurrent($identifier)  | 
                                                        |
| 298 | -    { | 
                                                        |
| 299 | - $this->rewind();  | 
                                                        |
| 300 | -        while ($this->valid()) { | 
                                                        |
| 301 | -            if ($identifier === $this->getInfo()) { | 
                                                        |
| 302 | - return true;  | 
                                                        |
| 303 | - }  | 
                                                        |
| 304 | - $this->next();  | 
                                                        |
| 305 | - }  | 
                                                        |
| 306 | - return false;  | 
                                                        |
| 307 | - }  | 
                                                        |
| 308 | -  | 
                                                        |
| 309 | -  | 
                                                        |
| 310 | - /**  | 
                                                        |
| 311 | - * setCurrentUsingObject  | 
                                                        |
| 312 | - * advances pointer to the provided object  | 
                                                        |
| 313 | - *  | 
                                                        |
| 314 | - * @param $object  | 
                                                        |
| 315 | - * @return boolean  | 
                                                        |
| 316 | - */  | 
                                                        |
| 317 | - public function setCurrentUsingObject($object)  | 
                                                        |
| 318 | -    { | 
                                                        |
| 319 | - $this->rewind();  | 
                                                        |
| 320 | -        while ($this->valid()) { | 
                                                        |
| 321 | -            if ($this->current() === $object) { | 
                                                        |
| 322 | - return true;  | 
                                                        |
| 323 | - }  | 
                                                        |
| 324 | - $this->next();  | 
                                                        |
| 325 | - }  | 
                                                        |
| 326 | - return false;  | 
                                                        |
| 327 | - }  | 
                                                        |
| 328 | -  | 
                                                        |
| 329 | -  | 
                                                        |
| 330 | - /**  | 
                                                        |
| 331 | - * Returns the object occupying the index before the current object,  | 
                                                        |
| 332 | - * unless this is already the first object, in which case it just returns the first object  | 
                                                        |
| 333 | - *  | 
                                                        |
| 334 | - * @return mixed  | 
                                                        |
| 335 | - */  | 
                                                        |
| 336 | - public function previous()  | 
                                                        |
| 337 | -    { | 
                                                        |
| 338 | - $index = $this->indexOf($this->current());  | 
                                                        |
| 339 | -        if ($index === 0) { | 
                                                        |
| 340 | - return $this->current();  | 
                                                        |
| 341 | - }  | 
                                                        |
| 342 | - $index--;  | 
                                                        |
| 343 | - return $this->objectAtIndex($index);  | 
                                                        |
| 344 | - }  | 
                                                        |
| 345 | -  | 
                                                        |
| 346 | -  | 
                                                        |
| 347 | - /**  | 
                                                        |
| 348 | - * Returns the index of a given object, or false if not found  | 
                                                        |
| 349 | - *  | 
                                                        |
| 350 | - * @see http://stackoverflow.com/a/8736013  | 
                                                        |
| 351 | - * @param $object  | 
                                                        |
| 352 | - * @return boolean|int|string  | 
                                                        |
| 353 | - */  | 
                                                        |
| 354 | - public function indexOf($object)  | 
                                                        |
| 355 | -    { | 
                                                        |
| 356 | -        if (! $this->contains($object)) { | 
                                                        |
| 357 | - return false;  | 
                                                        |
| 358 | - }  | 
                                                        |
| 359 | -        foreach ($this as $index => $obj) { | 
                                                        |
| 360 | -            if ($obj === $object) { | 
                                                        |
| 361 | - return $index;  | 
                                                        |
| 362 | - }  | 
                                                        |
| 363 | - }  | 
                                                        |
| 364 | - return false;  | 
                                                        |
| 365 | - }  | 
                                                        |
| 366 | -  | 
                                                        |
| 367 | -  | 
                                                        |
| 368 | - /**  | 
                                                        |
| 369 | - * Returns the object at the given index  | 
                                                        |
| 370 | - *  | 
                                                        |
| 371 | - * @see http://stackoverflow.com/a/8736013  | 
                                                        |
| 372 | - * @param int $index  | 
                                                        |
| 373 | - * @return mixed  | 
                                                        |
| 374 | - */  | 
                                                        |
| 375 | - public function objectAtIndex($index)  | 
                                                        |
| 376 | -    { | 
                                                        |
| 377 | - $iterator = new LimitIterator($this, $index, 1);  | 
                                                        |
| 378 | - $iterator->rewind();  | 
                                                        |
| 379 | - return $iterator->current();  | 
                                                        |
| 380 | - }  | 
                                                        |
| 381 | -  | 
                                                        |
| 382 | -  | 
                                                        |
| 383 | - /**  | 
                                                        |
| 384 | - * Returns the sequence of objects as specified by the offset and length  | 
                                                        |
| 385 | - *  | 
                                                        |
| 386 | - * @see http://stackoverflow.com/a/8736013  | 
                                                        |
| 387 | - * @param int $offset  | 
                                                        |
| 388 | - * @param int $length  | 
                                                        |
| 389 | - * @return array  | 
                                                        |
| 390 | - */  | 
                                                        |
| 391 | - public function slice($offset, $length)  | 
                                                        |
| 392 | -    { | 
                                                        |
| 393 | - $slice = array();  | 
                                                        |
| 394 | - $iterator = new LimitIterator($this, $offset, $length);  | 
                                                        |
| 395 | -        foreach ($iterator as $object) { | 
                                                        |
| 396 | - $slice[] = $object;  | 
                                                        |
| 397 | - }  | 
                                                        |
| 398 | - return $slice;  | 
                                                        |
| 399 | - }  | 
                                                        |
| 400 | -  | 
                                                        |
| 401 | -  | 
                                                        |
| 402 | - /**  | 
                                                        |
| 403 | - * Inserts an object at a certain point  | 
                                                        |
| 404 | - *  | 
                                                        |
| 405 | - * @see http://stackoverflow.com/a/8736013  | 
                                                        |
| 406 | - * @param mixed $object A single object  | 
                                                        |
| 407 | - * @param int $index  | 
                                                        |
| 408 | - * @param mixed $identifier  | 
                                                        |
| 409 | - * @return bool  | 
                                                        |
| 410 | - * @throws DuplicateCollectionIdentifierException  | 
                                                        |
| 411 | - * @throws InvalidEntityException  | 
                                                        |
| 412 | - */  | 
                                                        |
| 413 | - public function insertObjectAt($object, $index, $identifier = null)  | 
                                                        |
| 414 | -    { | 
                                                        |
| 415 | - // check to ensure that objects don't already exist in the collection  | 
                                                        |
| 416 | -        if ($this->has($identifier)) { | 
                                                        |
| 417 | - throw new DuplicateCollectionIdentifierException($identifier);  | 
                                                        |
| 418 | - }  | 
                                                        |
| 419 | - // detach any objects at or past this index  | 
                                                        |
| 420 | - $remaining_objects = array();  | 
                                                        |
| 421 | -        if ($index < $this->count()) { | 
                                                        |
| 422 | - $remaining_objects = $this->slice($index, $this->count() - $index);  | 
                                                        |
| 423 | -            foreach ($remaining_objects as $key => $remaining_object) { | 
                                                        |
| 424 | - // we need to grab the identifiers for each object and use them as keys  | 
                                                        |
| 425 | - $remaining_objects[ $remaining_object->getInfo() ] = $remaining_object;  | 
                                                        |
| 426 | - // and then remove the object from the current tracking array  | 
                                                        |
| 427 | - unset($remaining_objects[ $key ]);  | 
                                                        |
| 428 | - // and then remove it from the Collection  | 
                                                        |
| 429 | - $this->detach($remaining_object);  | 
                                                        |
| 430 | - }  | 
                                                        |
| 431 | - }  | 
                                                        |
| 432 | - // add the new object we're splicing in  | 
                                                        |
| 433 | - $this->add($object, $identifier);  | 
                                                        |
| 434 | - // attach the objects we previously detached  | 
                                                        |
| 435 | -        foreach ($remaining_objects as $key => $remaining_object) { | 
                                                        |
| 436 | - $this->add($remaining_object, $key);  | 
                                                        |
| 437 | - }  | 
                                                        |
| 438 | - return $this->contains($object);  | 
                                                        |
| 439 | - }  | 
                                                        |
| 440 | -  | 
                                                        |
| 441 | -  | 
                                                        |
| 442 | - /**  | 
                                                        |
| 443 | - * Inserts an object (or an array of objects) at a certain point  | 
                                                        |
| 444 | - *  | 
                                                        |
| 445 | - * @see http://stackoverflow.com/a/8736013  | 
                                                        |
| 446 | - * @param mixed $objects A single object or an array of objects  | 
                                                        |
| 447 | - * @param int $index  | 
                                                        |
| 448 | - */  | 
                                                        |
| 449 | - public function insertAt($objects, $index)  | 
                                                        |
| 450 | -    { | 
                                                        |
| 451 | -        if (! is_array($objects)) { | 
                                                        |
| 452 | - $objects = array($objects);  | 
                                                        |
| 453 | - }  | 
                                                        |
| 454 | - // check to ensure that objects don't already exist in the collection  | 
                                                        |
| 455 | -        foreach ($objects as $key => $object) { | 
                                                        |
| 456 | -            if ($this->contains($object)) { | 
                                                        |
| 457 | - unset($objects[ $key ]);  | 
                                                        |
| 458 | - }  | 
                                                        |
| 459 | - }  | 
                                                        |
| 460 | - // do we have any objects left?  | 
                                                        |
| 461 | -        if (! $objects) { | 
                                                        |
| 462 | - return;  | 
                                                        |
| 463 | - }  | 
                                                        |
| 464 | - // detach any objects at or past this index  | 
                                                        |
| 465 | - $remaining = array();  | 
                                                        |
| 466 | -        if ($index < $this->count()) { | 
                                                        |
| 467 | - $remaining = $this->slice($index, $this->count() - $index);  | 
                                                        |
| 468 | -            foreach ($remaining as $object) { | 
                                                        |
| 469 | - $this->detach($object);  | 
                                                        |
| 470 | - }  | 
                                                        |
| 471 | - }  | 
                                                        |
| 472 | - // add the new objects we're splicing in  | 
                                                        |
| 473 | -        foreach ($objects as $object) { | 
                                                        |
| 474 | - $this->attach($object);  | 
                                                        |
| 475 | - }  | 
                                                        |
| 476 | - // attach the objects we previously detached  | 
                                                        |
| 477 | -        foreach ($remaining as $object) { | 
                                                        |
| 478 | - $this->attach($object);  | 
                                                        |
| 479 | - }  | 
                                                        |
| 480 | - }  | 
                                                        |
| 481 | -  | 
                                                        |
| 482 | -  | 
                                                        |
| 483 | - /**  | 
                                                        |
| 484 | - * Removes the object at the given index  | 
                                                        |
| 485 | - *  | 
                                                        |
| 486 | - * @see http://stackoverflow.com/a/8736013  | 
                                                        |
| 487 | - * @param int $index  | 
                                                        |
| 488 | - */  | 
                                                        |
| 489 | - public function removeAt($index)  | 
                                                        |
| 490 | -    { | 
                                                        |
| 491 | - $this->detach($this->objectAtIndex($index));  | 
                                                        |
| 492 | - }  | 
                                                        |
| 493 | -  | 
                                                        |
| 494 | -  | 
                                                        |
| 495 | - /**  | 
                                                        |
| 496 | - * detaches ALL objects from the Collection  | 
                                                        |
| 497 | - */  | 
                                                        |
| 498 | - public function detachAll()  | 
                                                        |
| 499 | -    { | 
                                                        |
| 500 | - $this->rewind();  | 
                                                        |
| 501 | -        while ($this->valid()) { | 
                                                        |
| 502 | - $object = $this->current();  | 
                                                        |
| 503 | - $this->next();  | 
                                                        |
| 504 | - $this->detach($object);  | 
                                                        |
| 505 | - }  | 
                                                        |
| 506 | - }  | 
                                                        |
| 507 | -  | 
                                                        |
| 508 | -  | 
                                                        |
| 509 | - /**  | 
                                                        |
| 510 | - * unsets and detaches ALL objects from the Collection  | 
                                                        |
| 511 | - */  | 
                                                        |
| 512 | - public function trashAndDetachAll()  | 
                                                        |
| 513 | -    { | 
                                                        |
| 514 | - $this->rewind();  | 
                                                        |
| 515 | -        while ($this->valid()) { | 
                                                        |
| 516 | - $object = $this->current();  | 
                                                        |
| 517 | - $this->next();  | 
                                                        |
| 518 | - $this->detach($object);  | 
                                                        |
| 519 | - unset($object);  | 
                                                        |
| 520 | - }  | 
                                                        |
| 521 | - }  | 
                                                        |
| 22 | + /**  | 
                                                        |
| 23 | + * a unique string for identifying this collection  | 
                                                        |
| 24 | + *  | 
                                                        |
| 25 | + * @type string $collection_identifier  | 
                                                        |
| 26 | + */  | 
                                                        |
| 27 | + protected $collection_identifier;  | 
                                                        |
| 28 | +  | 
                                                        |
| 29 | +  | 
                                                        |
| 30 | + /**  | 
                                                        |
| 31 | + * an interface (or class) name to be used for restricting the type of objects added to the storage  | 
                                                        |
| 32 | + * this should be set from within the child class constructor  | 
                                                        |
| 33 | + *  | 
                                                        |
| 34 | + * @type string $interface  | 
                                                        |
| 35 | + */  | 
                                                        |
| 36 | + protected $collection_interface;  | 
                                                        |
| 37 | +  | 
                                                        |
| 38 | + /**  | 
                                                        |
| 39 | + * a short dash separated string describing the contents of this collection  | 
                                                        |
| 40 | + * used as the base for the $collection_identifier  | 
                                                        |
| 41 | + * defaults to the class short name if not set  | 
                                                        |
| 42 | + *  | 
                                                        |
| 43 | + * @type string $collection_identifier  | 
                                                        |
| 44 | + */  | 
                                                        |
| 45 | + protected $collection_name;  | 
                                                        |
| 46 | +  | 
                                                        |
| 47 | +  | 
                                                        |
| 48 | + /**  | 
                                                        |
| 49 | + * Collection constructor  | 
                                                        |
| 50 | + *  | 
                                                        |
| 51 | + * @param string $collection_interface  | 
                                                        |
| 52 | + * @param string $collection_name  | 
                                                        |
| 53 | + * @throws InvalidInterfaceException  | 
                                                        |
| 54 | + */  | 
                                                        |
| 55 | + public function __construct($collection_interface, $collection_name = '')  | 
                                                        |
| 56 | +	{ | 
                                                        |
| 57 | + $this->setCollectionInterface($collection_interface);  | 
                                                        |
| 58 | + $this->setCollectionName($collection_name);  | 
                                                        |
| 59 | + $this->setCollectionIdentifier();  | 
                                                        |
| 60 | + }  | 
                                                        |
| 61 | +  | 
                                                        |
| 62 | +  | 
                                                        |
| 63 | + /**  | 
                                                        |
| 64 | + * setCollectionInterface  | 
                                                        |
| 65 | + *  | 
                                                        |
| 66 | + * @param string $collection_interface  | 
                                                        |
| 67 | + * @throws InvalidInterfaceException  | 
                                                        |
| 68 | + */  | 
                                                        |
| 69 | + protected function setCollectionInterface($collection_interface)  | 
                                                        |
| 70 | +	{ | 
                                                        |
| 71 | +		if (! (interface_exists($collection_interface) || class_exists($collection_interface))) { | 
                                                        |
| 72 | + throw new InvalidInterfaceException($collection_interface);  | 
                                                        |
| 73 | + }  | 
                                                        |
| 74 | + $this->collection_interface = $collection_interface;  | 
                                                        |
| 75 | + }  | 
                                                        |
| 76 | +  | 
                                                        |
| 77 | +  | 
                                                        |
| 78 | + /**  | 
                                                        |
| 79 | + * @return string  | 
                                                        |
| 80 | + */  | 
                                                        |
| 81 | + public function collectionName()  | 
                                                        |
| 82 | +	{ | 
                                                        |
| 83 | + return $this->collection_name;  | 
                                                        |
| 84 | + }  | 
                                                        |
| 85 | +  | 
                                                        |
| 86 | +  | 
                                                        |
| 87 | + /**  | 
                                                        |
| 88 | + * @param string $collection_name  | 
                                                        |
| 89 | + */  | 
                                                        |
| 90 | + protected function setCollectionName($collection_name)  | 
                                                        |
| 91 | +	{ | 
                                                        |
| 92 | + $this->collection_name = ! empty($collection_name)  | 
                                                        |
| 93 | + ? sanitize_key($collection_name)  | 
                                                        |
| 94 | +			: basename(str_replace('\\', '/', get_class($this))); | 
                                                        |
| 95 | + }  | 
                                                        |
| 96 | +  | 
                                                        |
| 97 | +  | 
                                                        |
| 98 | + /**  | 
                                                        |
| 99 | + * @return string  | 
                                                        |
| 100 | + */  | 
                                                        |
| 101 | + public function collectionIdentifier()  | 
                                                        |
| 102 | +	{ | 
                                                        |
| 103 | + return $this->collection_identifier;  | 
                                                        |
| 104 | + }  | 
                                                        |
| 105 | +  | 
                                                        |
| 106 | +  | 
                                                        |
| 107 | + /**  | 
                                                        |
| 108 | + * creates a very readable unique 9 character identifier like: CF2-532-DAC  | 
                                                        |
| 109 | + * and appends it to the non-qualified class name, ex: ThingCollection-CF2-532-DAC  | 
                                                        |
| 110 | + *  | 
                                                        |
| 111 | + * @return void  | 
                                                        |
| 112 | + */  | 
                                                        |
| 113 | + protected function setCollectionIdentifier()  | 
                                                        |
| 114 | +	{ | 
                                                        |
| 115 | + // hash a few collection details  | 
                                                        |
| 116 | + $identifier = md5(spl_object_hash($this) . $this->collection_interface . time());  | 
                                                        |
| 117 | + // grab a few characters from the start, middle, and end of the hash  | 
                                                        |
| 118 | + $id = array();  | 
                                                        |
| 119 | +		for ($x = 0; $x < 19; $x += 9) { | 
                                                        |
| 120 | + $id[] = substr($identifier, $x, 3);  | 
                                                        |
| 121 | + }  | 
                                                        |
| 122 | +		$this->collection_identifier = $this->collection_name . '-' . strtoupper(implode('-', $id)); | 
                                                        |
| 123 | + }  | 
                                                        |
| 124 | +  | 
                                                        |
| 125 | +  | 
                                                        |
| 126 | + /**  | 
                                                        |
| 127 | + * add  | 
                                                        |
| 128 | + * attaches an object to the Collection  | 
                                                        |
| 129 | + * and sets any supplied data associated with the current iterator entry  | 
                                                        |
| 130 | + * by calling EE_Object_Collection::set_identifier()  | 
                                                        |
| 131 | + *  | 
                                                        |
| 132 | + * @param $object  | 
                                                        |
| 133 | + * @param mixed $identifier  | 
                                                        |
| 134 | + * @return bool  | 
                                                        |
| 135 | + * @throws InvalidEntityException  | 
                                                        |
| 136 | + * @throws DuplicateCollectionIdentifierException  | 
                                                        |
| 137 | + */  | 
                                                        |
| 138 | + public function add($object, $identifier = null)  | 
                                                        |
| 139 | +	{ | 
                                                        |
| 140 | +		if (! $object instanceof $this->collection_interface) { | 
                                                        |
| 141 | + throw new InvalidEntityException($object, $this->collection_interface);  | 
                                                        |
| 142 | + }  | 
                                                        |
| 143 | +		if ($this->contains($object)) { | 
                                                        |
| 144 | + throw new DuplicateCollectionIdentifierException($identifier);  | 
                                                        |
| 145 | + }  | 
                                                        |
| 146 | + $this->attach($object);  | 
                                                        |
| 147 | + $this->setIdentifier($object, $identifier);  | 
                                                        |
| 148 | + return $this->contains($object);  | 
                                                        |
| 149 | + }  | 
                                                        |
| 150 | +  | 
                                                        |
| 151 | +  | 
                                                        |
| 152 | + /**  | 
                                                        |
| 153 | + * getIdentifier  | 
                                                        |
| 154 | + * if no $identifier is supplied, then the spl_object_hash() is used  | 
                                                        |
| 155 | + *  | 
                                                        |
| 156 | + * @param $object  | 
                                                        |
| 157 | + * @param mixed $identifier  | 
                                                        |
| 158 | + * @return bool  | 
                                                        |
| 159 | + */  | 
                                                        |
| 160 | + public function getIdentifier($object, $identifier = null)  | 
                                                        |
| 161 | +	{ | 
                                                        |
| 162 | + return ! empty($identifier)  | 
                                                        |
| 163 | + ? $identifier  | 
                                                        |
| 164 | + : spl_object_hash($object);  | 
                                                        |
| 165 | + }  | 
                                                        |
| 166 | +  | 
                                                        |
| 167 | +  | 
                                                        |
| 168 | + /**  | 
                                                        |
| 169 | + * setIdentifier  | 
                                                        |
| 170 | + * Sets the data associated with an object in the Collection  | 
                                                        |
| 171 | + * if no $identifier is supplied, then the spl_object_hash() is used  | 
                                                        |
| 172 | + *  | 
                                                        |
| 173 | + * @param $object  | 
                                                        |
| 174 | + * @param mixed $identifier  | 
                                                        |
| 175 | + * @return bool  | 
                                                        |
| 176 | + */  | 
                                                        |
| 177 | + public function setIdentifier($object, $identifier = null)  | 
                                                        |
| 178 | +	{ | 
                                                        |
| 179 | + $identifier = $this->getIdentifier($object, $identifier);  | 
                                                        |
| 180 | + $this->rewind();  | 
                                                        |
| 181 | +		while ($this->valid()) { | 
                                                        |
| 182 | +			if ($object === $this->current()) { | 
                                                        |
| 183 | + $this->setInfo($identifier);  | 
                                                        |
| 184 | + $this->rewind();  | 
                                                        |
| 185 | + return true;  | 
                                                        |
| 186 | + }  | 
                                                        |
| 187 | + $this->next();  | 
                                                        |
| 188 | + }  | 
                                                        |
| 189 | + return false;  | 
                                                        |
| 190 | + }  | 
                                                        |
| 191 | +  | 
                                                        |
| 192 | +  | 
                                                        |
| 193 | + /**  | 
                                                        |
| 194 | + * get  | 
                                                        |
| 195 | + * finds and returns an object in the Collection based on the identifier that was set using addObject()  | 
                                                        |
| 196 | + * PLZ NOTE: the pointer is reset to the beginning of the collection before returning  | 
                                                        |
| 197 | + *  | 
                                                        |
| 198 | + * @param mixed $identifier  | 
                                                        |
| 199 | + * @return mixed  | 
                                                        |
| 200 | + */  | 
                                                        |
| 201 | + public function get($identifier)  | 
                                                        |
| 202 | +	{ | 
                                                        |
| 203 | + $this->rewind();  | 
                                                        |
| 204 | +		while ($this->valid()) { | 
                                                        |
| 205 | +			if ($identifier === $this->getInfo()) { | 
                                                        |
| 206 | + $object = $this->current();  | 
                                                        |
| 207 | + $this->rewind();  | 
                                                        |
| 208 | + return $object;  | 
                                                        |
| 209 | + }  | 
                                                        |
| 210 | + $this->next();  | 
                                                        |
| 211 | + }  | 
                                                        |
| 212 | + return null;  | 
                                                        |
| 213 | + }  | 
                                                        |
| 214 | +  | 
                                                        |
| 215 | +  | 
                                                        |
| 216 | + /**  | 
                                                        |
| 217 | + * has  | 
                                                        |
| 218 | + * returns TRUE or FALSE  | 
                                                        |
| 219 | + * depending on whether the object is within the Collection  | 
                                                        |
| 220 | + * based on the supplied $identifier  | 
                                                        |
| 221 | + *  | 
                                                        |
| 222 | + * @param mixed $identifier  | 
                                                        |
| 223 | + * @return bool  | 
                                                        |
| 224 | + */  | 
                                                        |
| 225 | + public function has($identifier)  | 
                                                        |
| 226 | +	{ | 
                                                        |
| 227 | + $this->rewind();  | 
                                                        |
| 228 | +		while ($this->valid()) { | 
                                                        |
| 229 | +			if ($identifier === $this->getInfo()) { | 
                                                        |
| 230 | + $this->rewind();  | 
                                                        |
| 231 | + return true;  | 
                                                        |
| 232 | + }  | 
                                                        |
| 233 | + $this->next();  | 
                                                        |
| 234 | + }  | 
                                                        |
| 235 | + return false;  | 
                                                        |
| 236 | + }  | 
                                                        |
| 237 | +  | 
                                                        |
| 238 | +  | 
                                                        |
| 239 | + /**  | 
                                                        |
| 240 | + * hasObject  | 
                                                        |
| 241 | + * returns TRUE or FALSE depending on whether the supplied object is within the Collection  | 
                                                        |
| 242 | + *  | 
                                                        |
| 243 | + * @param $object  | 
                                                        |
| 244 | + * @return bool  | 
                                                        |
| 245 | + */  | 
                                                        |
| 246 | + public function hasObject($object)  | 
                                                        |
| 247 | +	{ | 
                                                        |
| 248 | + return $this->contains($object);  | 
                                                        |
| 249 | + }  | 
                                                        |
| 250 | +  | 
                                                        |
| 251 | +  | 
                                                        |
| 252 | + /**  | 
                                                        |
| 253 | + * hasObjects  | 
                                                        |
| 254 | + * returns true if there are objects within the Collection, and false if it is empty  | 
                                                        |
| 255 | + *  | 
                                                        |
| 256 | + * @return bool  | 
                                                        |
| 257 | + */  | 
                                                        |
| 258 | + public function hasObjects()  | 
                                                        |
| 259 | +	{ | 
                                                        |
| 260 | + return $this->count() !== 0;  | 
                                                        |
| 261 | + }  | 
                                                        |
| 262 | +  | 
                                                        |
| 263 | +  | 
                                                        |
| 264 | + /**  | 
                                                        |
| 265 | + * isEmpty  | 
                                                        |
| 266 | + * returns true if there are no objects within the Collection, and false if there are  | 
                                                        |
| 267 | + *  | 
                                                        |
| 268 | + * @return bool  | 
                                                        |
| 269 | + */  | 
                                                        |
| 270 | + public function isEmpty()  | 
                                                        |
| 271 | +	{ | 
                                                        |
| 272 | + return $this->count() === 0;  | 
                                                        |
| 273 | + }  | 
                                                        |
| 274 | +  | 
                                                        |
| 275 | +  | 
                                                        |
| 276 | + /**  | 
                                                        |
| 277 | + * remove  | 
                                                        |
| 278 | + * detaches an object from the Collection  | 
                                                        |
| 279 | + *  | 
                                                        |
| 280 | + * @param $object  | 
                                                        |
| 281 | + * @return bool  | 
                                                        |
| 282 | + */  | 
                                                        |
| 283 | + public function remove($object)  | 
                                                        |
| 284 | +	{ | 
                                                        |
| 285 | + $this->detach($object);  | 
                                                        |
| 286 | + return true;  | 
                                                        |
| 287 | + }  | 
                                                        |
| 288 | +  | 
                                                        |
| 289 | +  | 
                                                        |
| 290 | + /**  | 
                                                        |
| 291 | + * setCurrent  | 
                                                        |
| 292 | + * advances pointer to the object whose identifier matches that which was provided  | 
                                                        |
| 293 | + *  | 
                                                        |
| 294 | + * @param mixed $identifier  | 
                                                        |
| 295 | + * @return boolean  | 
                                                        |
| 296 | + */  | 
                                                        |
| 297 | + public function setCurrent($identifier)  | 
                                                        |
| 298 | +	{ | 
                                                        |
| 299 | + $this->rewind();  | 
                                                        |
| 300 | +		while ($this->valid()) { | 
                                                        |
| 301 | +			if ($identifier === $this->getInfo()) { | 
                                                        |
| 302 | + return true;  | 
                                                        |
| 303 | + }  | 
                                                        |
| 304 | + $this->next();  | 
                                                        |
| 305 | + }  | 
                                                        |
| 306 | + return false;  | 
                                                        |
| 307 | + }  | 
                                                        |
| 308 | +  | 
                                                        |
| 309 | +  | 
                                                        |
| 310 | + /**  | 
                                                        |
| 311 | + * setCurrentUsingObject  | 
                                                        |
| 312 | + * advances pointer to the provided object  | 
                                                        |
| 313 | + *  | 
                                                        |
| 314 | + * @param $object  | 
                                                        |
| 315 | + * @return boolean  | 
                                                        |
| 316 | + */  | 
                                                        |
| 317 | + public function setCurrentUsingObject($object)  | 
                                                        |
| 318 | +	{ | 
                                                        |
| 319 | + $this->rewind();  | 
                                                        |
| 320 | +		while ($this->valid()) { | 
                                                        |
| 321 | +			if ($this->current() === $object) { | 
                                                        |
| 322 | + return true;  | 
                                                        |
| 323 | + }  | 
                                                        |
| 324 | + $this->next();  | 
                                                        |
| 325 | + }  | 
                                                        |
| 326 | + return false;  | 
                                                        |
| 327 | + }  | 
                                                        |
| 328 | +  | 
                                                        |
| 329 | +  | 
                                                        |
| 330 | + /**  | 
                                                        |
| 331 | + * Returns the object occupying the index before the current object,  | 
                                                        |
| 332 | + * unless this is already the first object, in which case it just returns the first object  | 
                                                        |
| 333 | + *  | 
                                                        |
| 334 | + * @return mixed  | 
                                                        |
| 335 | + */  | 
                                                        |
| 336 | + public function previous()  | 
                                                        |
| 337 | +	{ | 
                                                        |
| 338 | + $index = $this->indexOf($this->current());  | 
                                                        |
| 339 | +		if ($index === 0) { | 
                                                        |
| 340 | + return $this->current();  | 
                                                        |
| 341 | + }  | 
                                                        |
| 342 | + $index--;  | 
                                                        |
| 343 | + return $this->objectAtIndex($index);  | 
                                                        |
| 344 | + }  | 
                                                        |
| 345 | +  | 
                                                        |
| 346 | +  | 
                                                        |
| 347 | + /**  | 
                                                        |
| 348 | + * Returns the index of a given object, or false if not found  | 
                                                        |
| 349 | + *  | 
                                                        |
| 350 | + * @see http://stackoverflow.com/a/8736013  | 
                                                        |
| 351 | + * @param $object  | 
                                                        |
| 352 | + * @return boolean|int|string  | 
                                                        |
| 353 | + */  | 
                                                        |
| 354 | + public function indexOf($object)  | 
                                                        |
| 355 | +	{ | 
                                                        |
| 356 | +		if (! $this->contains($object)) { | 
                                                        |
| 357 | + return false;  | 
                                                        |
| 358 | + }  | 
                                                        |
| 359 | +		foreach ($this as $index => $obj) { | 
                                                        |
| 360 | +			if ($obj === $object) { | 
                                                        |
| 361 | + return $index;  | 
                                                        |
| 362 | + }  | 
                                                        |
| 363 | + }  | 
                                                        |
| 364 | + return false;  | 
                                                        |
| 365 | + }  | 
                                                        |
| 366 | +  | 
                                                        |
| 367 | +  | 
                                                        |
| 368 | + /**  | 
                                                        |
| 369 | + * Returns the object at the given index  | 
                                                        |
| 370 | + *  | 
                                                        |
| 371 | + * @see http://stackoverflow.com/a/8736013  | 
                                                        |
| 372 | + * @param int $index  | 
                                                        |
| 373 | + * @return mixed  | 
                                                        |
| 374 | + */  | 
                                                        |
| 375 | + public function objectAtIndex($index)  | 
                                                        |
| 376 | +	{ | 
                                                        |
| 377 | + $iterator = new LimitIterator($this, $index, 1);  | 
                                                        |
| 378 | + $iterator->rewind();  | 
                                                        |
| 379 | + return $iterator->current();  | 
                                                        |
| 380 | + }  | 
                                                        |
| 381 | +  | 
                                                        |
| 382 | +  | 
                                                        |
| 383 | + /**  | 
                                                        |
| 384 | + * Returns the sequence of objects as specified by the offset and length  | 
                                                        |
| 385 | + *  | 
                                                        |
| 386 | + * @see http://stackoverflow.com/a/8736013  | 
                                                        |
| 387 | + * @param int $offset  | 
                                                        |
| 388 | + * @param int $length  | 
                                                        |
| 389 | + * @return array  | 
                                                        |
| 390 | + */  | 
                                                        |
| 391 | + public function slice($offset, $length)  | 
                                                        |
| 392 | +	{ | 
                                                        |
| 393 | + $slice = array();  | 
                                                        |
| 394 | + $iterator = new LimitIterator($this, $offset, $length);  | 
                                                        |
| 395 | +		foreach ($iterator as $object) { | 
                                                        |
| 396 | + $slice[] = $object;  | 
                                                        |
| 397 | + }  | 
                                                        |
| 398 | + return $slice;  | 
                                                        |
| 399 | + }  | 
                                                        |
| 400 | +  | 
                                                        |
| 401 | +  | 
                                                        |
| 402 | + /**  | 
                                                        |
| 403 | + * Inserts an object at a certain point  | 
                                                        |
| 404 | + *  | 
                                                        |
| 405 | + * @see http://stackoverflow.com/a/8736013  | 
                                                        |
| 406 | + * @param mixed $object A single object  | 
                                                        |
| 407 | + * @param int $index  | 
                                                        |
| 408 | + * @param mixed $identifier  | 
                                                        |
| 409 | + * @return bool  | 
                                                        |
| 410 | + * @throws DuplicateCollectionIdentifierException  | 
                                                        |
| 411 | + * @throws InvalidEntityException  | 
                                                        |
| 412 | + */  | 
                                                        |
| 413 | + public function insertObjectAt($object, $index, $identifier = null)  | 
                                                        |
| 414 | +	{ | 
                                                        |
| 415 | + // check to ensure that objects don't already exist in the collection  | 
                                                        |
| 416 | +		if ($this->has($identifier)) { | 
                                                        |
| 417 | + throw new DuplicateCollectionIdentifierException($identifier);  | 
                                                        |
| 418 | + }  | 
                                                        |
| 419 | + // detach any objects at or past this index  | 
                                                        |
| 420 | + $remaining_objects = array();  | 
                                                        |
| 421 | +		if ($index < $this->count()) { | 
                                                        |
| 422 | + $remaining_objects = $this->slice($index, $this->count() - $index);  | 
                                                        |
| 423 | +			foreach ($remaining_objects as $key => $remaining_object) { | 
                                                        |
| 424 | + // we need to grab the identifiers for each object and use them as keys  | 
                                                        |
| 425 | + $remaining_objects[ $remaining_object->getInfo() ] = $remaining_object;  | 
                                                        |
| 426 | + // and then remove the object from the current tracking array  | 
                                                        |
| 427 | + unset($remaining_objects[ $key ]);  | 
                                                        |
| 428 | + // and then remove it from the Collection  | 
                                                        |
| 429 | + $this->detach($remaining_object);  | 
                                                        |
| 430 | + }  | 
                                                        |
| 431 | + }  | 
                                                        |
| 432 | + // add the new object we're splicing in  | 
                                                        |
| 433 | + $this->add($object, $identifier);  | 
                                                        |
| 434 | + // attach the objects we previously detached  | 
                                                        |
| 435 | +		foreach ($remaining_objects as $key => $remaining_object) { | 
                                                        |
| 436 | + $this->add($remaining_object, $key);  | 
                                                        |
| 437 | + }  | 
                                                        |
| 438 | + return $this->contains($object);  | 
                                                        |
| 439 | + }  | 
                                                        |
| 440 | +  | 
                                                        |
| 441 | +  | 
                                                        |
| 442 | + /**  | 
                                                        |
| 443 | + * Inserts an object (or an array of objects) at a certain point  | 
                                                        |
| 444 | + *  | 
                                                        |
| 445 | + * @see http://stackoverflow.com/a/8736013  | 
                                                        |
| 446 | + * @param mixed $objects A single object or an array of objects  | 
                                                        |
| 447 | + * @param int $index  | 
                                                        |
| 448 | + */  | 
                                                        |
| 449 | + public function insertAt($objects, $index)  | 
                                                        |
| 450 | +	{ | 
                                                        |
| 451 | +		if (! is_array($objects)) { | 
                                                        |
| 452 | + $objects = array($objects);  | 
                                                        |
| 453 | + }  | 
                                                        |
| 454 | + // check to ensure that objects don't already exist in the collection  | 
                                                        |
| 455 | +		foreach ($objects as $key => $object) { | 
                                                        |
| 456 | +			if ($this->contains($object)) { | 
                                                        |
| 457 | + unset($objects[ $key ]);  | 
                                                        |
| 458 | + }  | 
                                                        |
| 459 | + }  | 
                                                        |
| 460 | + // do we have any objects left?  | 
                                                        |
| 461 | +		if (! $objects) { | 
                                                        |
| 462 | + return;  | 
                                                        |
| 463 | + }  | 
                                                        |
| 464 | + // detach any objects at or past this index  | 
                                                        |
| 465 | + $remaining = array();  | 
                                                        |
| 466 | +		if ($index < $this->count()) { | 
                                                        |
| 467 | + $remaining = $this->slice($index, $this->count() - $index);  | 
                                                        |
| 468 | +			foreach ($remaining as $object) { | 
                                                        |
| 469 | + $this->detach($object);  | 
                                                        |
| 470 | + }  | 
                                                        |
| 471 | + }  | 
                                                        |
| 472 | + // add the new objects we're splicing in  | 
                                                        |
| 473 | +		foreach ($objects as $object) { | 
                                                        |
| 474 | + $this->attach($object);  | 
                                                        |
| 475 | + }  | 
                                                        |
| 476 | + // attach the objects we previously detached  | 
                                                        |
| 477 | +		foreach ($remaining as $object) { | 
                                                        |
| 478 | + $this->attach($object);  | 
                                                        |
| 479 | + }  | 
                                                        |
| 480 | + }  | 
                                                        |
| 481 | +  | 
                                                        |
| 482 | +  | 
                                                        |
| 483 | + /**  | 
                                                        |
| 484 | + * Removes the object at the given index  | 
                                                        |
| 485 | + *  | 
                                                        |
| 486 | + * @see http://stackoverflow.com/a/8736013  | 
                                                        |
| 487 | + * @param int $index  | 
                                                        |
| 488 | + */  | 
                                                        |
| 489 | + public function removeAt($index)  | 
                                                        |
| 490 | +	{ | 
                                                        |
| 491 | + $this->detach($this->objectAtIndex($index));  | 
                                                        |
| 492 | + }  | 
                                                        |
| 493 | +  | 
                                                        |
| 494 | +  | 
                                                        |
| 495 | + /**  | 
                                                        |
| 496 | + * detaches ALL objects from the Collection  | 
                                                        |
| 497 | + */  | 
                                                        |
| 498 | + public function detachAll()  | 
                                                        |
| 499 | +	{ | 
                                                        |
| 500 | + $this->rewind();  | 
                                                        |
| 501 | +		while ($this->valid()) { | 
                                                        |
| 502 | + $object = $this->current();  | 
                                                        |
| 503 | + $this->next();  | 
                                                        |
| 504 | + $this->detach($object);  | 
                                                        |
| 505 | + }  | 
                                                        |
| 506 | + }  | 
                                                        |
| 507 | +  | 
                                                        |
| 508 | +  | 
                                                        |
| 509 | + /**  | 
                                                        |
| 510 | + * unsets and detaches ALL objects from the Collection  | 
                                                        |
| 511 | + */  | 
                                                        |
| 512 | + public function trashAndDetachAll()  | 
                                                        |
| 513 | +	{ | 
                                                        |
| 514 | + $this->rewind();  | 
                                                        |
| 515 | +		while ($this->valid()) { | 
                                                        |
| 516 | + $object = $this->current();  | 
                                                        |
| 517 | + $this->next();  | 
                                                        |
| 518 | + $this->detach($object);  | 
                                                        |
| 519 | + unset($object);  | 
                                                        |
| 520 | + }  | 
                                                        |
| 521 | + }  | 
                                                        |
| 522 | 522 | }  | 
                                                        
@@ -175,7 +175,7 @@  | 
                                                    ||
| 175 | 175 | |
| 176 | 176 | /**  | 
                                                        
| 177 | 177 | * @param $entity  | 
                                                        
| 178 | - * @param mixed $identifier  | 
                                                        |
| 178 | + * @param string $identifier  | 
                                                        |
| 179 | 179 | * @return string  | 
                                                        
| 180 | 180 | * @throws InvalidEntityException  | 
                                                        
| 181 | 181 | * @throws DuplicateCollectionIdentifierException  | 
                                                        
@@ -29,295 +29,295 @@  | 
                                                    ||
| 29 | 29 | class CollectionLoader  | 
                                                        
| 30 | 30 |  { | 
                                                        
| 31 | 31 | |
| 32 | - /**  | 
                                                        |
| 33 | - * possible return value when adding entities to a collection.  | 
                                                        |
| 34 | - * denotes that the entity was NOT ADDED to the collection  | 
                                                        |
| 35 | - */  | 
                                                        |
| 36 | - const ENTITY_NOT_ADDED = 'entity-not-added-to-collection';  | 
                                                        |
| 32 | + /**  | 
                                                        |
| 33 | + * possible return value when adding entities to a collection.  | 
                                                        |
| 34 | + * denotes that the entity was NOT ADDED to the collection  | 
                                                        |
| 35 | + */  | 
                                                        |
| 36 | + const ENTITY_NOT_ADDED = 'entity-not-added-to-collection';  | 
                                                        |
| 37 | 37 | |
| 38 | - /**  | 
                                                        |
| 39 | - * possible return value when adding entities to a collection.  | 
                                                        |
| 40 | - * denotes that the entity was SUCCESSFULLY ADDED to the collection  | 
                                                        |
| 41 | - */  | 
                                                        |
| 42 | - const ENTITY_ADDED = 'entity-added-to-collection';  | 
                                                        |
| 38 | + /**  | 
                                                        |
| 39 | + * possible return value when adding entities to a collection.  | 
                                                        |
| 40 | + * denotes that the entity was SUCCESSFULLY ADDED to the collection  | 
                                                        |
| 41 | + */  | 
                                                        |
| 42 | + const ENTITY_ADDED = 'entity-added-to-collection';  | 
                                                        |
| 43 | 43 | |
| 44 | - /**  | 
                                                        |
| 45 | - * possible return value when adding entities to a collection.  | 
                                                        |
| 46 | - * denotes that the entity was ALREADY ADDED to the collection,  | 
                                                        |
| 47 | - * and therefore could not be added again.  | 
                                                        |
| 48 | - */  | 
                                                        |
| 49 | - const ENTITY_EXISTS = 'entity-already-in-collection';  | 
                                                        |
| 44 | + /**  | 
                                                        |
| 45 | + * possible return value when adding entities to a collection.  | 
                                                        |
| 46 | + * denotes that the entity was ALREADY ADDED to the collection,  | 
                                                        |
| 47 | + * and therefore could not be added again.  | 
                                                        |
| 48 | + */  | 
                                                        |
| 49 | + const ENTITY_EXISTS = 'entity-already-in-collection';  | 
                                                        |
| 50 | 50 | |
| 51 | 51 | |
| 52 | - /**  | 
                                                        |
| 53 | - * @var CollectionDetailsInterface $collection_details  | 
                                                        |
| 54 | - */  | 
                                                        |
| 55 | - protected $collection_details;  | 
                                                        |
| 52 | + /**  | 
                                                        |
| 53 | + * @var CollectionDetailsInterface $collection_details  | 
                                                        |
| 54 | + */  | 
                                                        |
| 55 | + protected $collection_details;  | 
                                                        |
| 56 | 56 | |
| 57 | - /**  | 
                                                        |
| 58 | - * @var CollectionInterface $collection  | 
                                                        |
| 59 | - */  | 
                                                        |
| 60 | - protected $collection;  | 
                                                        |
| 57 | + /**  | 
                                                        |
| 58 | + * @var CollectionInterface $collection  | 
                                                        |
| 59 | + */  | 
                                                        |
| 60 | + protected $collection;  | 
                                                        |
| 61 | 61 | |
| 62 | - /**  | 
                                                        |
| 63 | - * @var FactoryInterface $entity_factory  | 
                                                        |
| 64 | - */  | 
                                                        |
| 65 | - protected $entity_factory;  | 
                                                        |
| 62 | + /**  | 
                                                        |
| 63 | + * @var FactoryInterface $entity_factory  | 
                                                        |
| 64 | + */  | 
                                                        |
| 65 | + protected $entity_factory;  | 
                                                        |
| 66 | 66 | |
| 67 | - /**  | 
                                                        |
| 68 | - * @var FileLocator $file_locator  | 
                                                        |
| 69 | - */  | 
                                                        |
| 70 | - protected $file_locator;  | 
                                                        |
| 67 | + /**  | 
                                                        |
| 68 | + * @var FileLocator $file_locator  | 
                                                        |
| 69 | + */  | 
                                                        |
| 70 | + protected $file_locator;  | 
                                                        |
| 71 | 71 | |
| 72 | 72 | |
| 73 | - /**  | 
                                                        |
| 74 | - * CollectionLoader constructor.  | 
                                                        |
| 75 | - *  | 
                                                        |
| 76 | - * @param CollectionDetailsInterface $collection_details  | 
                                                        |
| 77 | - * @param CollectionInterface $collection  | 
                                                        |
| 78 | - * @param LocatorInterface $file_locator  | 
                                                        |
| 79 | - * @param FactoryInterface|null $entity_factory  | 
                                                        |
| 80 | - * @throws CollectionLoaderException  | 
                                                        |
| 81 | - */  | 
                                                        |
| 82 | - public function __construct(  | 
                                                        |
| 83 | - CollectionDetailsInterface $collection_details,  | 
                                                        |
| 84 | - CollectionInterface $collection = null,  | 
                                                        |
| 85 | - LocatorInterface $file_locator = null,  | 
                                                        |
| 86 | - FactoryInterface $entity_factory = null  | 
                                                        |
| 87 | -    ) { | 
                                                        |
| 88 | -        try { | 
                                                        |
| 89 | - $this->collection_details = $collection_details;  | 
                                                        |
| 90 | -            if (! $collection instanceof CollectionInterface) { | 
                                                        |
| 91 | - $collection = new Collection($this->collection_details->getCollectionInterface());  | 
                                                        |
| 92 | - }  | 
                                                        |
| 93 | - $this->collection = $collection;  | 
                                                        |
| 94 | - $this->file_locator = $file_locator;  | 
                                                        |
| 95 | - $this->entity_factory = $entity_factory;  | 
                                                        |
| 96 | - $this->loadAllFromFilepaths();  | 
                                                        |
| 97 | - $this->loadFromFQCNs();  | 
                                                        |
| 98 | -        } catch (Exception $exception) { | 
                                                        |
| 99 | - throw new CollectionLoaderException($exception);  | 
                                                        |
| 100 | - }  | 
                                                        |
| 101 | - }  | 
                                                        |
| 73 | + /**  | 
                                                        |
| 74 | + * CollectionLoader constructor.  | 
                                                        |
| 75 | + *  | 
                                                        |
| 76 | + * @param CollectionDetailsInterface $collection_details  | 
                                                        |
| 77 | + * @param CollectionInterface $collection  | 
                                                        |
| 78 | + * @param LocatorInterface $file_locator  | 
                                                        |
| 79 | + * @param FactoryInterface|null $entity_factory  | 
                                                        |
| 80 | + * @throws CollectionLoaderException  | 
                                                        |
| 81 | + */  | 
                                                        |
| 82 | + public function __construct(  | 
                                                        |
| 83 | + CollectionDetailsInterface $collection_details,  | 
                                                        |
| 84 | + CollectionInterface $collection = null,  | 
                                                        |
| 85 | + LocatorInterface $file_locator = null,  | 
                                                        |
| 86 | + FactoryInterface $entity_factory = null  | 
                                                        |
| 87 | +	) { | 
                                                        |
| 88 | +		try { | 
                                                        |
| 89 | + $this->collection_details = $collection_details;  | 
                                                        |
| 90 | +			if (! $collection instanceof CollectionInterface) { | 
                                                        |
| 91 | + $collection = new Collection($this->collection_details->getCollectionInterface());  | 
                                                        |
| 92 | + }  | 
                                                        |
| 93 | + $this->collection = $collection;  | 
                                                        |
| 94 | + $this->file_locator = $file_locator;  | 
                                                        |
| 95 | + $this->entity_factory = $entity_factory;  | 
                                                        |
| 96 | + $this->loadAllFromFilepaths();  | 
                                                        |
| 97 | + $this->loadFromFQCNs();  | 
                                                        |
| 98 | +		} catch (Exception $exception) { | 
                                                        |
| 99 | + throw new CollectionLoaderException($exception);  | 
                                                        |
| 100 | + }  | 
                                                        |
| 101 | + }  | 
                                                        |
| 102 | 102 | |
| 103 | 103 | |
| 104 | - /**  | 
                                                        |
| 105 | - * @return CollectionInterface  | 
                                                        |
| 106 | - */  | 
                                                        |
| 107 | - public function getCollection()  | 
                                                        |
| 108 | -    { | 
                                                        |
| 109 | - return $this->collection;  | 
                                                        |
| 110 | - }  | 
                                                        |
| 104 | + /**  | 
                                                        |
| 105 | + * @return CollectionInterface  | 
                                                        |
| 106 | + */  | 
                                                        |
| 107 | + public function getCollection()  | 
                                                        |
| 108 | +	{ | 
                                                        |
| 109 | + return $this->collection;  | 
                                                        |
| 110 | + }  | 
                                                        |
| 111 | 111 | |
| 112 | 112 | |
| 113 | - /**  | 
                                                        |
| 114 | - * @throws InvalidClassException  | 
                                                        |
| 115 | - * @throws InvalidFilePathException  | 
                                                        |
| 116 | - * @throws InvalidDataTypeException  | 
                                                        |
| 117 | - * @throws InvalidEntityException  | 
                                                        |
| 118 | - * @throws DuplicateCollectionIdentifierException  | 
                                                        |
| 119 | - */  | 
                                                        |
| 120 | - protected function loadAllFromFilepaths()  | 
                                                        |
| 121 | -    { | 
                                                        |
| 122 | -        if (! $this->file_locator instanceof FileLocator) { | 
                                                        |
| 123 | - $this->file_locator = new FileLocator();  | 
                                                        |
| 124 | - }  | 
                                                        |
| 125 | - $this->file_locator->setFileMask($this->collection_details->getFileMask());  | 
                                                        |
| 126 | - // find all of the files that match the file mask in the specified folder  | 
                                                        |
| 127 | - $this->file_locator->locate($this->collection_details->getCollectionPaths());  | 
                                                        |
| 128 | - // filter the results  | 
                                                        |
| 129 | - $filepaths = (array) apply_filters(  | 
                                                        |
| 130 | - 'FHEE__CollectionLoader__loadAllFromFilepath__filepaths',  | 
                                                        |
| 131 | - $this->file_locator->getFilePaths(),  | 
                                                        |
| 132 | - $this->collection_details->collectionName(),  | 
                                                        |
| 133 | - $this->collection_details  | 
                                                        |
| 134 | - );  | 
                                                        |
| 135 | -        if (empty($filepaths)) { | 
                                                        |
| 136 | - return;  | 
                                                        |
| 137 | - }  | 
                                                        |
| 138 | -        foreach ($filepaths as $filepath) { | 
                                                        |
| 139 | - $this->loadClassFromFilepath($filepath);  | 
                                                        |
| 140 | - }  | 
                                                        |
| 141 | - }  | 
                                                        |
| 113 | + /**  | 
                                                        |
| 114 | + * @throws InvalidClassException  | 
                                                        |
| 115 | + * @throws InvalidFilePathException  | 
                                                        |
| 116 | + * @throws InvalidDataTypeException  | 
                                                        |
| 117 | + * @throws InvalidEntityException  | 
                                                        |
| 118 | + * @throws DuplicateCollectionIdentifierException  | 
                                                        |
| 119 | + */  | 
                                                        |
| 120 | + protected function loadAllFromFilepaths()  | 
                                                        |
| 121 | +	{ | 
                                                        |
| 122 | +		if (! $this->file_locator instanceof FileLocator) { | 
                                                        |
| 123 | + $this->file_locator = new FileLocator();  | 
                                                        |
| 124 | + }  | 
                                                        |
| 125 | + $this->file_locator->setFileMask($this->collection_details->getFileMask());  | 
                                                        |
| 126 | + // find all of the files that match the file mask in the specified folder  | 
                                                        |
| 127 | + $this->file_locator->locate($this->collection_details->getCollectionPaths());  | 
                                                        |
| 128 | + // filter the results  | 
                                                        |
| 129 | + $filepaths = (array) apply_filters(  | 
                                                        |
| 130 | + 'FHEE__CollectionLoader__loadAllFromFilepath__filepaths',  | 
                                                        |
| 131 | + $this->file_locator->getFilePaths(),  | 
                                                        |
| 132 | + $this->collection_details->collectionName(),  | 
                                                        |
| 133 | + $this->collection_details  | 
                                                        |
| 134 | + );  | 
                                                        |
| 135 | +		if (empty($filepaths)) { | 
                                                        |
| 136 | + return;  | 
                                                        |
| 137 | + }  | 
                                                        |
| 138 | +		foreach ($filepaths as $filepath) { | 
                                                        |
| 139 | + $this->loadClassFromFilepath($filepath);  | 
                                                        |
| 140 | + }  | 
                                                        |
| 141 | + }  | 
                                                        |
| 142 | 142 | |
| 143 | 143 | |
| 144 | - /**  | 
                                                        |
| 145 | - * @param string $filepath  | 
                                                        |
| 146 | - * @return string  | 
                                                        |
| 147 | - * @throws InvalidEntityException  | 
                                                        |
| 148 | - * @throws InvalidDataTypeException  | 
                                                        |
| 149 | - * @throws InvalidFilePathException  | 
                                                        |
| 150 | - * @throws InvalidClassException  | 
                                                        |
| 151 | - * @throws DuplicateCollectionIdentifierException  | 
                                                        |
| 152 | - */  | 
                                                        |
| 153 | - protected function loadClassFromFilepath($filepath)  | 
                                                        |
| 154 | -    { | 
                                                        |
| 155 | -        if (! is_string($filepath)) { | 
                                                        |
| 156 | -            throw new InvalidDataTypeException('$filepath', $filepath, 'string'); | 
                                                        |
| 157 | - }  | 
                                                        |
| 158 | -        if (! is_readable($filepath)) { | 
                                                        |
| 159 | - throw new InvalidFilePathException($filepath);  | 
                                                        |
| 160 | - }  | 
                                                        |
| 161 | - require_once $filepath;  | 
                                                        |
| 162 | - // extract filename from path  | 
                                                        |
| 163 | - $file_name = basename($filepath);  | 
                                                        |
| 164 | - // now remove any file extensions  | 
                                                        |
| 165 | - $class_name = EEH_File::get_classname_from_filepath_with_standard_filename($file_name);  | 
                                                        |
| 166 | -        if (! class_exists($class_name)) { | 
                                                        |
| 167 | - throw new InvalidClassException($class_name);  | 
                                                        |
| 168 | - }  | 
                                                        |
| 169 | - $entity = $this->entity_factory instanceof FactoryInterface  | 
                                                        |
| 170 | - ? call_user_func(array($this->entity_factory, 'create'), $class_name)  | 
                                                        |
| 171 | - : new $class_name();  | 
                                                        |
| 172 | - return $this->addEntityToCollection($entity, $file_name);  | 
                                                        |
| 173 | - }  | 
                                                        |
| 144 | + /**  | 
                                                        |
| 145 | + * @param string $filepath  | 
                                                        |
| 146 | + * @return string  | 
                                                        |
| 147 | + * @throws InvalidEntityException  | 
                                                        |
| 148 | + * @throws InvalidDataTypeException  | 
                                                        |
| 149 | + * @throws InvalidFilePathException  | 
                                                        |
| 150 | + * @throws InvalidClassException  | 
                                                        |
| 151 | + * @throws DuplicateCollectionIdentifierException  | 
                                                        |
| 152 | + */  | 
                                                        |
| 153 | + protected function loadClassFromFilepath($filepath)  | 
                                                        |
| 154 | +	{ | 
                                                        |
| 155 | +		if (! is_string($filepath)) { | 
                                                        |
| 156 | +			throw new InvalidDataTypeException('$filepath', $filepath, 'string'); | 
                                                        |
| 157 | + }  | 
                                                        |
| 158 | +		if (! is_readable($filepath)) { | 
                                                        |
| 159 | + throw new InvalidFilePathException($filepath);  | 
                                                        |
| 160 | + }  | 
                                                        |
| 161 | + require_once $filepath;  | 
                                                        |
| 162 | + // extract filename from path  | 
                                                        |
| 163 | + $file_name = basename($filepath);  | 
                                                        |
| 164 | + // now remove any file extensions  | 
                                                        |
| 165 | + $class_name = EEH_File::get_classname_from_filepath_with_standard_filename($file_name);  | 
                                                        |
| 166 | +		if (! class_exists($class_name)) { | 
                                                        |
| 167 | + throw new InvalidClassException($class_name);  | 
                                                        |
| 168 | + }  | 
                                                        |
| 169 | + $entity = $this->entity_factory instanceof FactoryInterface  | 
                                                        |
| 170 | + ? call_user_func(array($this->entity_factory, 'create'), $class_name)  | 
                                                        |
| 171 | + : new $class_name();  | 
                                                        |
| 172 | + return $this->addEntityToCollection($entity, $file_name);  | 
                                                        |
| 173 | + }  | 
                                                        |
| 174 | 174 | |
| 175 | 175 | |
| 176 | - /**  | 
                                                        |
| 177 | - * @param $entity  | 
                                                        |
| 178 | - * @param mixed $identifier  | 
                                                        |
| 179 | - * @return string  | 
                                                        |
| 180 | - * @throws InvalidEntityException  | 
                                                        |
| 181 | - * @throws DuplicateCollectionIdentifierException  | 
                                                        |
| 182 | - */  | 
                                                        |
| 183 | - protected function addEntityToCollection($entity, $identifier)  | 
                                                        |
| 184 | -    { | 
                                                        |
| 185 | - do_action(  | 
                                                        |
| 186 | - 'FHEE__CollectionLoader__addEntityToCollection__entity',  | 
                                                        |
| 187 | - $entity,  | 
                                                        |
| 188 | - $this->collection_details->collectionName(),  | 
                                                        |
| 189 | - $this->collection_details  | 
                                                        |
| 190 | - );  | 
                                                        |
| 191 | - $identifier = $this->setIdentifier($entity, $identifier);  | 
                                                        |
| 192 | -        if ($this->collection->has($identifier)) { | 
                                                        |
| 193 | - do_action(  | 
                                                        |
| 194 | - 'FHEE__CollectionLoader__addEntityToCollection__entity_already_added',  | 
                                                        |
| 195 | - $this,  | 
                                                        |
| 196 | - $this->collection_details->collectionName(),  | 
                                                        |
| 197 | - $this->collection_details  | 
                                                        |
| 198 | - );  | 
                                                        |
| 199 | - return CollectionLoader::ENTITY_EXISTS;  | 
                                                        |
| 200 | - }  | 
                                                        |
| 201 | -        if ($this->collection->add($entity, $identifier)) { | 
                                                        |
| 202 | - do_action(  | 
                                                        |
| 203 | - 'FHEE__CollectionLoader__addEntityToCollection__entity_added',  | 
                                                        |
| 204 | - $this,  | 
                                                        |
| 205 | - $this->collection_details->collectionName(),  | 
                                                        |
| 206 | - $this->collection_details  | 
                                                        |
| 207 | - );  | 
                                                        |
| 208 | - return CollectionLoader::ENTITY_ADDED;  | 
                                                        |
| 209 | - }  | 
                                                        |
| 210 | - do_action(  | 
                                                        |
| 211 | - 'FHEE__CollectionLoader__addEntityToCollection__entity_not_added',  | 
                                                        |
| 212 | - $this,  | 
                                                        |
| 213 | - $this->collection_details->collectionName(),  | 
                                                        |
| 214 | - $this->collection_details  | 
                                                        |
| 215 | - );  | 
                                                        |
| 216 | - return CollectionLoader::ENTITY_NOT_ADDED;  | 
                                                        |
| 217 | - }  | 
                                                        |
| 176 | + /**  | 
                                                        |
| 177 | + * @param $entity  | 
                                                        |
| 178 | + * @param mixed $identifier  | 
                                                        |
| 179 | + * @return string  | 
                                                        |
| 180 | + * @throws InvalidEntityException  | 
                                                        |
| 181 | + * @throws DuplicateCollectionIdentifierException  | 
                                                        |
| 182 | + */  | 
                                                        |
| 183 | + protected function addEntityToCollection($entity, $identifier)  | 
                                                        |
| 184 | +	{ | 
                                                        |
| 185 | + do_action(  | 
                                                        |
| 186 | + 'FHEE__CollectionLoader__addEntityToCollection__entity',  | 
                                                        |
| 187 | + $entity,  | 
                                                        |
| 188 | + $this->collection_details->collectionName(),  | 
                                                        |
| 189 | + $this->collection_details  | 
                                                        |
| 190 | + );  | 
                                                        |
| 191 | + $identifier = $this->setIdentifier($entity, $identifier);  | 
                                                        |
| 192 | +		if ($this->collection->has($identifier)) { | 
                                                        |
| 193 | + do_action(  | 
                                                        |
| 194 | + 'FHEE__CollectionLoader__addEntityToCollection__entity_already_added',  | 
                                                        |
| 195 | + $this,  | 
                                                        |
| 196 | + $this->collection_details->collectionName(),  | 
                                                        |
| 197 | + $this->collection_details  | 
                                                        |
| 198 | + );  | 
                                                        |
| 199 | + return CollectionLoader::ENTITY_EXISTS;  | 
                                                        |
| 200 | + }  | 
                                                        |
| 201 | +		if ($this->collection->add($entity, $identifier)) { | 
                                                        |
| 202 | + do_action(  | 
                                                        |
| 203 | + 'FHEE__CollectionLoader__addEntityToCollection__entity_added',  | 
                                                        |
| 204 | + $this,  | 
                                                        |
| 205 | + $this->collection_details->collectionName(),  | 
                                                        |
| 206 | + $this->collection_details  | 
                                                        |
| 207 | + );  | 
                                                        |
| 208 | + return CollectionLoader::ENTITY_ADDED;  | 
                                                        |
| 209 | + }  | 
                                                        |
| 210 | + do_action(  | 
                                                        |
| 211 | + 'FHEE__CollectionLoader__addEntityToCollection__entity_not_added',  | 
                                                        |
| 212 | + $this,  | 
                                                        |
| 213 | + $this->collection_details->collectionName(),  | 
                                                        |
| 214 | + $this->collection_details  | 
                                                        |
| 215 | + );  | 
                                                        |
| 216 | + return CollectionLoader::ENTITY_NOT_ADDED;  | 
                                                        |
| 217 | + }  | 
                                                        |
| 218 | 218 | |
| 219 | 219 | |
| 220 | - /**  | 
                                                        |
| 221 | - * @param $entity  | 
                                                        |
| 222 | - * @param mixed $identifier  | 
                                                        |
| 223 | - * @return string  | 
                                                        |
| 224 | - * @throws InvalidEntityException  | 
                                                        |
| 225 | - */  | 
                                                        |
| 226 | - protected function setIdentifier($entity, $identifier)  | 
                                                        |
| 227 | -    { | 
                                                        |
| 228 | -        switch ($this->collection_details->identifierType()) { | 
                                                        |
| 229 | - // every unique object gets added to the collection, but not duplicates of the exact same object  | 
                                                        |
| 230 | - case CollectionDetails::ID_OBJECT_HASH:  | 
                                                        |
| 231 | - $identifier = spl_object_hash($entity);  | 
                                                        |
| 232 | - break;  | 
                                                        |
| 233 | - // only one entity per class can be added to collection, like a singleton  | 
                                                        |
| 234 | - case CollectionDetails::ID_CLASS_NAME:  | 
                                                        |
| 235 | - $identifier = get_class($entity);  | 
                                                        |
| 236 | - break;  | 
                                                        |
| 237 | - // objects added to the collection based on entity callback, so the entity itself decides  | 
                                                        |
| 238 | - case CollectionDetails::ID_CALLBACK_METHOD:  | 
                                                        |
| 239 | - $identifier_callback = $this->collection_details->identifierCallback();  | 
                                                        |
| 240 | -                if (! method_exists($entity, $identifier_callback)) { | 
                                                        |
| 241 | - throw new InvalidEntityException(  | 
                                                        |
| 242 | - $entity,  | 
                                                        |
| 243 | - $this->collection_details->getCollectionInterface(),  | 
                                                        |
| 244 | - sprintf(  | 
                                                        |
| 245 | - __(  | 
                                                        |
| 246 | - 'The current collection is configured to use a method named "%1$s" when setting or retrieving objects. The supplied entity is an instance  | 
                                                        |
| 220 | + /**  | 
                                                        |
| 221 | + * @param $entity  | 
                                                        |
| 222 | + * @param mixed $identifier  | 
                                                        |
| 223 | + * @return string  | 
                                                        |
| 224 | + * @throws InvalidEntityException  | 
                                                        |
| 225 | + */  | 
                                                        |
| 226 | + protected function setIdentifier($entity, $identifier)  | 
                                                        |
| 227 | +	{ | 
                                                        |
| 228 | +		switch ($this->collection_details->identifierType()) { | 
                                                        |
| 229 | + // every unique object gets added to the collection, but not duplicates of the exact same object  | 
                                                        |
| 230 | + case CollectionDetails::ID_OBJECT_HASH:  | 
                                                        |
| 231 | + $identifier = spl_object_hash($entity);  | 
                                                        |
| 232 | + break;  | 
                                                        |
| 233 | + // only one entity per class can be added to collection, like a singleton  | 
                                                        |
| 234 | + case CollectionDetails::ID_CLASS_NAME:  | 
                                                        |
| 235 | + $identifier = get_class($entity);  | 
                                                        |
| 236 | + break;  | 
                                                        |
| 237 | + // objects added to the collection based on entity callback, so the entity itself decides  | 
                                                        |
| 238 | + case CollectionDetails::ID_CALLBACK_METHOD:  | 
                                                        |
| 239 | + $identifier_callback = $this->collection_details->identifierCallback();  | 
                                                        |
| 240 | +				if (! method_exists($entity, $identifier_callback)) { | 
                                                        |
| 241 | + throw new InvalidEntityException(  | 
                                                        |
| 242 | + $entity,  | 
                                                        |
| 243 | + $this->collection_details->getCollectionInterface(),  | 
                                                        |
| 244 | + sprintf(  | 
                                                        |
| 245 | + __(  | 
                                                        |
| 246 | + 'The current collection is configured to use a method named "%1$s" when setting or retrieving objects. The supplied entity is an instance  | 
                                                        |
| 247 | 247 | of "%2$s", but does not contain this method.',  | 
                                                        
| 248 | - 'event_espresso'  | 
                                                        |
| 249 | - ),  | 
                                                        |
| 250 | - $identifier_callback,  | 
                                                        |
| 251 | - get_class($entity)  | 
                                                        |
| 252 | - )  | 
                                                        |
| 253 | - );  | 
                                                        |
| 254 | - }  | 
                                                        |
| 255 | -                $identifier = $entity->{$identifier_callback}(); | 
                                                        |
| 256 | - break;  | 
                                                        |
| 257 | - }  | 
                                                        |
| 258 | - return apply_filters(  | 
                                                        |
| 259 | - 'FHEE__CollectionLoader__addEntityToCollection__identifier',  | 
                                                        |
| 260 | - $identifier,  | 
                                                        |
| 261 | - $this->collection_details->collectionName(),  | 
                                                        |
| 262 | - $this->collection_details  | 
                                                        |
| 263 | - );  | 
                                                        |
| 264 | - }  | 
                                                        |
| 248 | + 'event_espresso'  | 
                                                        |
| 249 | + ),  | 
                                                        |
| 250 | + $identifier_callback,  | 
                                                        |
| 251 | + get_class($entity)  | 
                                                        |
| 252 | + )  | 
                                                        |
| 253 | + );  | 
                                                        |
| 254 | + }  | 
                                                        |
| 255 | +				$identifier = $entity->{$identifier_callback}(); | 
                                                        |
| 256 | + break;  | 
                                                        |
| 257 | + }  | 
                                                        |
| 258 | + return apply_filters(  | 
                                                        |
| 259 | + 'FHEE__CollectionLoader__addEntityToCollection__identifier',  | 
                                                        |
| 260 | + $identifier,  | 
                                                        |
| 261 | + $this->collection_details->collectionName(),  | 
                                                        |
| 262 | + $this->collection_details  | 
                                                        |
| 263 | + );  | 
                                                        |
| 264 | + }  | 
                                                        |
| 265 | 265 | |
| 266 | 266 | |
| 267 | - /**  | 
                                                        |
| 268 | - * @throws ReflectionException  | 
                                                        |
| 269 | - * @throws InvalidArgumentException  | 
                                                        |
| 270 | - * @throws InvalidInterfaceException  | 
                                                        |
| 271 | - * @throws EE_Error  | 
                                                        |
| 272 | - * @throws InvalidClassException  | 
                                                        |
| 273 | - * @throws InvalidDataTypeException  | 
                                                        |
| 274 | - * @throws InvalidEntityException  | 
                                                        |
| 275 | - * @throws DuplicateCollectionIdentifierException  | 
                                                        |
| 276 | - */  | 
                                                        |
| 277 | - protected function loadFromFQCNs()  | 
                                                        |
| 278 | -    { | 
                                                        |
| 279 | - $FQCNs = $this->collection_details->getCollectionFQCNs();  | 
                                                        |
| 280 | - $FQCNs = (array) apply_filters(  | 
                                                        |
| 281 | - 'FHEE__CollectionLoader__loadAllFromFQCNs__FQCNs',  | 
                                                        |
| 282 | - $FQCNs,  | 
                                                        |
| 283 | - $this->collection_details->collectionName(),  | 
                                                        |
| 284 | - $this->collection_details  | 
                                                        |
| 285 | - );  | 
                                                        |
| 286 | -        foreach ($FQCNs as $FQCN) { | 
                                                        |
| 287 | - $this->loadClassFromFQCN($FQCN);  | 
                                                        |
| 288 | - }  | 
                                                        |
| 289 | - }  | 
                                                        |
| 267 | + /**  | 
                                                        |
| 268 | + * @throws ReflectionException  | 
                                                        |
| 269 | + * @throws InvalidArgumentException  | 
                                                        |
| 270 | + * @throws InvalidInterfaceException  | 
                                                        |
| 271 | + * @throws EE_Error  | 
                                                        |
| 272 | + * @throws InvalidClassException  | 
                                                        |
| 273 | + * @throws InvalidDataTypeException  | 
                                                        |
| 274 | + * @throws InvalidEntityException  | 
                                                        |
| 275 | + * @throws DuplicateCollectionIdentifierException  | 
                                                        |
| 276 | + */  | 
                                                        |
| 277 | + protected function loadFromFQCNs()  | 
                                                        |
| 278 | +	{ | 
                                                        |
| 279 | + $FQCNs = $this->collection_details->getCollectionFQCNs();  | 
                                                        |
| 280 | + $FQCNs = (array) apply_filters(  | 
                                                        |
| 281 | + 'FHEE__CollectionLoader__loadAllFromFQCNs__FQCNs',  | 
                                                        |
| 282 | + $FQCNs,  | 
                                                        |
| 283 | + $this->collection_details->collectionName(),  | 
                                                        |
| 284 | + $this->collection_details  | 
                                                        |
| 285 | + );  | 
                                                        |
| 286 | +		foreach ($FQCNs as $FQCN) { | 
                                                        |
| 287 | + $this->loadClassFromFQCN($FQCN);  | 
                                                        |
| 288 | + }  | 
                                                        |
| 289 | + }  | 
                                                        |
| 290 | 290 | |
| 291 | 291 | |
| 292 | - /**  | 
                                                        |
| 293 | - * @param string $FQCN Fully Qualified Class Name  | 
                                                        |
| 294 | - * @return string  | 
                                                        |
| 295 | - * @throws InvalidArgumentException  | 
                                                        |
| 296 | - * @throws InvalidInterfaceException  | 
                                                        |
| 297 | - * @throws ReflectionException  | 
                                                        |
| 298 | - * @throws EE_Error  | 
                                                        |
| 299 | - * @throws InvalidEntityException  | 
                                                        |
| 300 | - * @throws InvalidDataTypeException  | 
                                                        |
| 301 | - * @throws InvalidClassException  | 
                                                        |
| 302 | - * @throws DuplicateCollectionIdentifierException  | 
                                                        |
| 303 | - */  | 
                                                        |
| 304 | - protected function loadClassFromFQCN($FQCN)  | 
                                                        |
| 305 | -    { | 
                                                        |
| 306 | -        if (! is_string($FQCN)) { | 
                                                        |
| 307 | -            throw new InvalidDataTypeException('$FQCN', $FQCN, 'string'); | 
                                                        |
| 308 | - }  | 
                                                        |
| 309 | -        if (! class_exists($FQCN)) { | 
                                                        |
| 310 | - throw new InvalidClassException($FQCN);  | 
                                                        |
| 311 | - }  | 
                                                        |
| 312 | - do_action(  | 
                                                        |
| 313 | - 'FHEE__CollectionLoader__loadClassFromFQCN__beforeLoading',  | 
                                                        |
| 314 | - $FQCN,  | 
                                                        |
| 315 | - $this->collection_details->collectionName(),  | 
                                                        |
| 316 | - $this->collection_details  | 
                                                        |
| 317 | - );  | 
                                                        |
| 318 | - $entity = $this->entity_factory instanceof FactoryInterface  | 
                                                        |
| 319 | - ? call_user_func(array($this->entity_factory, 'create'), $FQCN)  | 
                                                        |
| 320 | - : EE_Registry::instance()->create($FQCN);  | 
                                                        |
| 321 | - return $this->addEntityToCollection($entity, $FQCN);  | 
                                                        |
| 322 | - }  | 
                                                        |
| 292 | + /**  | 
                                                        |
| 293 | + * @param string $FQCN Fully Qualified Class Name  | 
                                                        |
| 294 | + * @return string  | 
                                                        |
| 295 | + * @throws InvalidArgumentException  | 
                                                        |
| 296 | + * @throws InvalidInterfaceException  | 
                                                        |
| 297 | + * @throws ReflectionException  | 
                                                        |
| 298 | + * @throws EE_Error  | 
                                                        |
| 299 | + * @throws InvalidEntityException  | 
                                                        |
| 300 | + * @throws InvalidDataTypeException  | 
                                                        |
| 301 | + * @throws InvalidClassException  | 
                                                        |
| 302 | + * @throws DuplicateCollectionIdentifierException  | 
                                                        |
| 303 | + */  | 
                                                        |
| 304 | + protected function loadClassFromFQCN($FQCN)  | 
                                                        |
| 305 | +	{ | 
                                                        |
| 306 | +		if (! is_string($FQCN)) { | 
                                                        |
| 307 | +			throw new InvalidDataTypeException('$FQCN', $FQCN, 'string'); | 
                                                        |
| 308 | + }  | 
                                                        |
| 309 | +		if (! class_exists($FQCN)) { | 
                                                        |
| 310 | + throw new InvalidClassException($FQCN);  | 
                                                        |
| 311 | + }  | 
                                                        |
| 312 | + do_action(  | 
                                                        |
| 313 | + 'FHEE__CollectionLoader__loadClassFromFQCN__beforeLoading',  | 
                                                        |
| 314 | + $FQCN,  | 
                                                        |
| 315 | + $this->collection_details->collectionName(),  | 
                                                        |
| 316 | + $this->collection_details  | 
                                                        |
| 317 | + );  | 
                                                        |
| 318 | + $entity = $this->entity_factory instanceof FactoryInterface  | 
                                                        |
| 319 | + ? call_user_func(array($this->entity_factory, 'create'), $FQCN)  | 
                                                        |
| 320 | + : EE_Registry::instance()->create($FQCN);  | 
                                                        |
| 321 | + return $this->addEntityToCollection($entity, $FQCN);  | 
                                                        |
| 322 | + }  | 
                                                        |
| 323 | 323 | }  | 
                                                        
@@ -87,7 +87,7 @@ discard block  | 
                                                    ||
| 87 | 87 |      ) { | 
                                                        
| 88 | 88 |          try { | 
                                                        
| 89 | 89 | $this->collection_details = $collection_details;  | 
                                                        
| 90 | -            if (! $collection instanceof CollectionInterface) { | 
                                                        |
| 90 | +            if ( ! $collection instanceof CollectionInterface) { | 
                                                        |
| 91 | 91 | $collection = new Collection($this->collection_details->getCollectionInterface());  | 
                                                        
| 92 | 92 | }  | 
                                                        
| 93 | 93 | $this->collection = $collection;  | 
                                                        
@@ -119,7 +119,7 @@ discard block  | 
                                                    ||
| 119 | 119 | */  | 
                                                        
| 120 | 120 | protected function loadAllFromFilepaths()  | 
                                                        
| 121 | 121 |      { | 
                                                        
| 122 | -        if (! $this->file_locator instanceof FileLocator) { | 
                                                        |
| 122 | +        if ( ! $this->file_locator instanceof FileLocator) { | 
                                                        |
| 123 | 123 | $this->file_locator = new FileLocator();  | 
                                                        
| 124 | 124 | }  | 
                                                        
| 125 | 125 | $this->file_locator->setFileMask($this->collection_details->getFileMask());  | 
                                                        
@@ -152,10 +152,10 @@ discard block  | 
                                                    ||
| 152 | 152 | */  | 
                                                        
| 153 | 153 | protected function loadClassFromFilepath($filepath)  | 
                                                        
| 154 | 154 |      { | 
                                                        
| 155 | -        if (! is_string($filepath)) { | 
                                                        |
| 155 | +        if ( ! is_string($filepath)) { | 
                                                        |
| 156 | 156 |              throw new InvalidDataTypeException('$filepath', $filepath, 'string'); | 
                                                        
| 157 | 157 | }  | 
                                                        
| 158 | -        if (! is_readable($filepath)) { | 
                                                        |
| 158 | +        if ( ! is_readable($filepath)) { | 
                                                        |
| 159 | 159 | throw new InvalidFilePathException($filepath);  | 
                                                        
| 160 | 160 | }  | 
                                                        
| 161 | 161 | require_once $filepath;  | 
                                                        
@@ -163,7 +163,7 @@ discard block  | 
                                                    ||
| 163 | 163 | $file_name = basename($filepath);  | 
                                                        
| 164 | 164 | // now remove any file extensions  | 
                                                        
| 165 | 165 | $class_name = EEH_File::get_classname_from_filepath_with_standard_filename($file_name);  | 
                                                        
| 166 | -        if (! class_exists($class_name)) { | 
                                                        |
| 166 | +        if ( ! class_exists($class_name)) { | 
                                                        |
| 167 | 167 | throw new InvalidClassException($class_name);  | 
                                                        
| 168 | 168 | }  | 
                                                        
| 169 | 169 | $entity = $this->entity_factory instanceof FactoryInterface  | 
                                                        
@@ -237,7 +237,7 @@ discard block  | 
                                                    ||
| 237 | 237 | // objects added to the collection based on entity callback, so the entity itself decides  | 
                                                        
| 238 | 238 | case CollectionDetails::ID_CALLBACK_METHOD:  | 
                                                        
| 239 | 239 | $identifier_callback = $this->collection_details->identifierCallback();  | 
                                                        
| 240 | -                if (! method_exists($entity, $identifier_callback)) { | 
                                                        |
| 240 | +                if ( ! method_exists($entity, $identifier_callback)) { | 
                                                        |
| 241 | 241 | throw new InvalidEntityException(  | 
                                                        
| 242 | 242 | $entity,  | 
                                                        
| 243 | 243 | $this->collection_details->getCollectionInterface(),  | 
                                                        
@@ -303,10 +303,10 @@ discard block  | 
                                                    ||
| 303 | 303 | */  | 
                                                        
| 304 | 304 | protected function loadClassFromFQCN($FQCN)  | 
                                                        
| 305 | 305 |      { | 
                                                        
| 306 | -        if (! is_string($FQCN)) { | 
                                                        |
| 306 | +        if ( ! is_string($FQCN)) { | 
                                                        |
| 307 | 307 |              throw new InvalidDataTypeException('$FQCN', $FQCN, 'string'); | 
                                                        
| 308 | 308 | }  | 
                                                        
| 309 | -        if (! class_exists($FQCN)) { | 
                                                        |
| 309 | +        if ( ! class_exists($FQCN)) { | 
                                                        |
| 310 | 310 | throw new InvalidClassException($FQCN);  | 
                                                        
| 311 | 311 | }  | 
                                                        
| 312 | 312 | do_action(  | 
                                                        
@@ -22,70 +22,70 @@  | 
                                                    ||
| 22 | 22 | interface BlockInterface  | 
                                                        
| 23 | 23 |  { | 
                                                        
| 24 | 24 | |
| 25 | - const NAME_SPACE = 'eventespresso';  | 
                                                        |
| 26 | -  | 
                                                        |
| 27 | - /**  | 
                                                        |
| 28 | - * Perform any early setup required by the block  | 
                                                        |
| 29 | - * including setting the block type and supported post types  | 
                                                        |
| 30 | - *  | 
                                                        |
| 31 | - * @return void  | 
                                                        |
| 32 | - */  | 
                                                        |
| 33 | - public function initialize();  | 
                                                        |
| 34 | -  | 
                                                        |
| 35 | -  | 
                                                        |
| 36 | - /**  | 
                                                        |
| 37 | - * @return string  | 
                                                        |
| 38 | - */  | 
                                                        |
| 39 | - public function blockType();  | 
                                                        |
| 40 | -  | 
                                                        |
| 41 | -  | 
                                                        |
| 42 | - /**  | 
                                                        |
| 43 | - * AssetRegister that this editor block uses for asset registration  | 
                                                        |
| 44 | - *  | 
                                                        |
| 45 | - * @return BlockAssetManagerInterface  | 
                                                        |
| 46 | - */  | 
                                                        |
| 47 | - public function assetManager();  | 
                                                        |
| 48 | -  | 
                                                        |
| 49 | -  | 
                                                        |
| 50 | - /**  | 
                                                        |
| 51 | - * Registers the Editor Block with WP core;  | 
                                                        |
| 52 | - * Returns the registered block type on success, or false on failure.  | 
                                                        |
| 53 | - *  | 
                                                        |
| 54 | - * @return WP_Block_Type|false  | 
                                                        |
| 55 | - */  | 
                                                        |
| 56 | - public function registerBlock();  | 
                                                        |
| 57 | -  | 
                                                        |
| 58 | -  | 
                                                        |
| 59 | - /**  | 
                                                        |
| 60 | - * Un-registers the Editor Block with WP core;  | 
                                                        |
| 61 | - * Returns the registered block type on success, or false on failure.  | 
                                                        |
| 62 | - *  | 
                                                        |
| 63 | - * @return WP_Block_Type|false  | 
                                                        |
| 64 | - */  | 
                                                        |
| 65 | - public function unRegisterBlock();  | 
                                                        |
| 66 | -  | 
                                                        |
| 67 | -  | 
                                                        |
| 68 | - /**  | 
                                                        |
| 69 | - * returns an array of fully qualified class names  | 
                                                        |
| 70 | - * for RouteMatchSpecificationInterface objects  | 
                                                        |
| 71 | - * that specify routes that the block should be loaded for.  | 
                                                        |
| 72 | - *  | 
                                                        |
| 73 | - * @return array  | 
                                                        |
| 74 | - */  | 
                                                        |
| 75 | - public function supportedRoutes();  | 
                                                        |
| 76 | -  | 
                                                        |
| 77 | -  | 
                                                        |
| 78 | - /**  | 
                                                        |
| 79 | - * @return array  | 
                                                        |
| 80 | - */  | 
                                                        |
| 81 | - public function getEditorContainer();  | 
                                                        |
| 82 | -  | 
                                                        |
| 83 | -  | 
                                                        |
| 84 | - /**  | 
                                                        |
| 85 | - * returns the rendered HTML for the block  | 
                                                        |
| 86 | - *  | 
                                                        |
| 87 | - * @param array $attributes  | 
                                                        |
| 88 | - * @return string  | 
                                                        |
| 89 | - */  | 
                                                        |
| 90 | - public function renderBlock(array $attributes = array());  | 
                                                        |
| 25 | + const NAME_SPACE = 'eventespresso';  | 
                                                        |
| 26 | +  | 
                                                        |
| 27 | + /**  | 
                                                        |
| 28 | + * Perform any early setup required by the block  | 
                                                        |
| 29 | + * including setting the block type and supported post types  | 
                                                        |
| 30 | + *  | 
                                                        |
| 31 | + * @return void  | 
                                                        |
| 32 | + */  | 
                                                        |
| 33 | + public function initialize();  | 
                                                        |
| 34 | +  | 
                                                        |
| 35 | +  | 
                                                        |
| 36 | + /**  | 
                                                        |
| 37 | + * @return string  | 
                                                        |
| 38 | + */  | 
                                                        |
| 39 | + public function blockType();  | 
                                                        |
| 40 | +  | 
                                                        |
| 41 | +  | 
                                                        |
| 42 | + /**  | 
                                                        |
| 43 | + * AssetRegister that this editor block uses for asset registration  | 
                                                        |
| 44 | + *  | 
                                                        |
| 45 | + * @return BlockAssetManagerInterface  | 
                                                        |
| 46 | + */  | 
                                                        |
| 47 | + public function assetManager();  | 
                                                        |
| 48 | +  | 
                                                        |
| 49 | +  | 
                                                        |
| 50 | + /**  | 
                                                        |
| 51 | + * Registers the Editor Block with WP core;  | 
                                                        |
| 52 | + * Returns the registered block type on success, or false on failure.  | 
                                                        |
| 53 | + *  | 
                                                        |
| 54 | + * @return WP_Block_Type|false  | 
                                                        |
| 55 | + */  | 
                                                        |
| 56 | + public function registerBlock();  | 
                                                        |
| 57 | +  | 
                                                        |
| 58 | +  | 
                                                        |
| 59 | + /**  | 
                                                        |
| 60 | + * Un-registers the Editor Block with WP core;  | 
                                                        |
| 61 | + * Returns the registered block type on success, or false on failure.  | 
                                                        |
| 62 | + *  | 
                                                        |
| 63 | + * @return WP_Block_Type|false  | 
                                                        |
| 64 | + */  | 
                                                        |
| 65 | + public function unRegisterBlock();  | 
                                                        |
| 66 | +  | 
                                                        |
| 67 | +  | 
                                                        |
| 68 | + /**  | 
                                                        |
| 69 | + * returns an array of fully qualified class names  | 
                                                        |
| 70 | + * for RouteMatchSpecificationInterface objects  | 
                                                        |
| 71 | + * that specify routes that the block should be loaded for.  | 
                                                        |
| 72 | + *  | 
                                                        |
| 73 | + * @return array  | 
                                                        |
| 74 | + */  | 
                                                        |
| 75 | + public function supportedRoutes();  | 
                                                        |
| 76 | +  | 
                                                        |
| 77 | +  | 
                                                        |
| 78 | + /**  | 
                                                        |
| 79 | + * @return array  | 
                                                        |
| 80 | + */  | 
                                                        |
| 81 | + public function getEditorContainer();  | 
                                                        |
| 82 | +  | 
                                                        |
| 83 | +  | 
                                                        |
| 84 | + /**  | 
                                                        |
| 85 | + * returns the rendered HTML for the block  | 
                                                        |
| 86 | + *  | 
                                                        |
| 87 | + * @param array $attributes  | 
                                                        |
| 88 | + * @return string  | 
                                                        |
| 89 | + */  | 
                                                        |
| 90 | + public function renderBlock(array $attributes = array());  | 
                                                        |
| 91 | 91 | }  | 
                                                        
@@ -24,17 +24,17 @@  | 
                                                    ||
| 24 | 24 | abstract class RouteMatchSpecification implements RouteMatchSpecificationInterface  | 
                                                        
| 25 | 25 |  { | 
                                                        
| 26 | 26 | |
| 27 | - /**  | 
                                                        |
| 28 | - * @var RequestInterface $request  | 
                                                        |
| 29 | - */  | 
                                                        |
| 30 | - protected $request;  | 
                                                        |
| 27 | + /**  | 
                                                        |
| 28 | + * @var RequestInterface $request  | 
                                                        |
| 29 | + */  | 
                                                        |
| 30 | + protected $request;  | 
                                                        |
| 31 | 31 | |
| 32 | - /**  | 
                                                        |
| 33 | - * RouteMatch constructor.  | 
                                                        |
| 34 | - * @param RequestInterface $request  | 
                                                        |
| 35 | - */  | 
                                                        |
| 36 | - public function __construct(RequestInterface $request)  | 
                                                        |
| 37 | -    { | 
                                                        |
| 38 | - $this->request = $request;  | 
                                                        |
| 39 | - }  | 
                                                        |
| 32 | + /**  | 
                                                        |
| 33 | + * RouteMatch constructor.  | 
                                                        |
| 34 | + * @param RequestInterface $request  | 
                                                        |
| 35 | + */  | 
                                                        |
| 36 | + public function __construct(RequestInterface $request)  | 
                                                        |
| 37 | +	{ | 
                                                        |
| 38 | + $this->request = $request;  | 
                                                        |
| 39 | + }  | 
                                                        |
| 40 | 40 | }  | 
                                                        
@@ -13,18 +13,18 @@  | 
                                                    ||
| 13 | 13 | abstract class RouteMatchSpecificationDecorator implements RouteMatchSpecificationInterface  | 
                                                        
| 14 | 14 |  { | 
                                                        
| 15 | 15 | |
| 16 | - /**  | 
                                                        |
| 17 | - * @var RouteMatchSpecificationInterface $specification  | 
                                                        |
| 18 | - */  | 
                                                        |
| 19 | - protected $specification;  | 
                                                        |
| 16 | + /**  | 
                                                        |
| 17 | + * @var RouteMatchSpecificationInterface $specification  | 
                                                        |
| 18 | + */  | 
                                                        |
| 19 | + protected $specification;  | 
                                                        |
| 20 | 20 | |
| 21 | - /**  | 
                                                        |
| 22 | - * RouteMatchSpecificationDecorator constructor.  | 
                                                        |
| 23 | - *  | 
                                                        |
| 24 | - * @param RouteMatchSpecificationInterface $specification  | 
                                                        |
| 25 | - */  | 
                                                        |
| 26 | - public function __construct(RouteMatchSpecificationInterface $specification)  | 
                                                        |
| 27 | -    { | 
                                                        |
| 28 | - $this->specification = $specification;  | 
                                                        |
| 29 | - }  | 
                                                        |
| 21 | + /**  | 
                                                        |
| 22 | + * RouteMatchSpecificationDecorator constructor.  | 
                                                        |
| 23 | + *  | 
                                                        |
| 24 | + * @param RouteMatchSpecificationInterface $specification  | 
                                                        |
| 25 | + */  | 
                                                        |
| 26 | + public function __construct(RouteMatchSpecificationInterface $specification)  | 
                                                        |
| 27 | +	{ | 
                                                        |
| 28 | + $this->specification = $specification;  | 
                                                        |
| 29 | + }  | 
                                                        |
| 30 | 30 | }  | 
                                                        
@@ -18,46 +18,46 @@  | 
                                                    ||
| 18 | 18 | abstract class BlockManager  | 
                                                        
| 19 | 19 |  { | 
                                                        
| 20 | 20 | |
| 21 | - /**  | 
                                                        |
| 22 | - * @var CollectionInterface|BlockInterface[] $blocks  | 
                                                        |
| 23 | - */  | 
                                                        |
| 24 | - protected $blocks;  | 
                                                        |
| 25 | -  | 
                                                        |
| 26 | - /**  | 
                                                        |
| 27 | - * @var RequestInterface $request  | 
                                                        |
| 28 | - */  | 
                                                        |
| 29 | - protected $request;  | 
                                                        |
| 30 | -  | 
                                                        |
| 31 | -  | 
                                                        |
| 32 | -  | 
                                                        |
| 33 | - /**  | 
                                                        |
| 34 | - * BlockManager constructor.  | 
                                                        |
| 35 | - *  | 
                                                        |
| 36 | - * @param BlockCollection $blocks  | 
                                                        |
| 37 | - * @param RequestInterface $request  | 
                                                        |
| 38 | - */  | 
                                                        |
| 39 | - public function __construct(  | 
                                                        |
| 40 | - BlockCollection $blocks,  | 
                                                        |
| 41 | - RequestInterface $request  | 
                                                        |
| 42 | -    ) { | 
                                                        |
| 43 | - $this->blocks = $blocks;  | 
                                                        |
| 44 | - $this->request = $request;  | 
                                                        |
| 45 | - add_action($this->initHook(), array($this, 'initialize'));  | 
                                                        |
| 46 | - }  | 
                                                        |
| 47 | -  | 
                                                        |
| 48 | -  | 
                                                        |
| 49 | - /**  | 
                                                        |
| 50 | - * Returns the name of a hookpoint to be used to call initialize()  | 
                                                        |
| 51 | - *  | 
                                                        |
| 52 | - * @return string  | 
                                                        |
| 53 | - */  | 
                                                        |
| 54 | - abstract public function initHook();  | 
                                                        |
| 55 | -  | 
                                                        |
| 56 | -  | 
                                                        |
| 57 | - /**  | 
                                                        |
| 58 | - * Perform any early setup required for block editors to functions  | 
                                                        |
| 59 | - *  | 
                                                        |
| 60 | - * @return void  | 
                                                        |
| 61 | - */  | 
                                                        |
| 62 | - abstract public function initialize();  | 
                                                        |
| 21 | + /**  | 
                                                        |
| 22 | + * @var CollectionInterface|BlockInterface[] $blocks  | 
                                                        |
| 23 | + */  | 
                                                        |
| 24 | + protected $blocks;  | 
                                                        |
| 25 | +  | 
                                                        |
| 26 | + /**  | 
                                                        |
| 27 | + * @var RequestInterface $request  | 
                                                        |
| 28 | + */  | 
                                                        |
| 29 | + protected $request;  | 
                                                        |
| 30 | +  | 
                                                        |
| 31 | +  | 
                                                        |
| 32 | +  | 
                                                        |
| 33 | + /**  | 
                                                        |
| 34 | + * BlockManager constructor.  | 
                                                        |
| 35 | + *  | 
                                                        |
| 36 | + * @param BlockCollection $blocks  | 
                                                        |
| 37 | + * @param RequestInterface $request  | 
                                                        |
| 38 | + */  | 
                                                        |
| 39 | + public function __construct(  | 
                                                        |
| 40 | + BlockCollection $blocks,  | 
                                                        |
| 41 | + RequestInterface $request  | 
                                                        |
| 42 | +	) { | 
                                                        |
| 43 | + $this->blocks = $blocks;  | 
                                                        |
| 44 | + $this->request = $request;  | 
                                                        |
| 45 | + add_action($this->initHook(), array($this, 'initialize'));  | 
                                                        |
| 46 | + }  | 
                                                        |
| 47 | +  | 
                                                        |
| 48 | +  | 
                                                        |
| 49 | + /**  | 
                                                        |
| 50 | + * Returns the name of a hookpoint to be used to call initialize()  | 
                                                        |
| 51 | + *  | 
                                                        |
| 52 | + * @return string  | 
                                                        |
| 53 | + */  | 
                                                        |
| 54 | + abstract public function initHook();  | 
                                                        |
| 55 | +  | 
                                                        |
| 56 | +  | 
                                                        |
| 57 | + /**  | 
                                                        |
| 58 | + * Perform any early setup required for block editors to functions  | 
                                                        |
| 59 | + *  | 
                                                        |
| 60 | + * @return void  | 
                                                        |
| 61 | + */  | 
                                                        |
| 62 | + abstract public function initialize();  | 
                                                        |
| 63 | 63 | }  | 
                                                        
@@ -16,36 +16,36 @@  | 
                                                    ||
| 16 | 16 | class RouteMatchSpecificationCollection extends Collection  | 
                                                        
| 17 | 17 |  { | 
                                                        
| 18 | 18 | |
| 19 | - const COLLECTION_NAME = 'route_match_specifications';  | 
                                                        |
| 20 | -  | 
                                                        |
| 21 | -  | 
                                                        |
| 22 | - /**  | 
                                                        |
| 23 | - * RouteMatchSpecificationCollection constructor  | 
                                                        |
| 24 | - *  | 
                                                        |
| 25 | - * @throws InvalidInterfaceException  | 
                                                        |
| 26 | - */  | 
                                                        |
| 27 | - public function __construct()  | 
                                                        |
| 28 | -    { | 
                                                        |
| 29 | - parent::__construct(  | 
                                                        |
| 30 | - 'EventEspresso\core\domain\entities\route_match\RouteMatchSpecificationInterface',  | 
                                                        |
| 31 | - RouteMatchSpecificationCollection::COLLECTION_NAME  | 
                                                        |
| 32 | - );  | 
                                                        |
| 33 | - }  | 
                                                        |
| 34 | -  | 
                                                        |
| 35 | -  | 
                                                        |
| 36 | - /**  | 
                                                        |
| 37 | - * getIdentifier  | 
                                                        |
| 38 | - * Overrides EventEspresso\core\services\collections\Collection::getIdentifier()  | 
                                                        |
| 39 | - * If no $identifier is supplied, then the fully qualified class name is used  | 
                                                        |
| 40 | - *  | 
                                                        |
| 41 | - * @param $object  | 
                                                        |
| 42 | - * @param mixed $identifier  | 
                                                        |
| 43 | - * @return bool  | 
                                                        |
| 44 | - */  | 
                                                        |
| 45 | - public function getIdentifier($object, $identifier = null)  | 
                                                        |
| 46 | -    { | 
                                                        |
| 47 | - return ! empty($identifier)  | 
                                                        |
| 48 | - ? $identifier  | 
                                                        |
| 49 | - : get_class($object);  | 
                                                        |
| 50 | - }  | 
                                                        |
| 19 | + const COLLECTION_NAME = 'route_match_specifications';  | 
                                                        |
| 20 | +  | 
                                                        |
| 21 | +  | 
                                                        |
| 22 | + /**  | 
                                                        |
| 23 | + * RouteMatchSpecificationCollection constructor  | 
                                                        |
| 24 | + *  | 
                                                        |
| 25 | + * @throws InvalidInterfaceException  | 
                                                        |
| 26 | + */  | 
                                                        |
| 27 | + public function __construct()  | 
                                                        |
| 28 | +	{ | 
                                                        |
| 29 | + parent::__construct(  | 
                                                        |
| 30 | + 'EventEspresso\core\domain\entities\route_match\RouteMatchSpecificationInterface',  | 
                                                        |
| 31 | + RouteMatchSpecificationCollection::COLLECTION_NAME  | 
                                                        |
| 32 | + );  | 
                                                        |
| 33 | + }  | 
                                                        |
| 34 | +  | 
                                                        |
| 35 | +  | 
                                                        |
| 36 | + /**  | 
                                                        |
| 37 | + * getIdentifier  | 
                                                        |
| 38 | + * Overrides EventEspresso\core\services\collections\Collection::getIdentifier()  | 
                                                        |
| 39 | + * If no $identifier is supplied, then the fully qualified class name is used  | 
                                                        |
| 40 | + *  | 
                                                        |
| 41 | + * @param $object  | 
                                                        |
| 42 | + * @param mixed $identifier  | 
                                                        |
| 43 | + * @return bool  | 
                                                        |
| 44 | + */  | 
                                                        |
| 45 | + public function getIdentifier($object, $identifier = null)  | 
                                                        |
| 46 | +	{ | 
                                                        |
| 47 | + return ! empty($identifier)  | 
                                                        |
| 48 | + ? $identifier  | 
                                                        |
| 49 | + : get_class($object);  | 
                                                        |
| 50 | + }  | 
                                                        |
| 51 | 51 | }  | 
                                                        
@@ -21,152 +21,152 @@  | 
                                                    ||
| 21 | 21 | abstract class AssetManager implements AssetManagerInterface  | 
                                                        
| 22 | 22 |  { | 
                                                        
| 23 | 23 | |
| 24 | - /**  | 
                                                        |
| 25 | - * @var AssetCollection $assets  | 
                                                        |
| 26 | - */  | 
                                                        |
| 27 | - protected $assets;  | 
                                                        |
| 28 | -  | 
                                                        |
| 29 | - /**  | 
                                                        |
| 30 | - * @var DomainInterface  | 
                                                        |
| 31 | - */  | 
                                                        |
| 32 | - protected $domain;  | 
                                                        |
| 33 | -  | 
                                                        |
| 34 | - /**  | 
                                                        |
| 35 | - * @var Registry $registry  | 
                                                        |
| 36 | - */  | 
                                                        |
| 37 | - protected $registry;  | 
                                                        |
| 38 | -  | 
                                                        |
| 39 | -  | 
                                                        |
| 40 | - /**  | 
                                                        |
| 41 | - * AssetRegister constructor.  | 
                                                        |
| 42 | - *  | 
                                                        |
| 43 | - * @param DomainInterface $domain  | 
                                                        |
| 44 | - * @param AssetCollection $assets  | 
                                                        |
| 45 | - * @param Registry $registry  | 
                                                        |
| 46 | - */  | 
                                                        |
| 47 | - public function __construct(DomainInterface $domain, AssetCollection $assets, Registry $registry)  | 
                                                        |
| 48 | -    { | 
                                                        |
| 49 | - $this->domain = $domain;  | 
                                                        |
| 50 | - $this->assets = $assets;  | 
                                                        |
| 51 | - $this->registry = $registry;  | 
                                                        |
| 52 | -        add_action('wp_enqueue_scripts', array($this, 'addManifestFile'), 0); | 
                                                        |
| 53 | -        add_action('admin_enqueue_scripts', array($this, 'addManifestFile'), 0); | 
                                                        |
| 54 | -        add_action('wp_enqueue_scripts', array($this, 'addAssets'), 2); | 
                                                        |
| 55 | -        add_action('admin_enqueue_scripts', array($this, 'addAssets'), 2); | 
                                                        |
| 56 | - }  | 
                                                        |
| 57 | -  | 
                                                        |
| 58 | -  | 
                                                        |
| 59 | - /**  | 
                                                        |
| 60 | - * @since $VID:$  | 
                                                        |
| 61 | - * @return string  | 
                                                        |
| 62 | - */  | 
                                                        |
| 63 | - public function assetNamespace()  | 
                                                        |
| 64 | -    { | 
                                                        |
| 65 | - return $this->domain->assetNamespace();  | 
                                                        |
| 66 | - }  | 
                                                        |
| 67 | -  | 
                                                        |
| 68 | -  | 
                                                        |
| 69 | - /**  | 
                                                        |
| 70 | - * @return void  | 
                                                        |
| 71 | - * @throws DuplicateCollectionIdentifierException  | 
                                                        |
| 72 | - * @throws InvalidDataTypeException  | 
                                                        |
| 73 | - * @throws InvalidEntityException  | 
                                                        |
| 74 | - * @since 4.9.62.p  | 
                                                        |
| 75 | - */  | 
                                                        |
| 76 | - public function addManifestFile()  | 
                                                        |
| 77 | -    { | 
                                                        |
| 78 | - // if a manifest file has already been added for this domain, then just return  | 
                                                        |
| 79 | -        if ($this->assets->has($this->domain->assetNamespace())) { | 
                                                        |
| 80 | - return;  | 
                                                        |
| 81 | - }  | 
                                                        |
| 82 | - $asset = new ManifestFile($this->domain);  | 
                                                        |
| 83 | - $this->assets->add($asset, $this->domain->assetNamespace());  | 
                                                        |
| 84 | - }  | 
                                                        |
| 85 | -  | 
                                                        |
| 86 | -  | 
                                                        |
| 87 | - /**  | 
                                                        |
| 88 | - * @return ManifestFile[]  | 
                                                        |
| 89 | - * @since 4.9.62.p  | 
                                                        |
| 90 | - */  | 
                                                        |
| 91 | - public function getManifestFile()  | 
                                                        |
| 92 | -    { | 
                                                        |
| 93 | - return $this->assets->getManifestFiles();  | 
                                                        |
| 94 | - }  | 
                                                        |
| 95 | -  | 
                                                        |
| 96 | -  | 
                                                        |
| 97 | - /**  | 
                                                        |
| 98 | - * @param string $handle  | 
                                                        |
| 99 | - * @param string $source  | 
                                                        |
| 100 | - * @param array $dependencies  | 
                                                        |
| 101 | - * @param bool $load_in_footer  | 
                                                        |
| 102 | - * @return JavascriptAsset  | 
                                                        |
| 103 | - * @throws DuplicateCollectionIdentifierException  | 
                                                        |
| 104 | - * @throws InvalidDataTypeException  | 
                                                        |
| 105 | - * @throws InvalidEntityException  | 
                                                        |
| 106 | - * @since 4.9.62.p  | 
                                                        |
| 107 | - */  | 
                                                        |
| 108 | - public function addJavascript(  | 
                                                        |
| 109 | - $handle,  | 
                                                        |
| 110 | - $source,  | 
                                                        |
| 111 | - array $dependencies = array(),  | 
                                                        |
| 112 | - $load_in_footer = true  | 
                                                        |
| 113 | -    ) { | 
                                                        |
| 114 | - $asset = new JavascriptAsset(  | 
                                                        |
| 115 | - $handle,  | 
                                                        |
| 116 | - $source,  | 
                                                        |
| 117 | - $dependencies,  | 
                                                        |
| 118 | - $load_in_footer,  | 
                                                        |
| 119 | - $this->domain  | 
                                                        |
| 120 | - );  | 
                                                        |
| 121 | - $this->assets->add($asset, $handle);  | 
                                                        |
| 122 | - return $asset;  | 
                                                        |
| 123 | - }  | 
                                                        |
| 124 | -  | 
                                                        |
| 125 | -  | 
                                                        |
| 126 | -  | 
                                                        |
| 127 | - /**  | 
                                                        |
| 128 | - * @param string $handle  | 
                                                        |
| 129 | - * @param string $source  | 
                                                        |
| 130 | - * @param array $dependencies  | 
                                                        |
| 131 | - * @param string $media  | 
                                                        |
| 132 | - * @return StylesheetAsset  | 
                                                        |
| 133 | - * @throws DuplicateCollectionIdentifierException  | 
                                                        |
| 134 | - * @throws InvalidDataTypeException  | 
                                                        |
| 135 | - * @throws InvalidEntityException  | 
                                                        |
| 136 | - * @since 4.9.62.p  | 
                                                        |
| 137 | - */  | 
                                                        |
| 138 | - public function addStylesheet(  | 
                                                        |
| 139 | - $handle,  | 
                                                        |
| 140 | - $source,  | 
                                                        |
| 141 | - array $dependencies = array(),  | 
                                                        |
| 142 | - $media = 'all'  | 
                                                        |
| 143 | -    ) { | 
                                                        |
| 144 | - $asset = new StylesheetAsset(  | 
                                                        |
| 145 | - $handle,  | 
                                                        |
| 146 | - $source,  | 
                                                        |
| 147 | - $dependencies,  | 
                                                        |
| 148 | - $this->domain,  | 
                                                        |
| 149 | - $media  | 
                                                        |
| 150 | - );  | 
                                                        |
| 151 | - $this->assets->add($asset, $handle);  | 
                                                        |
| 152 | - return $asset;  | 
                                                        |
| 153 | - }  | 
                                                        |
| 154 | -  | 
                                                        |
| 155 | -  | 
                                                        |
| 156 | - /**  | 
                                                        |
| 157 | - * @param string $handle  | 
                                                        |
| 158 | - * @return bool  | 
                                                        |
| 159 | - * @since 4.9.62.p  | 
                                                        |
| 160 | - */  | 
                                                        |
| 161 | - public function enqueueAsset($handle)  | 
                                                        |
| 162 | -    { | 
                                                        |
| 163 | -        if ($this->assets->has($handle)) { | 
                                                        |
| 164 | - $asset = $this->assets->get($handle);  | 
                                                        |
| 165 | -            if ($asset->isRegistered()) { | 
                                                        |
| 166 | - $asset->enqueueAsset();  | 
                                                        |
| 167 | - return true;  | 
                                                        |
| 168 | - }  | 
                                                        |
| 169 | - }  | 
                                                        |
| 170 | - return false;  | 
                                                        |
| 171 | - }  | 
                                                        |
| 24 | + /**  | 
                                                        |
| 25 | + * @var AssetCollection $assets  | 
                                                        |
| 26 | + */  | 
                                                        |
| 27 | + protected $assets;  | 
                                                        |
| 28 | +  | 
                                                        |
| 29 | + /**  | 
                                                        |
| 30 | + * @var DomainInterface  | 
                                                        |
| 31 | + */  | 
                                                        |
| 32 | + protected $domain;  | 
                                                        |
| 33 | +  | 
                                                        |
| 34 | + /**  | 
                                                        |
| 35 | + * @var Registry $registry  | 
                                                        |
| 36 | + */  | 
                                                        |
| 37 | + protected $registry;  | 
                                                        |
| 38 | +  | 
                                                        |
| 39 | +  | 
                                                        |
| 40 | + /**  | 
                                                        |
| 41 | + * AssetRegister constructor.  | 
                                                        |
| 42 | + *  | 
                                                        |
| 43 | + * @param DomainInterface $domain  | 
                                                        |
| 44 | + * @param AssetCollection $assets  | 
                                                        |
| 45 | + * @param Registry $registry  | 
                                                        |
| 46 | + */  | 
                                                        |
| 47 | + public function __construct(DomainInterface $domain, AssetCollection $assets, Registry $registry)  | 
                                                        |
| 48 | +	{ | 
                                                        |
| 49 | + $this->domain = $domain;  | 
                                                        |
| 50 | + $this->assets = $assets;  | 
                                                        |
| 51 | + $this->registry = $registry;  | 
                                                        |
| 52 | +		add_action('wp_enqueue_scripts', array($this, 'addManifestFile'), 0); | 
                                                        |
| 53 | +		add_action('admin_enqueue_scripts', array($this, 'addManifestFile'), 0); | 
                                                        |
| 54 | +		add_action('wp_enqueue_scripts', array($this, 'addAssets'), 2); | 
                                                        |
| 55 | +		add_action('admin_enqueue_scripts', array($this, 'addAssets'), 2); | 
                                                        |
| 56 | + }  | 
                                                        |
| 57 | +  | 
                                                        |
| 58 | +  | 
                                                        |
| 59 | + /**  | 
                                                        |
| 60 | + * @since $VID:$  | 
                                                        |
| 61 | + * @return string  | 
                                                        |
| 62 | + */  | 
                                                        |
| 63 | + public function assetNamespace()  | 
                                                        |
| 64 | +	{ | 
                                                        |
| 65 | + return $this->domain->assetNamespace();  | 
                                                        |
| 66 | + }  | 
                                                        |
| 67 | +  | 
                                                        |
| 68 | +  | 
                                                        |
| 69 | + /**  | 
                                                        |
| 70 | + * @return void  | 
                                                        |
| 71 | + * @throws DuplicateCollectionIdentifierException  | 
                                                        |
| 72 | + * @throws InvalidDataTypeException  | 
                                                        |
| 73 | + * @throws InvalidEntityException  | 
                                                        |
| 74 | + * @since 4.9.62.p  | 
                                                        |
| 75 | + */  | 
                                                        |
| 76 | + public function addManifestFile()  | 
                                                        |
| 77 | +	{ | 
                                                        |
| 78 | + // if a manifest file has already been added for this domain, then just return  | 
                                                        |
| 79 | +		if ($this->assets->has($this->domain->assetNamespace())) { | 
                                                        |
| 80 | + return;  | 
                                                        |
| 81 | + }  | 
                                                        |
| 82 | + $asset = new ManifestFile($this->domain);  | 
                                                        |
| 83 | + $this->assets->add($asset, $this->domain->assetNamespace());  | 
                                                        |
| 84 | + }  | 
                                                        |
| 85 | +  | 
                                                        |
| 86 | +  | 
                                                        |
| 87 | + /**  | 
                                                        |
| 88 | + * @return ManifestFile[]  | 
                                                        |
| 89 | + * @since 4.9.62.p  | 
                                                        |
| 90 | + */  | 
                                                        |
| 91 | + public function getManifestFile()  | 
                                                        |
| 92 | +	{ | 
                                                        |
| 93 | + return $this->assets->getManifestFiles();  | 
                                                        |
| 94 | + }  | 
                                                        |
| 95 | +  | 
                                                        |
| 96 | +  | 
                                                        |
| 97 | + /**  | 
                                                        |
| 98 | + * @param string $handle  | 
                                                        |
| 99 | + * @param string $source  | 
                                                        |
| 100 | + * @param array $dependencies  | 
                                                        |
| 101 | + * @param bool $load_in_footer  | 
                                                        |
| 102 | + * @return JavascriptAsset  | 
                                                        |
| 103 | + * @throws DuplicateCollectionIdentifierException  | 
                                                        |
| 104 | + * @throws InvalidDataTypeException  | 
                                                        |
| 105 | + * @throws InvalidEntityException  | 
                                                        |
| 106 | + * @since 4.9.62.p  | 
                                                        |
| 107 | + */  | 
                                                        |
| 108 | + public function addJavascript(  | 
                                                        |
| 109 | + $handle,  | 
                                                        |
| 110 | + $source,  | 
                                                        |
| 111 | + array $dependencies = array(),  | 
                                                        |
| 112 | + $load_in_footer = true  | 
                                                        |
| 113 | +	) { | 
                                                        |
| 114 | + $asset = new JavascriptAsset(  | 
                                                        |
| 115 | + $handle,  | 
                                                        |
| 116 | + $source,  | 
                                                        |
| 117 | + $dependencies,  | 
                                                        |
| 118 | + $load_in_footer,  | 
                                                        |
| 119 | + $this->domain  | 
                                                        |
| 120 | + );  | 
                                                        |
| 121 | + $this->assets->add($asset, $handle);  | 
                                                        |
| 122 | + return $asset;  | 
                                                        |
| 123 | + }  | 
                                                        |
| 124 | +  | 
                                                        |
| 125 | +  | 
                                                        |
| 126 | +  | 
                                                        |
| 127 | + /**  | 
                                                        |
| 128 | + * @param string $handle  | 
                                                        |
| 129 | + * @param string $source  | 
                                                        |
| 130 | + * @param array $dependencies  | 
                                                        |
| 131 | + * @param string $media  | 
                                                        |
| 132 | + * @return StylesheetAsset  | 
                                                        |
| 133 | + * @throws DuplicateCollectionIdentifierException  | 
                                                        |
| 134 | + * @throws InvalidDataTypeException  | 
                                                        |
| 135 | + * @throws InvalidEntityException  | 
                                                        |
| 136 | + * @since 4.9.62.p  | 
                                                        |
| 137 | + */  | 
                                                        |
| 138 | + public function addStylesheet(  | 
                                                        |
| 139 | + $handle,  | 
                                                        |
| 140 | + $source,  | 
                                                        |
| 141 | + array $dependencies = array(),  | 
                                                        |
| 142 | + $media = 'all'  | 
                                                        |
| 143 | +	) { | 
                                                        |
| 144 | + $asset = new StylesheetAsset(  | 
                                                        |
| 145 | + $handle,  | 
                                                        |
| 146 | + $source,  | 
                                                        |
| 147 | + $dependencies,  | 
                                                        |
| 148 | + $this->domain,  | 
                                                        |
| 149 | + $media  | 
                                                        |
| 150 | + );  | 
                                                        |
| 151 | + $this->assets->add($asset, $handle);  | 
                                                        |
| 152 | + return $asset;  | 
                                                        |
| 153 | + }  | 
                                                        |
| 154 | +  | 
                                                        |
| 155 | +  | 
                                                        |
| 156 | + /**  | 
                                                        |
| 157 | + * @param string $handle  | 
                                                        |
| 158 | + * @return bool  | 
                                                        |
| 159 | + * @since 4.9.62.p  | 
                                                        |
| 160 | + */  | 
                                                        |
| 161 | + public function enqueueAsset($handle)  | 
                                                        |
| 162 | +	{ | 
                                                        |
| 163 | +		if ($this->assets->has($handle)) { | 
                                                        |
| 164 | + $asset = $this->assets->get($handle);  | 
                                                        |
| 165 | +			if ($asset->isRegistered()) { | 
                                                        |
| 166 | + $asset->enqueueAsset();  | 
                                                        |
| 167 | + return true;  | 
                                                        |
| 168 | + }  | 
                                                        |
| 169 | + }  | 
                                                        |
| 170 | + return false;  | 
                                                        |
| 171 | + }  | 
                                                        |
| 172 | 172 | }  | 
                                                        
@@ -19,78 +19,78 @@  | 
                                                    ||
| 19 | 19 | */  | 
                                                        
| 20 | 20 | interface AssetManagerInterface  | 
                                                        
| 21 | 21 |  { | 
                                                        
| 22 | - /**  | 
                                                        |
| 23 | - * @since $VID:$  | 
                                                        |
| 24 | - * @return string  | 
                                                        |
| 25 | - */  | 
                                                        |
| 26 | - public function assetNamespace();  | 
                                                        |
| 22 | + /**  | 
                                                        |
| 23 | + * @since $VID:$  | 
                                                        |
| 24 | + * @return string  | 
                                                        |
| 25 | + */  | 
                                                        |
| 26 | + public function assetNamespace();  | 
                                                        |
| 27 | 27 | |
| 28 | - /**  | 
                                                        |
| 29 | - * @since 4.9.62.p  | 
                                                        |
| 30 | - */  | 
                                                        |
| 31 | - public function addAssets();  | 
                                                        |
| 28 | + /**  | 
                                                        |
| 29 | + * @since 4.9.62.p  | 
                                                        |
| 30 | + */  | 
                                                        |
| 31 | + public function addAssets();  | 
                                                        |
| 32 | 32 | |
| 33 | 33 | |
| 34 | - /**  | 
                                                        |
| 35 | - * @return ManifestFile  | 
                                                        |
| 36 | - * @throws DuplicateCollectionIdentifierException  | 
                                                        |
| 37 | - * @throws InvalidDataTypeException  | 
                                                        |
| 38 | - * @throws InvalidEntityException  | 
                                                        |
| 39 | - * @since 4.9.62.p  | 
                                                        |
| 40 | - */  | 
                                                        |
| 41 | - public function addManifestFile();  | 
                                                        |
| 34 | + /**  | 
                                                        |
| 35 | + * @return ManifestFile  | 
                                                        |
| 36 | + * @throws DuplicateCollectionIdentifierException  | 
                                                        |
| 37 | + * @throws InvalidDataTypeException  | 
                                                        |
| 38 | + * @throws InvalidEntityException  | 
                                                        |
| 39 | + * @since 4.9.62.p  | 
                                                        |
| 40 | + */  | 
                                                        |
| 41 | + public function addManifestFile();  | 
                                                        |
| 42 | 42 | |
| 43 | 43 | |
| 44 | - /**  | 
                                                        |
| 45 | - * @return ManifestFile[]  | 
                                                        |
| 46 | - * @since 4.9.62.p  | 
                                                        |
| 47 | - */  | 
                                                        |
| 48 | - public function getManifestFile();  | 
                                                        |
| 44 | + /**  | 
                                                        |
| 45 | + * @return ManifestFile[]  | 
                                                        |
| 46 | + * @since 4.9.62.p  | 
                                                        |
| 47 | + */  | 
                                                        |
| 48 | + public function getManifestFile();  | 
                                                        |
| 49 | 49 | |
| 50 | 50 | |
| 51 | - /**  | 
                                                        |
| 52 | - * @param string $handle  | 
                                                        |
| 53 | - * @param string $source  | 
                                                        |
| 54 | - * @param array $dependencies  | 
                                                        |
| 55 | - * @param bool $load_in_footer  | 
                                                        |
| 56 | - * @return JavascriptAsset  | 
                                                        |
| 57 | - * @throws DuplicateCollectionIdentifierException  | 
                                                        |
| 58 | - * @throws InvalidDataTypeException  | 
                                                        |
| 59 | - * @throws InvalidEntityException  | 
                                                        |
| 60 | - * @since 4.9.62.p  | 
                                                        |
| 61 | - */  | 
                                                        |
| 62 | - public function addJavascript(  | 
                                                        |
| 63 | - $handle,  | 
                                                        |
| 64 | - $source,  | 
                                                        |
| 65 | - array $dependencies = array(),  | 
                                                        |
| 66 | - $load_in_footer = true  | 
                                                        |
| 67 | - );  | 
                                                        |
| 51 | + /**  | 
                                                        |
| 52 | + * @param string $handle  | 
                                                        |
| 53 | + * @param string $source  | 
                                                        |
| 54 | + * @param array $dependencies  | 
                                                        |
| 55 | + * @param bool $load_in_footer  | 
                                                        |
| 56 | + * @return JavascriptAsset  | 
                                                        |
| 57 | + * @throws DuplicateCollectionIdentifierException  | 
                                                        |
| 58 | + * @throws InvalidDataTypeException  | 
                                                        |
| 59 | + * @throws InvalidEntityException  | 
                                                        |
| 60 | + * @since 4.9.62.p  | 
                                                        |
| 61 | + */  | 
                                                        |
| 62 | + public function addJavascript(  | 
                                                        |
| 63 | + $handle,  | 
                                                        |
| 64 | + $source,  | 
                                                        |
| 65 | + array $dependencies = array(),  | 
                                                        |
| 66 | + $load_in_footer = true  | 
                                                        |
| 67 | + );  | 
                                                        |
| 68 | 68 | |
| 69 | 69 | |
| 70 | 70 | |
| 71 | - /**  | 
                                                        |
| 72 | - * @param string $handle  | 
                                                        |
| 73 | - * @param string $source  | 
                                                        |
| 74 | - * @param array $dependencies  | 
                                                        |
| 75 | - * @param string $media  | 
                                                        |
| 76 | - * @return StylesheetAsset  | 
                                                        |
| 77 | - * @throws DuplicateCollectionIdentifierException  | 
                                                        |
| 78 | - * @throws InvalidDataTypeException  | 
                                                        |
| 79 | - * @throws InvalidEntityException  | 
                                                        |
| 80 | - * @since 4.9.62.p  | 
                                                        |
| 81 | - */  | 
                                                        |
| 82 | - public function addStylesheet(  | 
                                                        |
| 83 | - $handle,  | 
                                                        |
| 84 | - $source,  | 
                                                        |
| 85 | - array $dependencies = array(),  | 
                                                        |
| 86 | - $media = 'all'  | 
                                                        |
| 87 | - );  | 
                                                        |
| 71 | + /**  | 
                                                        |
| 72 | + * @param string $handle  | 
                                                        |
| 73 | + * @param string $source  | 
                                                        |
| 74 | + * @param array $dependencies  | 
                                                        |
| 75 | + * @param string $media  | 
                                                        |
| 76 | + * @return StylesheetAsset  | 
                                                        |
| 77 | + * @throws DuplicateCollectionIdentifierException  | 
                                                        |
| 78 | + * @throws InvalidDataTypeException  | 
                                                        |
| 79 | + * @throws InvalidEntityException  | 
                                                        |
| 80 | + * @since 4.9.62.p  | 
                                                        |
| 81 | + */  | 
                                                        |
| 82 | + public function addStylesheet(  | 
                                                        |
| 83 | + $handle,  | 
                                                        |
| 84 | + $source,  | 
                                                        |
| 85 | + array $dependencies = array(),  | 
                                                        |
| 86 | + $media = 'all'  | 
                                                        |
| 87 | + );  | 
                                                        |
| 88 | 88 | |
| 89 | 89 | |
| 90 | - /**  | 
                                                        |
| 91 | - * @param string $handle  | 
                                                        |
| 92 | - * @return bool  | 
                                                        |
| 93 | - * @since 4.9.62.p  | 
                                                        |
| 94 | - */  | 
                                                        |
| 95 | - public function enqueueAsset($handle);  | 
                                                        |
| 90 | + /**  | 
                                                        |
| 91 | + * @param string $handle  | 
                                                        |
| 92 | + * @return bool  | 
                                                        |
| 93 | + * @since 4.9.62.p  | 
                                                        |
| 94 | + */  | 
                                                        |
| 95 | + public function enqueueAsset($handle);  | 
                                                        |
| 96 | 96 | }  |