1 | <?php |
||
16 | abstract class Asset |
||
17 | { |
||
18 | |||
19 | /** |
||
20 | * indicates the file extension for a build distribution CSS file |
||
21 | */ |
||
22 | const FILE_EXTENSION_DISTRIBUTION_CSS = '.dist.css'; |
||
23 | |||
24 | /** |
||
25 | * indicates the file extension for a build distribution JS file |
||
26 | */ |
||
27 | const FILE_EXTENSION_DISTRIBUTION_JS = '.dist.js'; |
||
28 | |||
29 | /** |
||
30 | * indicates a Cascading Style Sheet asset |
||
31 | */ |
||
32 | const TYPE_CSS = 'css'; |
||
33 | |||
34 | /** |
||
35 | * indicates a Javascript asset |
||
36 | */ |
||
37 | const TYPE_JS = 'js'; |
||
38 | |||
39 | /** |
||
40 | * indicates a Javascript manifest file |
||
41 | */ |
||
42 | const TYPE_MANIFEST = 'manifest'; |
||
43 | |||
44 | /** |
||
45 | * @var DomainInterface $domain |
||
46 | */ |
||
47 | protected $domain; |
||
48 | |||
49 | /** |
||
50 | * @var string $type |
||
51 | */ |
||
52 | private $type; |
||
53 | |||
54 | /** |
||
55 | * @var string $handle |
||
56 | */ |
||
57 | private $handle; |
||
58 | |||
59 | /** |
||
60 | * @var bool $registered |
||
61 | */ |
||
62 | private $registered = false; |
||
63 | |||
64 | |||
65 | /** |
||
66 | * Asset constructor. |
||
67 | * |
||
68 | * @param $type |
||
69 | * @param string $handle |
||
70 | * @param DomainInterface $domain |
||
71 | * @throws InvalidDataTypeException |
||
72 | */ |
||
73 | public function __construct($type, $handle, DomainInterface $domain) |
||
79 | |||
80 | |||
81 | /** |
||
82 | * @return array |
||
83 | */ |
||
84 | public function validAssetTypes() |
||
92 | |||
93 | |||
94 | /** |
||
95 | * @param string $type |
||
96 | * @throws InvalidDataTypeException |
||
97 | */ |
||
98 | private function setType($type) |
||
109 | |||
110 | |||
111 | /** |
||
112 | * @param string $handle |
||
113 | * @throws InvalidDataTypeException |
||
114 | */ |
||
115 | private function setHandle($handle) |
||
126 | |||
127 | |||
128 | /** |
||
129 | * @return string |
||
130 | */ |
||
131 | public function assetNamespace() |
||
135 | |||
136 | |||
137 | /** |
||
138 | * @return string |
||
139 | */ |
||
140 | public function type() |
||
144 | |||
145 | |||
146 | /** |
||
147 | * @return string |
||
148 | */ |
||
149 | public function handle() |
||
153 | |||
154 | /** |
||
155 | * @return bool |
||
156 | */ |
||
157 | public function isRegistered() |
||
161 | |||
162 | /** |
||
163 | * @param bool $registered |
||
164 | */ |
||
165 | public function setRegistered($registered = true) |
||
169 | } |
||
170 |