Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Collection.php
Go to the documentation of this file.
1 <?php
7 
12 {
18  protected $assets = [];
19 
27  public function add($identifier, AssetInterface $asset)
28  {
29  $this->assets[$identifier] = $asset;
30  }
31 
38  public function insert($identifier, AssetInterface $asset, $key)
39  {
40  $result = [];
41  foreach ($this->assets as $assetKey => $assetVal) {
42  if ($assetKey == $key) {
43  $result[$key] = $assetVal;
44  $result[$identifier] = $asset;
45  } else {
46  $result[$assetKey] = $assetVal;
47  }
48  }
49 
50  $this->assets = $result;
51  }
52 
59  public function has($identifier)
60  {
61  return isset($this->assets[$identifier]);
62  }
63 
70  public function remove($identifier)
71  {
72  unset($this->assets[$identifier]);
73  }
74 
80  public function getAll()
81  {
82  return $this->assets;
83  }
84 }
add($identifier, AssetInterface $asset)
Definition: Collection.php:27
insert($identifier, AssetInterface $asset, $key)
Definition: Collection.php:38