1 | <?php |
||
23 | abstract class AssetManager implements AssetManagerInterface |
||
24 | { |
||
25 | |||
26 | /** |
||
27 | * @var AssetCollection $assets |
||
28 | */ |
||
29 | protected $assets; |
||
30 | |||
31 | /** |
||
32 | * @var DomainInterface |
||
33 | */ |
||
34 | protected $domain; |
||
35 | |||
36 | /** |
||
37 | * @var Registry $registry |
||
38 | */ |
||
39 | protected $registry; |
||
40 | |||
41 | |||
42 | /** |
||
43 | * AssetRegister constructor. |
||
44 | * |
||
45 | * @param DomainInterface $domain |
||
46 | * @param AssetCollection $assets |
||
47 | * @param Registry $registry |
||
48 | */ |
||
49 | public function __construct(DomainInterface $domain, AssetCollection $assets, Registry $registry) |
||
59 | |||
60 | |||
61 | /** |
||
62 | * @since $VID:$ |
||
63 | * @return string |
||
64 | */ |
||
65 | public function assetNamespace() |
||
69 | |||
70 | |||
71 | /** |
||
72 | * @return void |
||
73 | * @throws DuplicateCollectionIdentifierException |
||
74 | * @throws InvalidDataTypeException |
||
75 | * @throws InvalidEntityException |
||
76 | * @since 4.9.62.p |
||
77 | */ |
||
78 | public function addManifestFile() |
||
87 | |||
88 | |||
89 | /** |
||
90 | * @return ManifestFile[] |
||
91 | * @since 4.9.62.p |
||
92 | */ |
||
93 | public function getManifestFile() |
||
97 | |||
98 | |||
99 | /** |
||
100 | * @param string $handle |
||
101 | * @param string $source |
||
102 | * @param array $dependencies |
||
103 | * @param bool $load_in_footer |
||
104 | * @return JavascriptAsset |
||
105 | * @throws DuplicateCollectionIdentifierException |
||
106 | * @throws InvalidDataTypeException |
||
107 | * @throws InvalidEntityException |
||
108 | * @since 4.9.62.p |
||
109 | */ |
||
110 | public function addJavascript( |
||
111 | $handle, |
||
112 | $source, |
||
113 | array $dependencies = array(), |
||
114 | $load_in_footer = true |
||
115 | ) { |
||
116 | $asset = new JavascriptAsset( |
||
117 | $handle, |
||
118 | $source, |
||
119 | $dependencies, |
||
120 | $load_in_footer, |
||
121 | $this->domain |
||
122 | ); |
||
123 | $this->assets->add($asset, $handle); |
||
124 | return $asset; |
||
125 | } |
||
126 | |||
127 | |||
128 | /** |
||
129 | * @param string $handle |
||
130 | * @param array $dependencies |
||
131 | * @param bool $load_in_footer |
||
132 | * @return JavascriptAsset |
||
133 | * @throws DuplicateCollectionIdentifierException |
||
134 | * @throws InvalidDataTypeException |
||
135 | * @throws InvalidEntityException |
||
136 | * @throws DomainException |
||
137 | * @since $VID:$ |
||
138 | */ |
||
139 | public function addVendorJavascript( |
||
140 | $handle, |
||
141 | array $dependencies = array(), |
||
142 | $load_in_footer = true |
||
143 | ) { |
||
144 | $dev_suffix = wp_scripts_get_suffix('dev'); |
||
145 | $vendor_path = $this->domain->pluginUrl() . 'assets/vendor/'; |
||
146 | return $this->addJavascript( |
||
147 | $handle, |
||
148 | "{$vendor_path}{$handle}{$dev_suffix}.js", |
||
149 | $dependencies, |
||
150 | $load_in_footer |
||
151 | ); |
||
152 | } |
||
153 | |||
154 | |||
155 | |||
156 | /** |
||
157 | * @param string $handle |
||
158 | * @param string $source |
||
159 | * @param array $dependencies |
||
160 | * @param string $media |
||
161 | * @return StylesheetAsset |
||
162 | * @throws DuplicateCollectionIdentifierException |
||
163 | * @throws InvalidDataTypeException |
||
164 | * @throws InvalidEntityException |
||
165 | * @since 4.9.62.p |
||
166 | */ |
||
167 | public function addStylesheet( |
||
183 | |||
184 | |||
185 | /** |
||
186 | * @param string $handle |
||
187 | * @return bool |
||
188 | * @since 4.9.62.p |
||
189 | */ |
||
190 | public function enqueueAsset($handle) |
||
201 | } |
||
202 |