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 the file extension for a build distribution dependencies json file. |
||
31 | */ |
||
32 | const FILE_EXTENSION_DISTRIBUTION_DEPS = '.dist.deps.php'; |
||
33 | |||
34 | /** |
||
35 | * indicates a Cascading Style Sheet asset |
||
36 | */ |
||
37 | const TYPE_CSS = 'css'; |
||
38 | |||
39 | /** |
||
40 | * indicates a Javascript asset |
||
41 | */ |
||
42 | const TYPE_JS = 'js'; |
||
43 | |||
44 | /** |
||
45 | * indicates a JSON asset |
||
46 | */ |
||
47 | CONST TYPE_JSON = 'json'; |
||
48 | /** |
||
49 | * indicates a PHP asset |
||
50 | */ |
||
51 | CONST TYPE_PHP = 'php'; |
||
52 | |||
53 | /** |
||
54 | * indicates a Javascript manifest file |
||
55 | */ |
||
56 | const TYPE_MANIFEST = 'manifest'; |
||
57 | |||
58 | /** |
||
59 | * @var DomainInterface $domain |
||
60 | */ |
||
61 | protected $domain; |
||
62 | |||
63 | /** |
||
64 | * @var string $type |
||
65 | */ |
||
66 | private $type; |
||
67 | |||
68 | /** |
||
69 | * @var string $handle |
||
70 | */ |
||
71 | private $handle; |
||
72 | |||
73 | /** |
||
74 | * @var bool $registered |
||
75 | */ |
||
76 | private $registered = false; |
||
77 | |||
78 | /** |
||
79 | * @var bool $enqueue_immediately |
||
80 | */ |
||
81 | private $enqueue_immediately = false; |
||
82 | |||
83 | |||
84 | /** |
||
85 | * Asset constructor. |
||
86 | * |
||
87 | * @param $type |
||
88 | * @param string $handle |
||
89 | * @param DomainInterface $domain |
||
90 | * @throws InvalidDataTypeException |
||
91 | */ |
||
92 | public function __construct($type, $handle, DomainInterface $domain) |
||
98 | |||
99 | |||
100 | /** |
||
101 | * @return array |
||
102 | */ |
||
103 | public function validAssetTypes() |
||
111 | |||
112 | |||
113 | /** |
||
114 | * @param string $type |
||
115 | * @throws InvalidDataTypeException |
||
116 | */ |
||
117 | private function setType($type) |
||
128 | |||
129 | |||
130 | /** |
||
131 | * @param string $handle |
||
132 | * @throws InvalidDataTypeException |
||
133 | */ |
||
134 | private function setHandle($handle) |
||
145 | |||
146 | |||
147 | /** |
||
148 | * @return string |
||
149 | */ |
||
150 | public function assetNamespace() |
||
154 | |||
155 | |||
156 | /** |
||
157 | * @return string |
||
158 | */ |
||
159 | public function type() |
||
163 | |||
164 | |||
165 | /** |
||
166 | * @return string |
||
167 | */ |
||
168 | public function handle() |
||
172 | |||
173 | /** |
||
174 | * @return bool |
||
175 | */ |
||
176 | public function isRegistered() |
||
180 | |||
181 | /** |
||
182 | * @param bool $registered |
||
183 | */ |
||
184 | public function setRegistered($registered = true) |
||
188 | |||
189 | |||
190 | /** |
||
191 | * @return bool |
||
192 | */ |
||
193 | public function enqueueImmediately() |
||
197 | |||
198 | |||
199 | /** |
||
200 | * @param bool $enqueue_immediately |
||
201 | */ |
||
202 | public function setEnqueueImmediately($enqueue_immediately = true) |
||
206 | } |
||
207 |