| 1 | <?php |
||
| 19 | class MetaItemCollection extends CollectionBase implements CollectionContract |
||
|
1 ignored issue
–
show
|
|||
| 20 | { |
||
| 21 | /** |
||
| 22 | * Fully qualified class name to use when creating new items via magic methods. |
||
| 23 | * |
||
| 24 | * @var string |
||
| 25 | */ |
||
| 26 | protected static $item_class; |
||
| 27 | |||
| 28 | /** |
||
| 29 | * The default tag name to use when using magic methods. |
||
| 30 | * |
||
| 31 | * @var string |
||
| 32 | */ |
||
| 33 | protected $default_tag = 'default'; |
||
| 34 | |||
| 35 | /** |
||
| 36 | * Keys of the models that the collection was constructed with. |
||
| 37 | * |
||
| 38 | * @var array |
||
| 39 | */ |
||
| 40 | protected $original_model_keys = []; |
||
| 41 | |||
| 42 | /** |
||
| 43 | * MetaItemCollection constructor. |
||
| 44 | * |
||
| 45 | * @param array $items |
||
| 46 | */ |
||
| 47 | public function __construct($items = []) |
||
| 55 | |||
| 56 | /** |
||
| 57 | * Get the array of primary keys. |
||
| 58 | * |
||
| 59 | * @return array |
||
| 60 | */ |
||
| 61 | public function modelKeys() |
||
| 73 | |||
| 74 | /** |
||
| 75 | * Get the array of primary keys the collection was constructed with. |
||
| 76 | * |
||
| 77 | * @return array |
||
| 78 | */ |
||
| 79 | public function originalModelKeys() |
||
| 83 | |||
| 84 | /** |
||
| 85 | * Add an item to the collection. |
||
| 86 | * |
||
| 87 | * @param mixed $item |
||
| 88 | * @return $this |
||
| 89 | * @throws InvalidArgumentException |
||
| 90 | */ |
||
| 91 | public function add($item) |
||
| 110 | |||
| 111 | /** |
||
| 112 | * Get the collection key form an item key and tag. |
||
| 113 | * |
||
| 114 | * @param mixed $key |
||
| 115 | * @param null $tag |
||
| 116 | * @return mixed |
||
| 117 | */ |
||
| 118 | public function findItem($key, $tag = null) |
||
| 130 | |||
| 131 | /** |
||
| 132 | * Set deletion listeners on an array of items. |
||
| 133 | * |
||
| 134 | * @param array $items |
||
| 135 | */ |
||
| 136 | protected function observeDeletions(array $items) |
||
| 144 | |||
| 145 | /** |
||
| 146 | * Set a deletion listener on an item. |
||
| 147 | * |
||
| 148 | * @param \BoxedCode\Eloquent\Meta\Contracts\MetaItem $item |
||
| 149 | */ |
||
| 150 | protected function observeDeletion(MetaItemContract $item) |
||
| 160 | |||
| 161 | /** |
||
| 162 | * Get the class name that will be used to construct new |
||
| 163 | * items via the magic methods. |
||
| 164 | * |
||
| 165 | * @return string |
||
| 166 | */ |
||
| 167 | public static function getMetaItemClass() |
||
| 171 | |||
| 172 | /** |
||
| 173 | * Set the class name that will be used to construct new |
||
| 174 | * items via the magic methods. |
||
| 175 | * |
||
| 176 | * @param $class |
||
| 177 | */ |
||
| 178 | public static function setMetaItemClass($class) |
||
| 186 | |||
| 187 | /** |
||
| 188 | * Get the default tag name that will be used to construct new |
||
| 189 | * items via the magic methods. |
||
| 190 | * |
||
| 191 | * @return string |
||
| 192 | */ |
||
| 193 | public function getDefaultTag() |
||
| 197 | |||
| 198 | /** |
||
| 199 | * Set the default tag name that will be used to construct new |
||
| 200 | * items via the magic methods. |
||
| 201 | * |
||
| 202 | * @param $name |
||
| 203 | * @return $this |
||
| 204 | */ |
||
| 205 | public function setDefaultTag($name) |
||
| 211 | |||
| 212 | /** |
||
| 213 | * Resolve calls to filter the collection by item attributes. |
||
| 214 | * |
||
| 215 | * @param string $name |
||
| 216 | * @param array $arguments |
||
| 217 | * @return static |
||
| 218 | */ |
||
| 219 | public function __call($name, $arguments) |
||
| 226 | |||
| 227 | /** |
||
| 228 | * Resolve calls to check whether an item with a specific key name exists. |
||
| 229 | * |
||
| 230 | * @param $name |
||
| 231 | * @return bool |
||
| 232 | */ |
||
| 233 | public function __isset($name) |
||
| 237 | |||
| 238 | /** |
||
| 239 | * Resolve calls to unset an item with a specific key name. |
||
| 240 | * |
||
| 241 | * @param $name |
||
| 242 | */ |
||
| 243 | public function __unset($name) |
||
| 251 | |||
| 252 | /** |
||
| 253 | * Resolve calls to get an item with a specific key name or a |
||
| 254 | * collection of items with a specific tag name. |
||
| 255 | * |
||
| 256 | * @param $name |
||
| 257 | * @return mixed |
||
| 258 | */ |
||
| 259 | public function __get($name) |
||
| 273 | |||
| 274 | /** |
||
| 275 | * Resolve calls to set a new item to the collection or |
||
| 276 | * update an existing key. |
||
| 277 | * |
||
| 278 | * @param $name |
||
| 279 | * @param $value |
||
| 280 | */ |
||
| 281 | public function __set($name, $value) |
||
| 300 | } |
||
| 301 |