@@ -21,201 +21,201 @@ |
||
| 21 | 21 | { |
| 22 | 22 | |
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * AssetCollection constructor |
|
| 26 | - * |
|
| 27 | - * @throws InvalidInterfaceException |
|
| 28 | - */ |
|
| 29 | - public function __construct() |
|
| 30 | - { |
|
| 31 | - parent::__construct('EventEspresso\core\domain\values\assets\Asset'); |
|
| 32 | - } |
|
| 33 | - |
|
| 34 | - |
|
| 35 | - /** |
|
| 36 | - * @return StylesheetAsset[] |
|
| 37 | - * @since 4.9.62.p |
|
| 38 | - */ |
|
| 39 | - public function getStylesheetAssets() |
|
| 40 | - { |
|
| 41 | - return $this->getAssetsOfType(Asset::TYPE_CSS); |
|
| 42 | - } |
|
| 43 | - |
|
| 44 | - |
|
| 45 | - /** |
|
| 46 | - * @return JavascriptAsset[] |
|
| 47 | - * @since 4.9.62.p |
|
| 48 | - */ |
|
| 49 | - public function getJavascriptAssets() |
|
| 50 | - { |
|
| 51 | - return $this->getAssetsOfType(Asset::TYPE_JS); |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - |
|
| 55 | - /** |
|
| 56 | - * @return ManifestFile[] |
|
| 57 | - * @since 4.9.62.p |
|
| 58 | - */ |
|
| 59 | - public function getManifestFiles() |
|
| 60 | - { |
|
| 61 | - return $this->getAssetsOfType(Asset::TYPE_MANIFEST); |
|
| 62 | - } |
|
| 63 | - |
|
| 64 | - |
|
| 65 | - /** |
|
| 66 | - * @param $type |
|
| 67 | - * @return JavascriptAsset[]|StylesheetAsset[]|ManifestFile[] |
|
| 68 | - * @since 4.9.62.p |
|
| 69 | - */ |
|
| 70 | - protected function getAssetsOfType($type) |
|
| 71 | - { |
|
| 72 | - $files = array(); |
|
| 73 | - $this->rewind(); |
|
| 74 | - while ($this->valid()) { |
|
| 75 | - /** @var Asset $asset */ |
|
| 76 | - $asset = $this->current(); |
|
| 77 | - if ($asset->type() === $type) { |
|
| 78 | - $files[ $asset->handle() ] = $asset; |
|
| 79 | - } |
|
| 80 | - $this->next(); |
|
| 81 | - } |
|
| 82 | - $this->rewind(); |
|
| 83 | - return $files; |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - |
|
| 87 | - /** |
|
| 88 | - * @return JavascriptAsset[] |
|
| 89 | - * @since 4.9.62.p |
|
| 90 | - */ |
|
| 91 | - public function getJavascriptAssetsWithData() |
|
| 92 | - { |
|
| 93 | - $files = array(); |
|
| 94 | - $this->rewind(); |
|
| 95 | - while ($this->valid()) { |
|
| 96 | - /** @var JavascriptAsset $asset */ |
|
| 97 | - $asset = $this->current(); |
|
| 98 | - if ($asset->type() === Asset::TYPE_JS && $asset->hasInlineData()) { |
|
| 99 | - $files[ $asset->handle() ] = $asset; |
|
| 100 | - } |
|
| 101 | - $this->next(); |
|
| 102 | - } |
|
| 103 | - $this->rewind(); |
|
| 104 | - return $files; |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - |
|
| 108 | - /** |
|
| 109 | - * has |
|
| 110 | - * returns TRUE or FALSE |
|
| 111 | - * depending on whether the object is within the Collection |
|
| 112 | - * based on the supplied $identifier and type |
|
| 113 | - * |
|
| 114 | - * @param mixed $identifier |
|
| 115 | - * @param string $type |
|
| 116 | - * @return bool |
|
| 117 | - * @since $VID:$ |
|
| 118 | - */ |
|
| 119 | - public function hasAssetOfType($identifier, $type = Asset::TYPE_JS) |
|
| 120 | - { |
|
| 121 | - $this->rewind(); |
|
| 122 | - while ($this->valid()) { |
|
| 123 | - if ($this->getInfo() === $identifier && $this->current()->type() === $type) { |
|
| 124 | - $this->rewind(); |
|
| 125 | - return true; |
|
| 126 | - } |
|
| 127 | - $this->next(); |
|
| 128 | - } |
|
| 129 | - return false; |
|
| 130 | - } |
|
| 131 | - |
|
| 132 | - |
|
| 133 | - /** |
|
| 134 | - * has |
|
| 135 | - * returns TRUE or FALSE |
|
| 136 | - * depending on whether the Stylesheet Asset is within the Collection |
|
| 137 | - * based on the supplied $identifier |
|
| 138 | - * |
|
| 139 | - * @param mixed $identifier |
|
| 140 | - * @return bool |
|
| 141 | - * @since $VID:$ |
|
| 142 | - */ |
|
| 143 | - public function hasStylesheetAsset($identifier) |
|
| 144 | - { |
|
| 145 | - return $this->hasAssetOfType($identifier, Asset::TYPE_CSS); |
|
| 146 | - } |
|
| 147 | - |
|
| 148 | - |
|
| 149 | - /** |
|
| 150 | - * has |
|
| 151 | - * returns TRUE or FALSE |
|
| 152 | - * depending on whether the Javascript Asset is within the Collection |
|
| 153 | - * based on the supplied $identifier |
|
| 154 | - * |
|
| 155 | - * @param mixed $identifier |
|
| 156 | - * @return bool |
|
| 157 | - * @since $VID:$ |
|
| 158 | - */ |
|
| 159 | - public function hasJavascriptAsset($identifier) |
|
| 160 | - { |
|
| 161 | - return $this->hasAssetOfType($identifier, Asset::TYPE_JS); |
|
| 162 | - } |
|
| 163 | - |
|
| 164 | - /** |
|
| 165 | - * has |
|
| 166 | - * returns TRUE or FALSE |
|
| 167 | - * depending on whether the object is within the Collection |
|
| 168 | - * based on the supplied $identifier and type |
|
| 169 | - * |
|
| 170 | - * @param mixed $identifier |
|
| 171 | - * @param string $type |
|
| 172 | - * @return JavascriptAsset|StylesheetAsset |
|
| 173 | - * @since $VID:$ |
|
| 174 | - */ |
|
| 175 | - public function getAssetOfType($identifier, $type = Asset::TYPE_JS) |
|
| 176 | - { |
|
| 177 | - $this->rewind(); |
|
| 178 | - while ($this->valid()) { |
|
| 179 | - if ($this->getInfo() === $identifier && $this->current()->type() === $type) { |
|
| 180 | - /** @var JavascriptAsset|StylesheetAsset $object */ |
|
| 181 | - $object = $this->current(); |
|
| 182 | - $this->rewind(); |
|
| 183 | - return $object; |
|
| 184 | - } |
|
| 185 | - $this->next(); |
|
| 186 | - } |
|
| 187 | - return null; |
|
| 188 | - } |
|
| 189 | - |
|
| 190 | - |
|
| 191 | - /** |
|
| 192 | - * has |
|
| 193 | - * returns TRUE or FALSE |
|
| 194 | - * depending on whether the Stylesheet Asset is within the Collection |
|
| 195 | - * based on the supplied $identifier |
|
| 196 | - * |
|
| 197 | - * @param mixed $identifier |
|
| 198 | - * @return StylesheetAsset |
|
| 199 | - * @since $VID:$ |
|
| 200 | - */ |
|
| 201 | - public function getStylesheetAsset($identifier) |
|
| 202 | - { |
|
| 203 | - return $this->getAssetOfType($identifier, Asset::TYPE_CSS); |
|
| 204 | - } |
|
| 205 | - |
|
| 206 | - |
|
| 207 | - /** |
|
| 208 | - * has |
|
| 209 | - * returns TRUE or FALSE |
|
| 210 | - * depending on whether the Javascript Asset is within the Collection |
|
| 211 | - * based on the supplied $identifier |
|
| 212 | - * |
|
| 213 | - * @param mixed $identifier |
|
| 214 | - * @return JavascriptAsset |
|
| 215 | - * @since $VID:$ |
|
| 216 | - */ |
|
| 217 | - public function getJavascriptAsset($identifier) |
|
| 218 | - { |
|
| 219 | - return $this->getAssetOfType($identifier, Asset::TYPE_JS); |
|
| 220 | - } |
|
| 24 | + /** |
|
| 25 | + * AssetCollection constructor |
|
| 26 | + * |
|
| 27 | + * @throws InvalidInterfaceException |
|
| 28 | + */ |
|
| 29 | + public function __construct() |
|
| 30 | + { |
|
| 31 | + parent::__construct('EventEspresso\core\domain\values\assets\Asset'); |
|
| 32 | + } |
|
| 33 | + |
|
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * @return StylesheetAsset[] |
|
| 37 | + * @since 4.9.62.p |
|
| 38 | + */ |
|
| 39 | + public function getStylesheetAssets() |
|
| 40 | + { |
|
| 41 | + return $this->getAssetsOfType(Asset::TYPE_CSS); |
|
| 42 | + } |
|
| 43 | + |
|
| 44 | + |
|
| 45 | + /** |
|
| 46 | + * @return JavascriptAsset[] |
|
| 47 | + * @since 4.9.62.p |
|
| 48 | + */ |
|
| 49 | + public function getJavascriptAssets() |
|
| 50 | + { |
|
| 51 | + return $this->getAssetsOfType(Asset::TYPE_JS); |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + |
|
| 55 | + /** |
|
| 56 | + * @return ManifestFile[] |
|
| 57 | + * @since 4.9.62.p |
|
| 58 | + */ |
|
| 59 | + public function getManifestFiles() |
|
| 60 | + { |
|
| 61 | + return $this->getAssetsOfType(Asset::TYPE_MANIFEST); |
|
| 62 | + } |
|
| 63 | + |
|
| 64 | + |
|
| 65 | + /** |
|
| 66 | + * @param $type |
|
| 67 | + * @return JavascriptAsset[]|StylesheetAsset[]|ManifestFile[] |
|
| 68 | + * @since 4.9.62.p |
|
| 69 | + */ |
|
| 70 | + protected function getAssetsOfType($type) |
|
| 71 | + { |
|
| 72 | + $files = array(); |
|
| 73 | + $this->rewind(); |
|
| 74 | + while ($this->valid()) { |
|
| 75 | + /** @var Asset $asset */ |
|
| 76 | + $asset = $this->current(); |
|
| 77 | + if ($asset->type() === $type) { |
|
| 78 | + $files[ $asset->handle() ] = $asset; |
|
| 79 | + } |
|
| 80 | + $this->next(); |
|
| 81 | + } |
|
| 82 | + $this->rewind(); |
|
| 83 | + return $files; |
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + |
|
| 87 | + /** |
|
| 88 | + * @return JavascriptAsset[] |
|
| 89 | + * @since 4.9.62.p |
|
| 90 | + */ |
|
| 91 | + public function getJavascriptAssetsWithData() |
|
| 92 | + { |
|
| 93 | + $files = array(); |
|
| 94 | + $this->rewind(); |
|
| 95 | + while ($this->valid()) { |
|
| 96 | + /** @var JavascriptAsset $asset */ |
|
| 97 | + $asset = $this->current(); |
|
| 98 | + if ($asset->type() === Asset::TYPE_JS && $asset->hasInlineData()) { |
|
| 99 | + $files[ $asset->handle() ] = $asset; |
|
| 100 | + } |
|
| 101 | + $this->next(); |
|
| 102 | + } |
|
| 103 | + $this->rewind(); |
|
| 104 | + return $files; |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + |
|
| 108 | + /** |
|
| 109 | + * has |
|
| 110 | + * returns TRUE or FALSE |
|
| 111 | + * depending on whether the object is within the Collection |
|
| 112 | + * based on the supplied $identifier and type |
|
| 113 | + * |
|
| 114 | + * @param mixed $identifier |
|
| 115 | + * @param string $type |
|
| 116 | + * @return bool |
|
| 117 | + * @since $VID:$ |
|
| 118 | + */ |
|
| 119 | + public function hasAssetOfType($identifier, $type = Asset::TYPE_JS) |
|
| 120 | + { |
|
| 121 | + $this->rewind(); |
|
| 122 | + while ($this->valid()) { |
|
| 123 | + if ($this->getInfo() === $identifier && $this->current()->type() === $type) { |
|
| 124 | + $this->rewind(); |
|
| 125 | + return true; |
|
| 126 | + } |
|
| 127 | + $this->next(); |
|
| 128 | + } |
|
| 129 | + return false; |
|
| 130 | + } |
|
| 131 | + |
|
| 132 | + |
|
| 133 | + /** |
|
| 134 | + * has |
|
| 135 | + * returns TRUE or FALSE |
|
| 136 | + * depending on whether the Stylesheet Asset is within the Collection |
|
| 137 | + * based on the supplied $identifier |
|
| 138 | + * |
|
| 139 | + * @param mixed $identifier |
|
| 140 | + * @return bool |
|
| 141 | + * @since $VID:$ |
|
| 142 | + */ |
|
| 143 | + public function hasStylesheetAsset($identifier) |
|
| 144 | + { |
|
| 145 | + return $this->hasAssetOfType($identifier, Asset::TYPE_CSS); |
|
| 146 | + } |
|
| 147 | + |
|
| 148 | + |
|
| 149 | + /** |
|
| 150 | + * has |
|
| 151 | + * returns TRUE or FALSE |
|
| 152 | + * depending on whether the Javascript Asset is within the Collection |
|
| 153 | + * based on the supplied $identifier |
|
| 154 | + * |
|
| 155 | + * @param mixed $identifier |
|
| 156 | + * @return bool |
|
| 157 | + * @since $VID:$ |
|
| 158 | + */ |
|
| 159 | + public function hasJavascriptAsset($identifier) |
|
| 160 | + { |
|
| 161 | + return $this->hasAssetOfType($identifier, Asset::TYPE_JS); |
|
| 162 | + } |
|
| 163 | + |
|
| 164 | + /** |
|
| 165 | + * has |
|
| 166 | + * returns TRUE or FALSE |
|
| 167 | + * depending on whether the object is within the Collection |
|
| 168 | + * based on the supplied $identifier and type |
|
| 169 | + * |
|
| 170 | + * @param mixed $identifier |
|
| 171 | + * @param string $type |
|
| 172 | + * @return JavascriptAsset|StylesheetAsset |
|
| 173 | + * @since $VID:$ |
|
| 174 | + */ |
|
| 175 | + public function getAssetOfType($identifier, $type = Asset::TYPE_JS) |
|
| 176 | + { |
|
| 177 | + $this->rewind(); |
|
| 178 | + while ($this->valid()) { |
|
| 179 | + if ($this->getInfo() === $identifier && $this->current()->type() === $type) { |
|
| 180 | + /** @var JavascriptAsset|StylesheetAsset $object */ |
|
| 181 | + $object = $this->current(); |
|
| 182 | + $this->rewind(); |
|
| 183 | + return $object; |
|
| 184 | + } |
|
| 185 | + $this->next(); |
|
| 186 | + } |
|
| 187 | + return null; |
|
| 188 | + } |
|
| 189 | + |
|
| 190 | + |
|
| 191 | + /** |
|
| 192 | + * has |
|
| 193 | + * returns TRUE or FALSE |
|
| 194 | + * depending on whether the Stylesheet Asset is within the Collection |
|
| 195 | + * based on the supplied $identifier |
|
| 196 | + * |
|
| 197 | + * @param mixed $identifier |
|
| 198 | + * @return StylesheetAsset |
|
| 199 | + * @since $VID:$ |
|
| 200 | + */ |
|
| 201 | + public function getStylesheetAsset($identifier) |
|
| 202 | + { |
|
| 203 | + return $this->getAssetOfType($identifier, Asset::TYPE_CSS); |
|
| 204 | + } |
|
| 205 | + |
|
| 206 | + |
|
| 207 | + /** |
|
| 208 | + * has |
|
| 209 | + * returns TRUE or FALSE |
|
| 210 | + * depending on whether the Javascript Asset is within the Collection |
|
| 211 | + * based on the supplied $identifier |
|
| 212 | + * |
|
| 213 | + * @param mixed $identifier |
|
| 214 | + * @return JavascriptAsset |
|
| 215 | + * @since $VID:$ |
|
| 216 | + */ |
|
| 217 | + public function getJavascriptAsset($identifier) |
|
| 218 | + { |
|
| 219 | + return $this->getAssetOfType($identifier, Asset::TYPE_JS); |
|
| 220 | + } |
|
| 221 | 221 | } |