@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | foreach ($this->blocks as $block) { |
146 | 146 | $block->initialize(); |
147 | 147 | $this->trackAssetManagersForBlocks($block); |
148 | - if (! $this->block_asset_manager_collection->has($block->assetManager())) { |
|
148 | + if ( ! $this->block_asset_manager_collection->has($block->assetManager())) { |
|
149 | 149 | $this->block_asset_manager_collection->add($block->assetManager()); |
150 | 150 | $block->assetManager()->setAssetHandles(); |
151 | 151 | } |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | $supported_routes = $block->supportedRoutes(); |
168 | 168 | foreach ($supported_routes as $supported_route) { |
169 | 169 | if ($this->route_manager->currentRequestMatches($supported_route)) { |
170 | - $this->block_asset_managers[ $block->blockType() ] = $block->assetManager()->assetNamespace(); |
|
170 | + $this->block_asset_managers[$block->blockType()] = $block->assetManager()->assetNamespace(); |
|
171 | 171 | } |
172 | 172 | } |
173 | 173 | } |
@@ -183,10 +183,10 @@ discard block |
||
183 | 183 | */ |
184 | 184 | public function matchesRoute(BlockInterface $block) |
185 | 185 | { |
186 | - if(isset($this->block_asset_managers[ $block->blockType() ])) { |
|
186 | + if (isset($this->block_asset_managers[$block->blockType()])) { |
|
187 | 187 | return true; |
188 | 188 | } |
189 | - unset($this->block_asset_managers[ $block->blockType() ]); |
|
189 | + unset($this->block_asset_managers[$block->blockType()]); |
|
190 | 190 | return false; |
191 | 191 | } |
192 | 192 | |
@@ -202,12 +202,12 @@ discard block |
||
202 | 202 | try { |
203 | 203 | // cycle thru block loader folders |
204 | 204 | foreach ($this->blocks as $block) { |
205 | - if (! $this->matchesRoute($block)) { |
|
205 | + if ( ! $this->matchesRoute($block)) { |
|
206 | 206 | continue; |
207 | 207 | } |
208 | 208 | // perform any setup required for the block |
209 | 209 | $block_type = $block->registerBlock(); |
210 | - if (! $block_type instanceof WP_Block_Type) { |
|
210 | + if ( ! $block_type instanceof WP_Block_Type) { |
|
211 | 211 | throw new InvalidEntityException($block_type, 'WP_Block_Type'); |
212 | 212 | } |
213 | 213 | do_action( |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | $assets = array_flip($this->block_asset_managers); |
227 | 227 | foreach ($this->block_asset_manager_collection as $asset_manager) { |
228 | 228 | // if there are no longer any blocks that require these assets, |
229 | - if(! isset($assets[ $asset_manager->assetNamespace() ])) { |
|
229 | + if ( ! isset($assets[$asset_manager->assetNamespace()])) { |
|
230 | 230 | // then unset asset enqueueing and bail |
231 | 231 | remove_action('wp_enqueue_scripts', array($asset_manager, 'addManifestFile'), 0); |
232 | 232 | remove_action('admin_enqueue_scripts', array($asset_manager, 'addManifestFile'), 0); |
@@ -32,210 +32,210 @@ |
||
32 | 32 | class BlockRegistrationManager extends BlockManager |
33 | 33 | { |
34 | 34 | |
35 | - /** |
|
36 | - * @var BlockAssetManagerCollection $block_asset_manager_collection |
|
37 | - */ |
|
38 | - protected $block_asset_manager_collection; |
|
39 | - |
|
40 | - /** |
|
41 | - * @var RouteMatchSpecificationManager $route_manager |
|
42 | - */ |
|
43 | - protected $route_manager; |
|
44 | - |
|
45 | - /** |
|
46 | - * array for tracking asset managers required by blocks for the current route |
|
47 | - * |
|
48 | - * @var array $block_asset_managers |
|
49 | - */ |
|
50 | - protected $block_asset_managers = array(); |
|
51 | - |
|
52 | - |
|
53 | - /** |
|
54 | - * BlockRegistrationManager constructor. |
|
55 | - * |
|
56 | - * @param BlockAssetManagerCollection $block_asset_manager_collection |
|
57 | - * @param BlockCollection $blocks |
|
58 | - * @param RouteMatchSpecificationManager $route_manager |
|
59 | - * @param RequestInterface $request |
|
60 | - */ |
|
61 | - public function __construct( |
|
62 | - BlockAssetManagerCollection $block_asset_manager_collection, |
|
63 | - BlockCollection $blocks, |
|
64 | - RouteMatchSpecificationManager $route_manager, |
|
65 | - RequestInterface $request |
|
66 | - ) { |
|
67 | - $this->block_asset_manager_collection = $block_asset_manager_collection; |
|
68 | - $this->route_manager = $route_manager; |
|
69 | - parent::__construct($blocks, $request); |
|
70 | - } |
|
71 | - |
|
72 | - |
|
73 | - /** |
|
74 | - * Returns the name of a hookpoint to be used to call initialize() |
|
75 | - * |
|
76 | - * @return string |
|
77 | - */ |
|
78 | - public function initHook() |
|
79 | - { |
|
80 | - return 'AHEE__EE_System__initialize'; |
|
81 | - } |
|
82 | - |
|
83 | - |
|
84 | - /** |
|
85 | - * Perform any early setup required for block editors to functions |
|
86 | - * |
|
87 | - * @return void |
|
88 | - * @throws Exception |
|
89 | - */ |
|
90 | - public function initialize() |
|
91 | - { |
|
92 | - $this->initializeBlocks(); |
|
93 | - add_action('AHEE__EE_System__initialize_last', array($this, 'registerBlocks')); |
|
94 | - add_action('wp_loaded', array($this, 'unloadAssets')); |
|
95 | - } |
|
96 | - |
|
97 | - |
|
98 | - /** |
|
99 | - * @return CollectionInterface|BlockInterface[] |
|
100 | - * @throws CollectionLoaderException |
|
101 | - * @throws CollectionDetailsException |
|
102 | - */ |
|
103 | - protected function populateBlockCollection() |
|
104 | - { |
|
105 | - $loader = new CollectionLoader( |
|
106 | - new CollectionDetails( |
|
107 | - // collection name |
|
108 | - 'editor_blocks', |
|
109 | - // collection interface |
|
110 | - 'EventEspresso\core\domain\entities\editor\BlockInterface', |
|
111 | - // FQCNs for classes to add (all classes within each namespace will be loaded) |
|
112 | - apply_filters( |
|
113 | - 'FHEE__EventEspresso_core_services_editor_BlockManager__populateBlockCollection__collection_FQCNs', |
|
114 | - array( |
|
115 | - // 'EventEspresso\core\domain\entities\editor\blocks\common', |
|
116 | - // 'EventEspresso\core\domain\entities\editor\blocks\editor', |
|
117 | - // 'EventEspresso\core\domain\entities\editor\blocks\widgets', |
|
118 | - ) |
|
119 | - ), |
|
120 | - // filepaths to classes to add |
|
121 | - array(), |
|
122 | - // file mask to use if parsing folder for files to add |
|
123 | - '', |
|
124 | - // what to use as identifier for collection entities |
|
125 | - // using CLASS NAME prevents duplicates (works like a singleton) |
|
126 | - CollectionDetails::ID_CLASS_NAME |
|
127 | - ), |
|
128 | - $this->blocks |
|
129 | - ); |
|
130 | - return $loader->getCollection(); |
|
131 | - } |
|
132 | - |
|
133 | - |
|
134 | - /** |
|
135 | - * populates the BlockCollection and calls initialize() on all installed blocks |
|
136 | - * |
|
137 | - * @return void |
|
138 | - * @throws Exception |
|
139 | - */ |
|
140 | - public function initializeBlocks() |
|
141 | - { |
|
142 | - try { |
|
143 | - $this->populateBlockCollection(); |
|
144 | - // cycle thru block loaders and initialize each loader |
|
145 | - foreach ($this->blocks as $block) { |
|
146 | - $block->initialize(); |
|
147 | - $this->trackAssetManagersForBlocks($block); |
|
148 | - if (! $this->block_asset_manager_collection->has($block->assetManager())) { |
|
149 | - $this->block_asset_manager_collection->add($block->assetManager()); |
|
150 | - $block->assetManager()->setAssetHandles(); |
|
151 | - } |
|
152 | - } |
|
153 | - } catch (Exception $exception) { |
|
154 | - new ExceptionStackTraceDisplay($exception); |
|
155 | - } |
|
156 | - } |
|
157 | - |
|
158 | - |
|
159 | - /** |
|
160 | - * track blocks with routes that match the current request |
|
161 | - * |
|
162 | - * @param BlockInterface $block |
|
163 | - * @throws InvalidClassException |
|
164 | - */ |
|
165 | - private function trackAssetManagersForBlocks(BlockInterface $block) |
|
166 | - { |
|
167 | - $supported_routes = $block->supportedRoutes(); |
|
168 | - foreach ($supported_routes as $supported_route) { |
|
169 | - if ($this->route_manager->currentRequestMatches($supported_route)) { |
|
170 | - $this->block_asset_managers[ $block->blockType() ] = $block->assetManager()->assetNamespace(); |
|
171 | - } |
|
172 | - } |
|
173 | - } |
|
174 | - |
|
175 | - |
|
176 | - /** |
|
177 | - * returns true if the block should be registered for the current request |
|
178 | - * else removes block from block_routes array and returns false |
|
179 | - * |
|
180 | - * @param BlockInterface $block |
|
181 | - * @return boolean |
|
182 | - * @throws InvalidClassException |
|
183 | - */ |
|
184 | - public function matchesRoute(BlockInterface $block) |
|
185 | - { |
|
186 | - if(isset($this->block_asset_managers[ $block->blockType() ])) { |
|
187 | - return true; |
|
188 | - } |
|
189 | - unset($this->block_asset_managers[ $block->blockType() ]); |
|
190 | - return false; |
|
191 | - } |
|
192 | - |
|
193 | - |
|
194 | - /** |
|
195 | - * calls registerBlock() and load assets for all installed blocks |
|
196 | - * |
|
197 | - * @return void |
|
198 | - * @throws Exception |
|
199 | - */ |
|
200 | - public function registerBlocks() |
|
201 | - { |
|
202 | - try { |
|
203 | - // cycle thru block loader folders |
|
204 | - foreach ($this->blocks as $block) { |
|
205 | - if (! $this->matchesRoute($block)) { |
|
206 | - continue; |
|
207 | - } |
|
208 | - // perform any setup required for the block |
|
209 | - $block_type = $block->registerBlock(); |
|
210 | - if (! $block_type instanceof WP_Block_Type) { |
|
211 | - throw new InvalidEntityException($block_type, 'WP_Block_Type'); |
|
212 | - } |
|
213 | - do_action( |
|
214 | - 'FHEE__EventEspresso_core_services_editor_BlockManager__registerBlocks__block_type_registered', |
|
215 | - $block, |
|
216 | - $block_type |
|
217 | - ); |
|
218 | - } |
|
219 | - } catch (Exception $exception) { |
|
220 | - new ExceptionStackTraceDisplay($exception); |
|
221 | - } |
|
222 | - } |
|
223 | - |
|
224 | - public function unloadAssets() |
|
225 | - { |
|
226 | - $assets = array_flip($this->block_asset_managers); |
|
227 | - foreach ($this->block_asset_manager_collection as $asset_manager) { |
|
228 | - // if there are no longer any blocks that require these assets, |
|
229 | - if(! isset($assets[ $asset_manager->assetNamespace() ])) { |
|
230 | - // then unset asset enqueueing and bail |
|
231 | - remove_action('wp_enqueue_scripts', array($asset_manager, 'addManifestFile'), 0); |
|
232 | - remove_action('admin_enqueue_scripts', array($asset_manager, 'addManifestFile'), 0); |
|
233 | - remove_action('wp_enqueue_scripts', array($asset_manager, 'addAssets'), 2); |
|
234 | - remove_action('admin_enqueue_scripts', array($asset_manager, 'addAssets'), 2); |
|
235 | - |
|
236 | - } |
|
237 | - } |
|
238 | - |
|
239 | - } |
|
35 | + /** |
|
36 | + * @var BlockAssetManagerCollection $block_asset_manager_collection |
|
37 | + */ |
|
38 | + protected $block_asset_manager_collection; |
|
39 | + |
|
40 | + /** |
|
41 | + * @var RouteMatchSpecificationManager $route_manager |
|
42 | + */ |
|
43 | + protected $route_manager; |
|
44 | + |
|
45 | + /** |
|
46 | + * array for tracking asset managers required by blocks for the current route |
|
47 | + * |
|
48 | + * @var array $block_asset_managers |
|
49 | + */ |
|
50 | + protected $block_asset_managers = array(); |
|
51 | + |
|
52 | + |
|
53 | + /** |
|
54 | + * BlockRegistrationManager constructor. |
|
55 | + * |
|
56 | + * @param BlockAssetManagerCollection $block_asset_manager_collection |
|
57 | + * @param BlockCollection $blocks |
|
58 | + * @param RouteMatchSpecificationManager $route_manager |
|
59 | + * @param RequestInterface $request |
|
60 | + */ |
|
61 | + public function __construct( |
|
62 | + BlockAssetManagerCollection $block_asset_manager_collection, |
|
63 | + BlockCollection $blocks, |
|
64 | + RouteMatchSpecificationManager $route_manager, |
|
65 | + RequestInterface $request |
|
66 | + ) { |
|
67 | + $this->block_asset_manager_collection = $block_asset_manager_collection; |
|
68 | + $this->route_manager = $route_manager; |
|
69 | + parent::__construct($blocks, $request); |
|
70 | + } |
|
71 | + |
|
72 | + |
|
73 | + /** |
|
74 | + * Returns the name of a hookpoint to be used to call initialize() |
|
75 | + * |
|
76 | + * @return string |
|
77 | + */ |
|
78 | + public function initHook() |
|
79 | + { |
|
80 | + return 'AHEE__EE_System__initialize'; |
|
81 | + } |
|
82 | + |
|
83 | + |
|
84 | + /** |
|
85 | + * Perform any early setup required for block editors to functions |
|
86 | + * |
|
87 | + * @return void |
|
88 | + * @throws Exception |
|
89 | + */ |
|
90 | + public function initialize() |
|
91 | + { |
|
92 | + $this->initializeBlocks(); |
|
93 | + add_action('AHEE__EE_System__initialize_last', array($this, 'registerBlocks')); |
|
94 | + add_action('wp_loaded', array($this, 'unloadAssets')); |
|
95 | + } |
|
96 | + |
|
97 | + |
|
98 | + /** |
|
99 | + * @return CollectionInterface|BlockInterface[] |
|
100 | + * @throws CollectionLoaderException |
|
101 | + * @throws CollectionDetailsException |
|
102 | + */ |
|
103 | + protected function populateBlockCollection() |
|
104 | + { |
|
105 | + $loader = new CollectionLoader( |
|
106 | + new CollectionDetails( |
|
107 | + // collection name |
|
108 | + 'editor_blocks', |
|
109 | + // collection interface |
|
110 | + 'EventEspresso\core\domain\entities\editor\BlockInterface', |
|
111 | + // FQCNs for classes to add (all classes within each namespace will be loaded) |
|
112 | + apply_filters( |
|
113 | + 'FHEE__EventEspresso_core_services_editor_BlockManager__populateBlockCollection__collection_FQCNs', |
|
114 | + array( |
|
115 | + // 'EventEspresso\core\domain\entities\editor\blocks\common', |
|
116 | + // 'EventEspresso\core\domain\entities\editor\blocks\editor', |
|
117 | + // 'EventEspresso\core\domain\entities\editor\blocks\widgets', |
|
118 | + ) |
|
119 | + ), |
|
120 | + // filepaths to classes to add |
|
121 | + array(), |
|
122 | + // file mask to use if parsing folder for files to add |
|
123 | + '', |
|
124 | + // what to use as identifier for collection entities |
|
125 | + // using CLASS NAME prevents duplicates (works like a singleton) |
|
126 | + CollectionDetails::ID_CLASS_NAME |
|
127 | + ), |
|
128 | + $this->blocks |
|
129 | + ); |
|
130 | + return $loader->getCollection(); |
|
131 | + } |
|
132 | + |
|
133 | + |
|
134 | + /** |
|
135 | + * populates the BlockCollection and calls initialize() on all installed blocks |
|
136 | + * |
|
137 | + * @return void |
|
138 | + * @throws Exception |
|
139 | + */ |
|
140 | + public function initializeBlocks() |
|
141 | + { |
|
142 | + try { |
|
143 | + $this->populateBlockCollection(); |
|
144 | + // cycle thru block loaders and initialize each loader |
|
145 | + foreach ($this->blocks as $block) { |
|
146 | + $block->initialize(); |
|
147 | + $this->trackAssetManagersForBlocks($block); |
|
148 | + if (! $this->block_asset_manager_collection->has($block->assetManager())) { |
|
149 | + $this->block_asset_manager_collection->add($block->assetManager()); |
|
150 | + $block->assetManager()->setAssetHandles(); |
|
151 | + } |
|
152 | + } |
|
153 | + } catch (Exception $exception) { |
|
154 | + new ExceptionStackTraceDisplay($exception); |
|
155 | + } |
|
156 | + } |
|
157 | + |
|
158 | + |
|
159 | + /** |
|
160 | + * track blocks with routes that match the current request |
|
161 | + * |
|
162 | + * @param BlockInterface $block |
|
163 | + * @throws InvalidClassException |
|
164 | + */ |
|
165 | + private function trackAssetManagersForBlocks(BlockInterface $block) |
|
166 | + { |
|
167 | + $supported_routes = $block->supportedRoutes(); |
|
168 | + foreach ($supported_routes as $supported_route) { |
|
169 | + if ($this->route_manager->currentRequestMatches($supported_route)) { |
|
170 | + $this->block_asset_managers[ $block->blockType() ] = $block->assetManager()->assetNamespace(); |
|
171 | + } |
|
172 | + } |
|
173 | + } |
|
174 | + |
|
175 | + |
|
176 | + /** |
|
177 | + * returns true if the block should be registered for the current request |
|
178 | + * else removes block from block_routes array and returns false |
|
179 | + * |
|
180 | + * @param BlockInterface $block |
|
181 | + * @return boolean |
|
182 | + * @throws InvalidClassException |
|
183 | + */ |
|
184 | + public function matchesRoute(BlockInterface $block) |
|
185 | + { |
|
186 | + if(isset($this->block_asset_managers[ $block->blockType() ])) { |
|
187 | + return true; |
|
188 | + } |
|
189 | + unset($this->block_asset_managers[ $block->blockType() ]); |
|
190 | + return false; |
|
191 | + } |
|
192 | + |
|
193 | + |
|
194 | + /** |
|
195 | + * calls registerBlock() and load assets for all installed blocks |
|
196 | + * |
|
197 | + * @return void |
|
198 | + * @throws Exception |
|
199 | + */ |
|
200 | + public function registerBlocks() |
|
201 | + { |
|
202 | + try { |
|
203 | + // cycle thru block loader folders |
|
204 | + foreach ($this->blocks as $block) { |
|
205 | + if (! $this->matchesRoute($block)) { |
|
206 | + continue; |
|
207 | + } |
|
208 | + // perform any setup required for the block |
|
209 | + $block_type = $block->registerBlock(); |
|
210 | + if (! $block_type instanceof WP_Block_Type) { |
|
211 | + throw new InvalidEntityException($block_type, 'WP_Block_Type'); |
|
212 | + } |
|
213 | + do_action( |
|
214 | + 'FHEE__EventEspresso_core_services_editor_BlockManager__registerBlocks__block_type_registered', |
|
215 | + $block, |
|
216 | + $block_type |
|
217 | + ); |
|
218 | + } |
|
219 | + } catch (Exception $exception) { |
|
220 | + new ExceptionStackTraceDisplay($exception); |
|
221 | + } |
|
222 | + } |
|
223 | + |
|
224 | + public function unloadAssets() |
|
225 | + { |
|
226 | + $assets = array_flip($this->block_asset_managers); |
|
227 | + foreach ($this->block_asset_manager_collection as $asset_manager) { |
|
228 | + // if there are no longer any blocks that require these assets, |
|
229 | + if(! isset($assets[ $asset_manager->assetNamespace() ])) { |
|
230 | + // then unset asset enqueueing and bail |
|
231 | + remove_action('wp_enqueue_scripts', array($asset_manager, 'addManifestFile'), 0); |
|
232 | + remove_action('admin_enqueue_scripts', array($asset_manager, 'addManifestFile'), 0); |
|
233 | + remove_action('wp_enqueue_scripts', array($asset_manager, 'addAssets'), 2); |
|
234 | + remove_action('admin_enqueue_scripts', array($asset_manager, 'addAssets'), 2); |
|
235 | + |
|
236 | + } |
|
237 | + } |
|
238 | + |
|
239 | + } |
|
240 | 240 | } |
241 | 241 |
@@ -18,46 +18,46 @@ |
||
18 | 18 | abstract class BlockManager |
19 | 19 | { |
20 | 20 | |
21 | - /** |
|
22 | - * @var CollectionInterface|BlockInterface[] $blocks |
|
23 | - */ |
|
24 | - protected $blocks; |
|
25 | - |
|
26 | - /** |
|
27 | - * @var RequestInterface $request |
|
28 | - */ |
|
29 | - protected $request; |
|
30 | - |
|
31 | - |
|
32 | - |
|
33 | - /** |
|
34 | - * BlockManager constructor. |
|
35 | - * |
|
36 | - * @param BlockCollection $blocks |
|
37 | - * @param RequestInterface $request |
|
38 | - */ |
|
39 | - public function __construct( |
|
40 | - BlockCollection $blocks, |
|
41 | - RequestInterface $request |
|
42 | - ) { |
|
43 | - $this->blocks = $blocks; |
|
44 | - $this->request = $request; |
|
45 | - add_action($this->initHook(), array($this, 'initialize')); |
|
46 | - } |
|
47 | - |
|
48 | - |
|
49 | - /** |
|
50 | - * Returns the name of a hookpoint to be used to call initialize() |
|
51 | - * |
|
52 | - * @return string |
|
53 | - */ |
|
54 | - abstract public function initHook(); |
|
55 | - |
|
56 | - |
|
57 | - /** |
|
58 | - * Perform any early setup required for block editors to functions |
|
59 | - * |
|
60 | - * @return void |
|
61 | - */ |
|
62 | - abstract public function initialize(); |
|
21 | + /** |
|
22 | + * @var CollectionInterface|BlockInterface[] $blocks |
|
23 | + */ |
|
24 | + protected $blocks; |
|
25 | + |
|
26 | + /** |
|
27 | + * @var RequestInterface $request |
|
28 | + */ |
|
29 | + protected $request; |
|
30 | + |
|
31 | + |
|
32 | + |
|
33 | + /** |
|
34 | + * BlockManager constructor. |
|
35 | + * |
|
36 | + * @param BlockCollection $blocks |
|
37 | + * @param RequestInterface $request |
|
38 | + */ |
|
39 | + public function __construct( |
|
40 | + BlockCollection $blocks, |
|
41 | + RequestInterface $request |
|
42 | + ) { |
|
43 | + $this->blocks = $blocks; |
|
44 | + $this->request = $request; |
|
45 | + add_action($this->initHook(), array($this, 'initialize')); |
|
46 | + } |
|
47 | + |
|
48 | + |
|
49 | + /** |
|
50 | + * Returns the name of a hookpoint to be used to call initialize() |
|
51 | + * |
|
52 | + * @return string |
|
53 | + */ |
|
54 | + abstract public function initHook(); |
|
55 | + |
|
56 | + |
|
57 | + /** |
|
58 | + * Perform any early setup required for block editors to functions |
|
59 | + * |
|
60 | + * @return void |
|
61 | + */ |
|
62 | + abstract public function initialize(); |
|
63 | 63 | } |
@@ -16,36 +16,36 @@ |
||
16 | 16 | class RouteMatchSpecificationCollection extends Collection |
17 | 17 | { |
18 | 18 | |
19 | - const COLLECTION_NAME = 'route_match_specifications'; |
|
20 | - |
|
21 | - |
|
22 | - /** |
|
23 | - * RouteMatchSpecificationCollection constructor |
|
24 | - * |
|
25 | - * @throws InvalidInterfaceException |
|
26 | - */ |
|
27 | - public function __construct() |
|
28 | - { |
|
29 | - parent::__construct( |
|
30 | - 'EventEspresso\core\domain\entities\route_match\RouteMatchSpecificationInterface', |
|
31 | - RouteMatchSpecificationCollection::COLLECTION_NAME |
|
32 | - ); |
|
33 | - } |
|
34 | - |
|
35 | - |
|
36 | - /** |
|
37 | - * getIdentifier |
|
38 | - * Overrides EventEspresso\core\services\collections\Collection::getIdentifier() |
|
39 | - * If no $identifier is supplied, then the fully qualified class name is used |
|
40 | - * |
|
41 | - * @param $object |
|
42 | - * @param mixed $identifier |
|
43 | - * @return bool |
|
44 | - */ |
|
45 | - public function getIdentifier($object, $identifier = null) |
|
46 | - { |
|
47 | - return ! empty($identifier) |
|
48 | - ? $identifier |
|
49 | - : get_class($object); |
|
50 | - } |
|
19 | + const COLLECTION_NAME = 'route_match_specifications'; |
|
20 | + |
|
21 | + |
|
22 | + /** |
|
23 | + * RouteMatchSpecificationCollection constructor |
|
24 | + * |
|
25 | + * @throws InvalidInterfaceException |
|
26 | + */ |
|
27 | + public function __construct() |
|
28 | + { |
|
29 | + parent::__construct( |
|
30 | + 'EventEspresso\core\domain\entities\route_match\RouteMatchSpecificationInterface', |
|
31 | + RouteMatchSpecificationCollection::COLLECTION_NAME |
|
32 | + ); |
|
33 | + } |
|
34 | + |
|
35 | + |
|
36 | + /** |
|
37 | + * getIdentifier |
|
38 | + * Overrides EventEspresso\core\services\collections\Collection::getIdentifier() |
|
39 | + * If no $identifier is supplied, then the fully qualified class name is used |
|
40 | + * |
|
41 | + * @param $object |
|
42 | + * @param mixed $identifier |
|
43 | + * @return bool |
|
44 | + */ |
|
45 | + public function getIdentifier($object, $identifier = null) |
|
46 | + { |
|
47 | + return ! empty($identifier) |
|
48 | + ? $identifier |
|
49 | + : get_class($object); |
|
50 | + } |
|
51 | 51 | } |
@@ -138,7 +138,7 @@ |
||
138 | 138 | foreach ($this->specifications as $specification) { |
139 | 139 | /** @var RouteMatchSpecificationInterface $specification */ |
140 | 140 | if ($specification->routeMatches()) { |
141 | - $matches[] = get_class($specification ); |
|
141 | + $matches[] = get_class($specification); |
|
142 | 142 | } |
143 | 143 | } |
144 | 144 | return $matches; |
@@ -25,122 +25,122 @@ |
||
25 | 25 | */ |
26 | 26 | class RouteMatchSpecificationManager |
27 | 27 | { |
28 | - /** |
|
29 | - * @var CollectionInterface[]|RouteMatchSpecificationInterface[] $specifications |
|
30 | - */ |
|
31 | - private $specifications; |
|
28 | + /** |
|
29 | + * @var CollectionInterface[]|RouteMatchSpecificationInterface[] $specifications |
|
30 | + */ |
|
31 | + private $specifications; |
|
32 | 32 | |
33 | - /** |
|
34 | - * @var RouteMatchSpecificationFactory $specifications_factory |
|
35 | - */ |
|
36 | - private $specifications_factory; |
|
33 | + /** |
|
34 | + * @var RouteMatchSpecificationFactory $specifications_factory |
|
35 | + */ |
|
36 | + private $specifications_factory; |
|
37 | 37 | |
38 | 38 | |
39 | - /** |
|
40 | - * RouteMatchSpecificationManager constructor. |
|
41 | - * |
|
42 | - * @param RouteMatchSpecificationCollection $specifications |
|
43 | - * @param RouteMatchSpecificationFactory $specifications_factory |
|
44 | - */ |
|
45 | - public function __construct( |
|
46 | - RouteMatchSpecificationCollection $specifications, |
|
47 | - RouteMatchSpecificationFactory $specifications_factory |
|
48 | - ) { |
|
49 | - $this->specifications = $specifications; |
|
50 | - $this->specifications_factory = $specifications_factory; |
|
51 | - add_action('AHEE__EE_System__loadRouteMatchSpecifications', array($this, 'initialize')); |
|
52 | - } |
|
39 | + /** |
|
40 | + * RouteMatchSpecificationManager constructor. |
|
41 | + * |
|
42 | + * @param RouteMatchSpecificationCollection $specifications |
|
43 | + * @param RouteMatchSpecificationFactory $specifications_factory |
|
44 | + */ |
|
45 | + public function __construct( |
|
46 | + RouteMatchSpecificationCollection $specifications, |
|
47 | + RouteMatchSpecificationFactory $specifications_factory |
|
48 | + ) { |
|
49 | + $this->specifications = $specifications; |
|
50 | + $this->specifications_factory = $specifications_factory; |
|
51 | + add_action('AHEE__EE_System__loadRouteMatchSpecifications', array($this, 'initialize')); |
|
52 | + } |
|
53 | 53 | |
54 | 54 | |
55 | - /** |
|
56 | - * Perform any early setup required for block editors to functions |
|
57 | - * |
|
58 | - * @return void |
|
59 | - * @throws CollectionLoaderException |
|
60 | - * @throws CollectionDetailsException |
|
61 | - */ |
|
62 | - public function initialize() |
|
63 | - { |
|
64 | - $this->populateSpecificationCollection(); |
|
65 | - } |
|
55 | + /** |
|
56 | + * Perform any early setup required for block editors to functions |
|
57 | + * |
|
58 | + * @return void |
|
59 | + * @throws CollectionLoaderException |
|
60 | + * @throws CollectionDetailsException |
|
61 | + */ |
|
62 | + public function initialize() |
|
63 | + { |
|
64 | + $this->populateSpecificationCollection(); |
|
65 | + } |
|
66 | 66 | |
67 | 67 | |
68 | - /** |
|
69 | - * @return CollectionInterface|RouteMatchSpecificationInterface[] |
|
70 | - * @throws CollectionLoaderException |
|
71 | - * @throws CollectionDetailsException |
|
72 | - * @since $VID:$ |
|
73 | - */ |
|
74 | - private function populateSpecificationCollection() |
|
75 | - { |
|
76 | - $loader = new CollectionLoader( |
|
77 | - new CollectionDetails( |
|
78 | - // collection name |
|
79 | - RouteMatchSpecificationCollection::COLLECTION_NAME, |
|
80 | - // collection interface |
|
81 | - 'EventEspresso\core\domain\entities\route_match\RouteMatchSpecificationInterface', |
|
82 | - // FQCNs for classes to add (all classes within each namespace will be loaded) |
|
83 | - apply_filters( |
|
84 | - 'FHEE__EventEspresso_core_services_route_match_RouteMatchSpecificationManager__populateSpecificationCollection__collection_FQCNs', |
|
85 | - array( |
|
86 | - 'EventEspresso\core\domain\entities\route_match\specifications\admin', |
|
87 | - // 'EventEspresso\core\domain\entities\route_match\specifications\public', |
|
88 | - ) |
|
89 | - ), |
|
90 | - // filepaths to classes to add |
|
91 | - array(), |
|
92 | - // file mask to use if parsing folder for files to add |
|
93 | - '', |
|
94 | - // what to use as identifier for collection entities |
|
95 | - // using CLASS NAME prevents duplicates (works like a singleton) |
|
96 | - CollectionDetails::ID_CLASS_NAME |
|
97 | - ), |
|
98 | - $this->specifications, |
|
99 | - null, |
|
100 | - $this->specifications_factory |
|
101 | - ); |
|
102 | - return $loader->getCollection(); |
|
103 | - } |
|
68 | + /** |
|
69 | + * @return CollectionInterface|RouteMatchSpecificationInterface[] |
|
70 | + * @throws CollectionLoaderException |
|
71 | + * @throws CollectionDetailsException |
|
72 | + * @since $VID:$ |
|
73 | + */ |
|
74 | + private function populateSpecificationCollection() |
|
75 | + { |
|
76 | + $loader = new CollectionLoader( |
|
77 | + new CollectionDetails( |
|
78 | + // collection name |
|
79 | + RouteMatchSpecificationCollection::COLLECTION_NAME, |
|
80 | + // collection interface |
|
81 | + 'EventEspresso\core\domain\entities\route_match\RouteMatchSpecificationInterface', |
|
82 | + // FQCNs for classes to add (all classes within each namespace will be loaded) |
|
83 | + apply_filters( |
|
84 | + 'FHEE__EventEspresso_core_services_route_match_RouteMatchSpecificationManager__populateSpecificationCollection__collection_FQCNs', |
|
85 | + array( |
|
86 | + 'EventEspresso\core\domain\entities\route_match\specifications\admin', |
|
87 | + // 'EventEspresso\core\domain\entities\route_match\specifications\public', |
|
88 | + ) |
|
89 | + ), |
|
90 | + // filepaths to classes to add |
|
91 | + array(), |
|
92 | + // file mask to use if parsing folder for files to add |
|
93 | + '', |
|
94 | + // what to use as identifier for collection entities |
|
95 | + // using CLASS NAME prevents duplicates (works like a singleton) |
|
96 | + CollectionDetails::ID_CLASS_NAME |
|
97 | + ), |
|
98 | + $this->specifications, |
|
99 | + null, |
|
100 | + $this->specifications_factory |
|
101 | + ); |
|
102 | + return $loader->getCollection(); |
|
103 | + } |
|
104 | 104 | |
105 | 105 | |
106 | - /** |
|
107 | - * Given the FQCN for a RouteMatchSpecification, will return true if the current request matches |
|
108 | - * |
|
109 | - * @param string $routeMatchSpecificationFqcn fully qualified class name |
|
110 | - * @return bool |
|
111 | - * @throws InvalidClassException |
|
112 | - * @since $VID:$ |
|
113 | - */ |
|
114 | - public function currentRequestMatches($routeMatchSpecificationFqcn) |
|
115 | - { |
|
116 | - /** @var RouteMatchSpecificationInterface $specification */ |
|
117 | - $specification = $this->specifications->get($routeMatchSpecificationFqcn); |
|
118 | - if ( ! $specification instanceof $routeMatchSpecificationFqcn) { |
|
119 | - throw new InvalidClassException($routeMatchSpecificationFqcn); |
|
120 | - } |
|
121 | - return $specification->routeMatches(); |
|
122 | - } |
|
106 | + /** |
|
107 | + * Given the FQCN for a RouteMatchSpecification, will return true if the current request matches |
|
108 | + * |
|
109 | + * @param string $routeMatchSpecificationFqcn fully qualified class name |
|
110 | + * @return bool |
|
111 | + * @throws InvalidClassException |
|
112 | + * @since $VID:$ |
|
113 | + */ |
|
114 | + public function currentRequestMatches($routeMatchSpecificationFqcn) |
|
115 | + { |
|
116 | + /** @var RouteMatchSpecificationInterface $specification */ |
|
117 | + $specification = $this->specifications->get($routeMatchSpecificationFqcn); |
|
118 | + if ( ! $specification instanceof $routeMatchSpecificationFqcn) { |
|
119 | + throw new InvalidClassException($routeMatchSpecificationFqcn); |
|
120 | + } |
|
121 | + return $specification->routeMatches(); |
|
122 | + } |
|
123 | 123 | |
124 | 124 | |
125 | - /** |
|
126 | - * Handy method for development that returns |
|
127 | - * a list of existing RouteMatchSpecification classes |
|
128 | - * matching the current request that can be used to identify it. |
|
129 | - * If no matches are returned (or nothing acceptable) |
|
130 | - * then create a new one that better matches your requirements. |
|
131 | - * |
|
132 | - * @return array |
|
133 | - * @since $VID:$ |
|
134 | - */ |
|
135 | - public function findSpecificationsMatchingCurrentRequest() |
|
136 | - { |
|
137 | - $matches = array(); |
|
138 | - foreach ($this->specifications as $specification) { |
|
139 | - /** @var RouteMatchSpecificationInterface $specification */ |
|
140 | - if ($specification->routeMatches()) { |
|
141 | - $matches[] = get_class($specification ); |
|
142 | - } |
|
143 | - } |
|
144 | - return $matches; |
|
145 | - } |
|
125 | + /** |
|
126 | + * Handy method for development that returns |
|
127 | + * a list of existing RouteMatchSpecification classes |
|
128 | + * matching the current request that can be used to identify it. |
|
129 | + * If no matches are returned (or nothing acceptable) |
|
130 | + * then create a new one that better matches your requirements. |
|
131 | + * |
|
132 | + * @return array |
|
133 | + * @since $VID:$ |
|
134 | + */ |
|
135 | + public function findSpecificationsMatchingCurrentRequest() |
|
136 | + { |
|
137 | + $matches = array(); |
|
138 | + foreach ($this->specifications as $specification) { |
|
139 | + /** @var RouteMatchSpecificationInterface $specification */ |
|
140 | + if ($specification->routeMatches()) { |
|
141 | + $matches[] = get_class($specification ); |
|
142 | + } |
|
143 | + } |
|
144 | + return $matches; |
|
145 | + } |
|
146 | 146 | } |
@@ -24,59 +24,59 @@ |
||
24 | 24 | class RouteMatchSpecificationFactory implements FactoryInterface |
25 | 25 | { |
26 | 26 | |
27 | - /** |
|
28 | - * @var RouteMatchSpecificationDependencyResolver $dependency_resolver |
|
29 | - */ |
|
30 | - private $dependency_resolver; |
|
27 | + /** |
|
28 | + * @var RouteMatchSpecificationDependencyResolver $dependency_resolver |
|
29 | + */ |
|
30 | + private $dependency_resolver; |
|
31 | 31 | |
32 | - /** |
|
33 | - * @var LoaderInterface $loader |
|
34 | - */ |
|
35 | - private $loader; |
|
32 | + /** |
|
33 | + * @var LoaderInterface $loader |
|
34 | + */ |
|
35 | + private $loader; |
|
36 | 36 | |
37 | 37 | |
38 | - /** |
|
39 | - * RouteMatchSpecificationFactory constructor |
|
40 | - * |
|
41 | - * @param RouteMatchSpecificationDependencyResolver $dependency_resolver |
|
42 | - * @param LoaderInterface $loader |
|
43 | - */ |
|
44 | - public function __construct(RouteMatchSpecificationDependencyResolver $dependency_resolver, LoaderInterface $loader) |
|
45 | - { |
|
46 | - $this->dependency_resolver = $dependency_resolver; |
|
47 | - $this->loader = $loader; |
|
48 | - } |
|
38 | + /** |
|
39 | + * RouteMatchSpecificationFactory constructor |
|
40 | + * |
|
41 | + * @param RouteMatchSpecificationDependencyResolver $dependency_resolver |
|
42 | + * @param LoaderInterface $loader |
|
43 | + */ |
|
44 | + public function __construct(RouteMatchSpecificationDependencyResolver $dependency_resolver, LoaderInterface $loader) |
|
45 | + { |
|
46 | + $this->dependency_resolver = $dependency_resolver; |
|
47 | + $this->loader = $loader; |
|
48 | + } |
|
49 | 49 | |
50 | 50 | |
51 | - /** |
|
52 | - * @param $fqcn |
|
53 | - * @return RouteMatchSpecification |
|
54 | - * @throws InvalidDataTypeException |
|
55 | - * @throws ReflectionException |
|
56 | - * @since $VID:$ |
|
57 | - */ |
|
58 | - public function createNewRouteMatchSpecification($fqcn) |
|
59 | - { |
|
60 | - $this->dependency_resolver->resolveDependenciesForSpecification($fqcn); |
|
61 | - return $this->loader->getShared($fqcn); |
|
62 | - } |
|
51 | + /** |
|
52 | + * @param $fqcn |
|
53 | + * @return RouteMatchSpecification |
|
54 | + * @throws InvalidDataTypeException |
|
55 | + * @throws ReflectionException |
|
56 | + * @since $VID:$ |
|
57 | + */ |
|
58 | + public function createNewRouteMatchSpecification($fqcn) |
|
59 | + { |
|
60 | + $this->dependency_resolver->resolveDependenciesForSpecification($fqcn); |
|
61 | + return $this->loader->getShared($fqcn); |
|
62 | + } |
|
63 | 63 | |
64 | 64 | |
65 | - /** |
|
66 | - * @param $fqcn |
|
67 | - * @return RouteMatchSpecification |
|
68 | - * @throws InvalidDataTypeException |
|
69 | - * @throws InvalidInterfaceException |
|
70 | - * @throws InvalidArgumentException |
|
71 | - * @throws ReflectionException |
|
72 | - * @since $VID:$ |
|
73 | - */ |
|
74 | - public static function create($fqcn) |
|
75 | - { |
|
76 | - /** @var RouteMatchSpecificationFactory $specification_factory */ |
|
77 | - $specification_factory = LoaderFactory::getLoader()->getShared( |
|
78 | - 'EventEspresso\core\services\route_match\RouteMatchSpecificationFactory' |
|
79 | - ); |
|
80 | - return $specification_factory->createNewRouteMatchSpecification($fqcn); |
|
81 | - } |
|
65 | + /** |
|
66 | + * @param $fqcn |
|
67 | + * @return RouteMatchSpecification |
|
68 | + * @throws InvalidDataTypeException |
|
69 | + * @throws InvalidInterfaceException |
|
70 | + * @throws InvalidArgumentException |
|
71 | + * @throws ReflectionException |
|
72 | + * @since $VID:$ |
|
73 | + */ |
|
74 | + public static function create($fqcn) |
|
75 | + { |
|
76 | + /** @var RouteMatchSpecificationFactory $specification_factory */ |
|
77 | + $specification_factory = LoaderFactory::getLoader()->getShared( |
|
78 | + 'EventEspresso\core\services\route_match\RouteMatchSpecificationFactory' |
|
79 | + ); |
|
80 | + return $specification_factory->createNewRouteMatchSpecification($fqcn); |
|
81 | + } |
|
82 | 82 | } |
@@ -25,62 +25,62 @@ |
||
25 | 25 | class RouteMatchSpecificationDependencyResolver |
26 | 26 | { |
27 | 27 | |
28 | - /** |
|
29 | - * @var Mirror $mirror |
|
30 | - */ |
|
31 | - private $mirror; |
|
28 | + /** |
|
29 | + * @var Mirror $mirror |
|
30 | + */ |
|
31 | + private $mirror; |
|
32 | 32 | |
33 | - /** |
|
34 | - * @var ClassInterfaceCache $class_cache |
|
35 | - */ |
|
36 | - private $class_cache; |
|
33 | + /** |
|
34 | + * @var ClassInterfaceCache $class_cache |
|
35 | + */ |
|
36 | + private $class_cache; |
|
37 | 37 | |
38 | - /** |
|
39 | - * @var EE_Dependency_Map $dependency_map |
|
40 | - */ |
|
41 | - private $dependency_map; |
|
38 | + /** |
|
39 | + * @var EE_Dependency_Map $dependency_map |
|
40 | + */ |
|
41 | + private $dependency_map; |
|
42 | 42 | |
43 | 43 | |
44 | - /** |
|
45 | - * RouteMatchSpecificationDependencyResolver constructor. |
|
46 | - * |
|
47 | - * @param Mirror $mirror |
|
48 | - * @param ClassInterfaceCache $class_cache |
|
49 | - * @param EE_Dependency_Map $dependency_map |
|
50 | - */ |
|
51 | - public function __construct( |
|
52 | - Mirror $mirror, |
|
53 | - ClassInterfaceCache $class_cache, |
|
54 | - EE_Dependency_Map $dependency_map |
|
55 | - ) { |
|
56 | - $this->mirror = $mirror; |
|
57 | - $this->class_cache = $class_cache; |
|
58 | - $this->dependency_map = $dependency_map; |
|
59 | - } |
|
44 | + /** |
|
45 | + * RouteMatchSpecificationDependencyResolver constructor. |
|
46 | + * |
|
47 | + * @param Mirror $mirror |
|
48 | + * @param ClassInterfaceCache $class_cache |
|
49 | + * @param EE_Dependency_Map $dependency_map |
|
50 | + */ |
|
51 | + public function __construct( |
|
52 | + Mirror $mirror, |
|
53 | + ClassInterfaceCache $class_cache, |
|
54 | + EE_Dependency_Map $dependency_map |
|
55 | + ) { |
|
56 | + $this->mirror = $mirror; |
|
57 | + $this->class_cache = $class_cache; |
|
58 | + $this->dependency_map = $dependency_map; |
|
59 | + } |
|
60 | 60 | |
61 | 61 | |
62 | - /** |
|
63 | - * @param string $FQCN Fully Qualified Class Name |
|
64 | - * @throws InvalidDataTypeException |
|
65 | - * @throws ReflectionException |
|
66 | - * @since $VID:$ |
|
67 | - */ |
|
68 | - public function resolveDependenciesForSpecification($FQCN) |
|
69 | - { |
|
70 | - $dependencies = array(); |
|
71 | - $params = $this->mirror->getParameters($FQCN); |
|
72 | - foreach ($params as $index => $param) { |
|
73 | - // is this a dependency for a specific class ? |
|
74 | - $param_class = $this->mirror->getParameterClassName($param, $FQCN, $index); |
|
75 | - if (strpos($param_class, 'EventEspresso\core\domain\entities\route_match\specifications') !== false) { |
|
76 | - $this->resolveDependenciesForSpecification($param_class); |
|
77 | - } |
|
78 | - $param_class = $param_class === 'EventEspresso\core\services\request\RequestInterface' |
|
79 | - ? $this->class_cache->getFqnForAlias($param_class) |
|
80 | - : $param_class; |
|
62 | + /** |
|
63 | + * @param string $FQCN Fully Qualified Class Name |
|
64 | + * @throws InvalidDataTypeException |
|
65 | + * @throws ReflectionException |
|
66 | + * @since $VID:$ |
|
67 | + */ |
|
68 | + public function resolveDependenciesForSpecification($FQCN) |
|
69 | + { |
|
70 | + $dependencies = array(); |
|
71 | + $params = $this->mirror->getParameters($FQCN); |
|
72 | + foreach ($params as $index => $param) { |
|
73 | + // is this a dependency for a specific class ? |
|
74 | + $param_class = $this->mirror->getParameterClassName($param, $FQCN, $index); |
|
75 | + if (strpos($param_class, 'EventEspresso\core\domain\entities\route_match\specifications') !== false) { |
|
76 | + $this->resolveDependenciesForSpecification($param_class); |
|
77 | + } |
|
78 | + $param_class = $param_class === 'EventEspresso\core\services\request\RequestInterface' |
|
79 | + ? $this->class_cache->getFqnForAlias($param_class) |
|
80 | + : $param_class; |
|
81 | 81 | |
82 | - $dependencies[ $param_class ] = EE_Dependency_Map::load_from_cache; |
|
83 | - } |
|
84 | - $this->dependency_map->registerDependencies($FQCN, $dependencies); |
|
85 | - } |
|
82 | + $dependencies[ $param_class ] = EE_Dependency_Map::load_from_cache; |
|
83 | + } |
|
84 | + $this->dependency_map->registerDependencies($FQCN, $dependencies); |
|
85 | + } |
|
86 | 86 | } |
@@ -79,7 +79,7 @@ |
||
79 | 79 | ? $this->class_cache->getFqnForAlias($param_class) |
80 | 80 | : $param_class; |
81 | 81 | |
82 | - $dependencies[ $param_class ] = EE_Dependency_Map::load_from_cache; |
|
82 | + $dependencies[$param_class] = EE_Dependency_Map::load_from_cache; |
|
83 | 83 | } |
84 | 84 | $this->dependency_map->registerDependencies($FQCN, $dependencies); |
85 | 85 | } |
@@ -16,161 +16,161 @@ |
||
16 | 16 | class ClassInterfaceCache |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * array of interfaces indexed by FQCNs where values are arrays of interface FQNs |
|
21 | - * |
|
22 | - * @var string[][] $interfaces |
|
23 | - */ |
|
24 | - private $interfaces = array(); |
|
25 | - |
|
26 | - /** |
|
27 | - * @type string[][] $aliases |
|
28 | - */ |
|
29 | - protected $aliases = array(); |
|
30 | - |
|
31 | - |
|
32 | - /** |
|
33 | - * @param string $fqn |
|
34 | - * @return string |
|
35 | - */ |
|
36 | - public function getFqn($fqn) |
|
37 | - { |
|
38 | - $fqn = $fqn instanceof FullyQualifiedName ? $fqn->string() : $fqn; |
|
39 | - return ltrim($fqn, '\\'); |
|
40 | - } |
|
41 | - |
|
42 | - |
|
43 | - /** |
|
44 | - * @param string $fqn |
|
45 | - * @return array |
|
46 | - */ |
|
47 | - public function getInterfaces($fqn) |
|
48 | - { |
|
49 | - $fqn = $this->getFqn($fqn); |
|
50 | - // have we already seen this FQCN ? |
|
51 | - if (! array_key_exists($fqn, $this->interfaces)) { |
|
52 | - $this->interfaces[ $fqn ] = array(); |
|
53 | - if (class_exists($fqn)) { |
|
54 | - $this->interfaces[ $fqn ] = class_implements($fqn, false); |
|
55 | - $this->interfaces[ $fqn ] = $this->interfaces[ $fqn ] !== false |
|
56 | - ? $this->interfaces[ $fqn ] |
|
57 | - : array(); |
|
58 | - } |
|
59 | - } |
|
60 | - return $this->interfaces[ $fqn ]; |
|
61 | - } |
|
62 | - |
|
63 | - |
|
64 | - /** |
|
65 | - * @param string $fqn |
|
66 | - * @param string $interface |
|
67 | - * @return bool |
|
68 | - */ |
|
69 | - public function hasInterface($fqn, $interface) |
|
70 | - { |
|
71 | - $fqn = $this->getFqn($fqn); |
|
72 | - $interfaces = $this->getInterfaces($fqn); |
|
73 | - return in_array($interface, $interfaces, true); |
|
74 | - } |
|
75 | - |
|
76 | - |
|
77 | - /** |
|
78 | - * adds an alias for a classname |
|
79 | - * |
|
80 | - * @param string $fqn the class name that should be used (concrete class to replace interface) |
|
81 | - * @param string $alias the class name that would be type hinted for (abstract parent or interface) |
|
82 | - * @param string $for_class the class that has the dependency (is type hinting for the interface) |
|
83 | - */ |
|
84 | - public function addAlias($fqn, $alias, $for_class = '') |
|
85 | - { |
|
86 | - $fqn = $this->getFqn($fqn); |
|
87 | - $alias = $this->getFqn($alias); |
|
88 | - // are we adding an alias for a specific class? |
|
89 | - if ($for_class !== '') { |
|
90 | - // make sure it's set up as an array |
|
91 | - if (! isset($this->aliases[ $for_class ])) { |
|
92 | - $this->aliases[ $for_class ] = array(); |
|
93 | - } |
|
94 | - $this->aliases[ $for_class ][ $alias ] = $fqn; |
|
95 | - return; |
|
96 | - } |
|
97 | - $this->aliases[ $alias ] = $fqn; |
|
98 | - } |
|
99 | - |
|
100 | - |
|
101 | - /** |
|
102 | - * returns TRUE if the provided FQN is an alias |
|
103 | - * |
|
104 | - * @param string $fqn |
|
105 | - * @param string $for_class |
|
106 | - * @return bool |
|
107 | - */ |
|
108 | - public function isAlias($fqn = '', $for_class = '') |
|
109 | - { |
|
110 | - $fqn = $this->getFqn($fqn); |
|
111 | - if ($this->isAliasForClass($fqn, $for_class)) { |
|
112 | - return true; |
|
113 | - } |
|
114 | - if ($for_class === '' && $this->isDirectAlias($fqn)) { |
|
115 | - return true; |
|
116 | - } |
|
117 | - return false; |
|
118 | - } |
|
119 | - |
|
120 | - |
|
121 | - /** |
|
122 | - * returns TRUE if the provided FQN is an alias |
|
123 | - * |
|
124 | - * @param string $fqn |
|
125 | - * @return bool |
|
126 | - */ |
|
127 | - protected function isDirectAlias($fqn = '') |
|
128 | - { |
|
129 | - return isset($this->aliases[ (string) $fqn ]) && ! is_array($this->aliases[ (string) $fqn ]); |
|
130 | - } |
|
131 | - |
|
132 | - |
|
133 | - /** |
|
134 | - * returns TRUE if the provided FQN is an alias for the specified class |
|
135 | - * |
|
136 | - * @param string $fqn |
|
137 | - * @param string $for_class |
|
138 | - * @return bool |
|
139 | - */ |
|
140 | - protected function isAliasForClass($fqn = '', $for_class = '') |
|
141 | - { |
|
142 | - return ( |
|
143 | - $for_class !== '' |
|
144 | - && isset($this->aliases[ (string) $for_class ][ (string) $fqn ]) |
|
145 | - ); |
|
146 | - } |
|
147 | - |
|
148 | - |
|
149 | - /** |
|
150 | - * returns FQN for provided alias if one exists, otherwise returns the original FQN |
|
151 | - * functions recursively, so that multiple aliases can be used to drill down to a FQN |
|
152 | - * for example: |
|
153 | - * if the following two entries were added to the aliases array: |
|
154 | - * array( |
|
155 | - * 'interface_alias' => 'some\namespace\interface' |
|
156 | - * 'some\namespace\interface' => 'some\namespace\classname' |
|
157 | - * ) |
|
158 | - * then one could use Loader::getNew( 'interface_alias' ) |
|
159 | - * to load an instance of 'some\namespace\classname' |
|
160 | - * |
|
161 | - * @param string $alias |
|
162 | - * @param string $for_class |
|
163 | - * @return string |
|
164 | - */ |
|
165 | - public function getFqnForAlias($alias = '', $for_class = '') |
|
166 | - { |
|
167 | - $alias = $this->getFqn($alias); |
|
168 | - if ($this->isAliasForClass($alias, $for_class)) { |
|
169 | - return $this->getFqnForAlias($this->aliases[ (string) $for_class ][ (string) $alias ], $for_class); |
|
170 | - } |
|
171 | - if ($this->isDirectAlias($alias)) { |
|
172 | - return $this->getFqnForAlias($this->aliases[ (string) $alias ], ''); |
|
173 | - } |
|
174 | - return $alias; |
|
175 | - } |
|
19 | + /** |
|
20 | + * array of interfaces indexed by FQCNs where values are arrays of interface FQNs |
|
21 | + * |
|
22 | + * @var string[][] $interfaces |
|
23 | + */ |
|
24 | + private $interfaces = array(); |
|
25 | + |
|
26 | + /** |
|
27 | + * @type string[][] $aliases |
|
28 | + */ |
|
29 | + protected $aliases = array(); |
|
30 | + |
|
31 | + |
|
32 | + /** |
|
33 | + * @param string $fqn |
|
34 | + * @return string |
|
35 | + */ |
|
36 | + public function getFqn($fqn) |
|
37 | + { |
|
38 | + $fqn = $fqn instanceof FullyQualifiedName ? $fqn->string() : $fqn; |
|
39 | + return ltrim($fqn, '\\'); |
|
40 | + } |
|
41 | + |
|
42 | + |
|
43 | + /** |
|
44 | + * @param string $fqn |
|
45 | + * @return array |
|
46 | + */ |
|
47 | + public function getInterfaces($fqn) |
|
48 | + { |
|
49 | + $fqn = $this->getFqn($fqn); |
|
50 | + // have we already seen this FQCN ? |
|
51 | + if (! array_key_exists($fqn, $this->interfaces)) { |
|
52 | + $this->interfaces[ $fqn ] = array(); |
|
53 | + if (class_exists($fqn)) { |
|
54 | + $this->interfaces[ $fqn ] = class_implements($fqn, false); |
|
55 | + $this->interfaces[ $fqn ] = $this->interfaces[ $fqn ] !== false |
|
56 | + ? $this->interfaces[ $fqn ] |
|
57 | + : array(); |
|
58 | + } |
|
59 | + } |
|
60 | + return $this->interfaces[ $fqn ]; |
|
61 | + } |
|
62 | + |
|
63 | + |
|
64 | + /** |
|
65 | + * @param string $fqn |
|
66 | + * @param string $interface |
|
67 | + * @return bool |
|
68 | + */ |
|
69 | + public function hasInterface($fqn, $interface) |
|
70 | + { |
|
71 | + $fqn = $this->getFqn($fqn); |
|
72 | + $interfaces = $this->getInterfaces($fqn); |
|
73 | + return in_array($interface, $interfaces, true); |
|
74 | + } |
|
75 | + |
|
76 | + |
|
77 | + /** |
|
78 | + * adds an alias for a classname |
|
79 | + * |
|
80 | + * @param string $fqn the class name that should be used (concrete class to replace interface) |
|
81 | + * @param string $alias the class name that would be type hinted for (abstract parent or interface) |
|
82 | + * @param string $for_class the class that has the dependency (is type hinting for the interface) |
|
83 | + */ |
|
84 | + public function addAlias($fqn, $alias, $for_class = '') |
|
85 | + { |
|
86 | + $fqn = $this->getFqn($fqn); |
|
87 | + $alias = $this->getFqn($alias); |
|
88 | + // are we adding an alias for a specific class? |
|
89 | + if ($for_class !== '') { |
|
90 | + // make sure it's set up as an array |
|
91 | + if (! isset($this->aliases[ $for_class ])) { |
|
92 | + $this->aliases[ $for_class ] = array(); |
|
93 | + } |
|
94 | + $this->aliases[ $for_class ][ $alias ] = $fqn; |
|
95 | + return; |
|
96 | + } |
|
97 | + $this->aliases[ $alias ] = $fqn; |
|
98 | + } |
|
99 | + |
|
100 | + |
|
101 | + /** |
|
102 | + * returns TRUE if the provided FQN is an alias |
|
103 | + * |
|
104 | + * @param string $fqn |
|
105 | + * @param string $for_class |
|
106 | + * @return bool |
|
107 | + */ |
|
108 | + public function isAlias($fqn = '', $for_class = '') |
|
109 | + { |
|
110 | + $fqn = $this->getFqn($fqn); |
|
111 | + if ($this->isAliasForClass($fqn, $for_class)) { |
|
112 | + return true; |
|
113 | + } |
|
114 | + if ($for_class === '' && $this->isDirectAlias($fqn)) { |
|
115 | + return true; |
|
116 | + } |
|
117 | + return false; |
|
118 | + } |
|
119 | + |
|
120 | + |
|
121 | + /** |
|
122 | + * returns TRUE if the provided FQN is an alias |
|
123 | + * |
|
124 | + * @param string $fqn |
|
125 | + * @return bool |
|
126 | + */ |
|
127 | + protected function isDirectAlias($fqn = '') |
|
128 | + { |
|
129 | + return isset($this->aliases[ (string) $fqn ]) && ! is_array($this->aliases[ (string) $fqn ]); |
|
130 | + } |
|
131 | + |
|
132 | + |
|
133 | + /** |
|
134 | + * returns TRUE if the provided FQN is an alias for the specified class |
|
135 | + * |
|
136 | + * @param string $fqn |
|
137 | + * @param string $for_class |
|
138 | + * @return bool |
|
139 | + */ |
|
140 | + protected function isAliasForClass($fqn = '', $for_class = '') |
|
141 | + { |
|
142 | + return ( |
|
143 | + $for_class !== '' |
|
144 | + && isset($this->aliases[ (string) $for_class ][ (string) $fqn ]) |
|
145 | + ); |
|
146 | + } |
|
147 | + |
|
148 | + |
|
149 | + /** |
|
150 | + * returns FQN for provided alias if one exists, otherwise returns the original FQN |
|
151 | + * functions recursively, so that multiple aliases can be used to drill down to a FQN |
|
152 | + * for example: |
|
153 | + * if the following two entries were added to the aliases array: |
|
154 | + * array( |
|
155 | + * 'interface_alias' => 'some\namespace\interface' |
|
156 | + * 'some\namespace\interface' => 'some\namespace\classname' |
|
157 | + * ) |
|
158 | + * then one could use Loader::getNew( 'interface_alias' ) |
|
159 | + * to load an instance of 'some\namespace\classname' |
|
160 | + * |
|
161 | + * @param string $alias |
|
162 | + * @param string $for_class |
|
163 | + * @return string |
|
164 | + */ |
|
165 | + public function getFqnForAlias($alias = '', $for_class = '') |
|
166 | + { |
|
167 | + $alias = $this->getFqn($alias); |
|
168 | + if ($this->isAliasForClass($alias, $for_class)) { |
|
169 | + return $this->getFqnForAlias($this->aliases[ (string) $for_class ][ (string) $alias ], $for_class); |
|
170 | + } |
|
171 | + if ($this->isDirectAlias($alias)) { |
|
172 | + return $this->getFqnForAlias($this->aliases[ (string) $alias ], ''); |
|
173 | + } |
|
174 | + return $alias; |
|
175 | + } |
|
176 | 176 | } |
@@ -21,152 +21,152 @@ |
||
21 | 21 | abstract class AssetManager implements AssetManagerInterface |
22 | 22 | { |
23 | 23 | |
24 | - /** |
|
25 | - * @var AssetCollection $assets |
|
26 | - */ |
|
27 | - protected $assets; |
|
28 | - |
|
29 | - /** |
|
30 | - * @var DomainInterface |
|
31 | - */ |
|
32 | - protected $domain; |
|
33 | - |
|
34 | - /** |
|
35 | - * @var Registry $registry |
|
36 | - */ |
|
37 | - protected $registry; |
|
38 | - |
|
39 | - |
|
40 | - /** |
|
41 | - * AssetRegister constructor. |
|
42 | - * |
|
43 | - * @param DomainInterface $domain |
|
44 | - * @param AssetCollection $assets |
|
45 | - * @param Registry $registry |
|
46 | - */ |
|
47 | - public function __construct(DomainInterface $domain, AssetCollection $assets, Registry $registry) |
|
48 | - { |
|
49 | - $this->domain = $domain; |
|
50 | - $this->assets = $assets; |
|
51 | - $this->registry = $registry; |
|
52 | - add_action('wp_enqueue_scripts', array($this, 'addManifestFile'), 0); |
|
53 | - add_action('admin_enqueue_scripts', array($this, 'addManifestFile'), 0); |
|
54 | - add_action('wp_enqueue_scripts', array($this, 'addAssets'), 2); |
|
55 | - add_action('admin_enqueue_scripts', array($this, 'addAssets'), 2); |
|
56 | - } |
|
57 | - |
|
58 | - |
|
59 | - /** |
|
60 | - * @since $VID:$ |
|
61 | - * @return string |
|
62 | - */ |
|
63 | - public function assetNamespace() |
|
64 | - { |
|
65 | - return $this->domain->assetNamespace(); |
|
66 | - } |
|
67 | - |
|
68 | - |
|
69 | - /** |
|
70 | - * @return void |
|
71 | - * @throws DuplicateCollectionIdentifierException |
|
72 | - * @throws InvalidDataTypeException |
|
73 | - * @throws InvalidEntityException |
|
74 | - * @since 4.9.62.p |
|
75 | - */ |
|
76 | - public function addManifestFile() |
|
77 | - { |
|
78 | - // if a manifest file has already been added for this domain, then just return |
|
79 | - if ($this->assets->has($this->domain->assetNamespace())) { |
|
80 | - return; |
|
81 | - } |
|
82 | - $asset = new ManifestFile($this->domain); |
|
83 | - $this->assets->add($asset, $this->domain->assetNamespace()); |
|
84 | - } |
|
85 | - |
|
86 | - |
|
87 | - /** |
|
88 | - * @return ManifestFile[] |
|
89 | - * @since 4.9.62.p |
|
90 | - */ |
|
91 | - public function getManifestFile() |
|
92 | - { |
|
93 | - return $this->assets->getManifestFiles(); |
|
94 | - } |
|
95 | - |
|
96 | - |
|
97 | - /** |
|
98 | - * @param string $handle |
|
99 | - * @param string $source |
|
100 | - * @param array $dependencies |
|
101 | - * @param bool $load_in_footer |
|
102 | - * @return JavascriptAsset |
|
103 | - * @throws DuplicateCollectionIdentifierException |
|
104 | - * @throws InvalidDataTypeException |
|
105 | - * @throws InvalidEntityException |
|
106 | - * @since 4.9.62.p |
|
107 | - */ |
|
108 | - public function addJavascript( |
|
109 | - $handle, |
|
110 | - $source, |
|
111 | - array $dependencies = array(), |
|
112 | - $load_in_footer = true |
|
113 | - ) { |
|
114 | - $asset = new JavascriptAsset( |
|
115 | - $handle, |
|
116 | - $source, |
|
117 | - $dependencies, |
|
118 | - $load_in_footer, |
|
119 | - $this->domain |
|
120 | - ); |
|
121 | - $this->assets->add($asset, $handle); |
|
122 | - return $asset; |
|
123 | - } |
|
124 | - |
|
125 | - |
|
126 | - |
|
127 | - /** |
|
128 | - * @param string $handle |
|
129 | - * @param string $source |
|
130 | - * @param array $dependencies |
|
131 | - * @param string $media |
|
132 | - * @return StylesheetAsset |
|
133 | - * @throws DuplicateCollectionIdentifierException |
|
134 | - * @throws InvalidDataTypeException |
|
135 | - * @throws InvalidEntityException |
|
136 | - * @since 4.9.62.p |
|
137 | - */ |
|
138 | - public function addStylesheet( |
|
139 | - $handle, |
|
140 | - $source, |
|
141 | - array $dependencies = array(), |
|
142 | - $media = 'all' |
|
143 | - ) { |
|
144 | - $asset = new StylesheetAsset( |
|
145 | - $handle, |
|
146 | - $source, |
|
147 | - $dependencies, |
|
148 | - $this->domain, |
|
149 | - $media |
|
150 | - ); |
|
151 | - $this->assets->add($asset, $handle); |
|
152 | - return $asset; |
|
153 | - } |
|
154 | - |
|
155 | - |
|
156 | - /** |
|
157 | - * @param string $handle |
|
158 | - * @return bool |
|
159 | - * @since 4.9.62.p |
|
160 | - */ |
|
161 | - public function enqueueAsset($handle) |
|
162 | - { |
|
163 | - if ($this->assets->has($handle)) { |
|
164 | - $asset = $this->assets->get($handle); |
|
165 | - if ($asset->isRegistered()) { |
|
166 | - $asset->enqueueAsset(); |
|
167 | - return true; |
|
168 | - } |
|
169 | - } |
|
170 | - return false; |
|
171 | - } |
|
24 | + /** |
|
25 | + * @var AssetCollection $assets |
|
26 | + */ |
|
27 | + protected $assets; |
|
28 | + |
|
29 | + /** |
|
30 | + * @var DomainInterface |
|
31 | + */ |
|
32 | + protected $domain; |
|
33 | + |
|
34 | + /** |
|
35 | + * @var Registry $registry |
|
36 | + */ |
|
37 | + protected $registry; |
|
38 | + |
|
39 | + |
|
40 | + /** |
|
41 | + * AssetRegister constructor. |
|
42 | + * |
|
43 | + * @param DomainInterface $domain |
|
44 | + * @param AssetCollection $assets |
|
45 | + * @param Registry $registry |
|
46 | + */ |
|
47 | + public function __construct(DomainInterface $domain, AssetCollection $assets, Registry $registry) |
|
48 | + { |
|
49 | + $this->domain = $domain; |
|
50 | + $this->assets = $assets; |
|
51 | + $this->registry = $registry; |
|
52 | + add_action('wp_enqueue_scripts', array($this, 'addManifestFile'), 0); |
|
53 | + add_action('admin_enqueue_scripts', array($this, 'addManifestFile'), 0); |
|
54 | + add_action('wp_enqueue_scripts', array($this, 'addAssets'), 2); |
|
55 | + add_action('admin_enqueue_scripts', array($this, 'addAssets'), 2); |
|
56 | + } |
|
57 | + |
|
58 | + |
|
59 | + /** |
|
60 | + * @since $VID:$ |
|
61 | + * @return string |
|
62 | + */ |
|
63 | + public function assetNamespace() |
|
64 | + { |
|
65 | + return $this->domain->assetNamespace(); |
|
66 | + } |
|
67 | + |
|
68 | + |
|
69 | + /** |
|
70 | + * @return void |
|
71 | + * @throws DuplicateCollectionIdentifierException |
|
72 | + * @throws InvalidDataTypeException |
|
73 | + * @throws InvalidEntityException |
|
74 | + * @since 4.9.62.p |
|
75 | + */ |
|
76 | + public function addManifestFile() |
|
77 | + { |
|
78 | + // if a manifest file has already been added for this domain, then just return |
|
79 | + if ($this->assets->has($this->domain->assetNamespace())) { |
|
80 | + return; |
|
81 | + } |
|
82 | + $asset = new ManifestFile($this->domain); |
|
83 | + $this->assets->add($asset, $this->domain->assetNamespace()); |
|
84 | + } |
|
85 | + |
|
86 | + |
|
87 | + /** |
|
88 | + * @return ManifestFile[] |
|
89 | + * @since 4.9.62.p |
|
90 | + */ |
|
91 | + public function getManifestFile() |
|
92 | + { |
|
93 | + return $this->assets->getManifestFiles(); |
|
94 | + } |
|
95 | + |
|
96 | + |
|
97 | + /** |
|
98 | + * @param string $handle |
|
99 | + * @param string $source |
|
100 | + * @param array $dependencies |
|
101 | + * @param bool $load_in_footer |
|
102 | + * @return JavascriptAsset |
|
103 | + * @throws DuplicateCollectionIdentifierException |
|
104 | + * @throws InvalidDataTypeException |
|
105 | + * @throws InvalidEntityException |
|
106 | + * @since 4.9.62.p |
|
107 | + */ |
|
108 | + public function addJavascript( |
|
109 | + $handle, |
|
110 | + $source, |
|
111 | + array $dependencies = array(), |
|
112 | + $load_in_footer = true |
|
113 | + ) { |
|
114 | + $asset = new JavascriptAsset( |
|
115 | + $handle, |
|
116 | + $source, |
|
117 | + $dependencies, |
|
118 | + $load_in_footer, |
|
119 | + $this->domain |
|
120 | + ); |
|
121 | + $this->assets->add($asset, $handle); |
|
122 | + return $asset; |
|
123 | + } |
|
124 | + |
|
125 | + |
|
126 | + |
|
127 | + /** |
|
128 | + * @param string $handle |
|
129 | + * @param string $source |
|
130 | + * @param array $dependencies |
|
131 | + * @param string $media |
|
132 | + * @return StylesheetAsset |
|
133 | + * @throws DuplicateCollectionIdentifierException |
|
134 | + * @throws InvalidDataTypeException |
|
135 | + * @throws InvalidEntityException |
|
136 | + * @since 4.9.62.p |
|
137 | + */ |
|
138 | + public function addStylesheet( |
|
139 | + $handle, |
|
140 | + $source, |
|
141 | + array $dependencies = array(), |
|
142 | + $media = 'all' |
|
143 | + ) { |
|
144 | + $asset = new StylesheetAsset( |
|
145 | + $handle, |
|
146 | + $source, |
|
147 | + $dependencies, |
|
148 | + $this->domain, |
|
149 | + $media |
|
150 | + ); |
|
151 | + $this->assets->add($asset, $handle); |
|
152 | + return $asset; |
|
153 | + } |
|
154 | + |
|
155 | + |
|
156 | + /** |
|
157 | + * @param string $handle |
|
158 | + * @return bool |
|
159 | + * @since 4.9.62.p |
|
160 | + */ |
|
161 | + public function enqueueAsset($handle) |
|
162 | + { |
|
163 | + if ($this->assets->has($handle)) { |
|
164 | + $asset = $this->assets->get($handle); |
|
165 | + if ($asset->isRegistered()) { |
|
166 | + $asset->enqueueAsset(); |
|
167 | + return true; |
|
168 | + } |
|
169 | + } |
|
170 | + return false; |
|
171 | + } |
|
172 | 172 | } |
@@ -19,78 +19,78 @@ |
||
19 | 19 | */ |
20 | 20 | interface AssetManagerInterface |
21 | 21 | { |
22 | - /** |
|
23 | - * @since $VID:$ |
|
24 | - * @return string |
|
25 | - */ |
|
26 | - public function assetNamespace(); |
|
22 | + /** |
|
23 | + * @since $VID:$ |
|
24 | + * @return string |
|
25 | + */ |
|
26 | + public function assetNamespace(); |
|
27 | 27 | |
28 | - /** |
|
29 | - * @since 4.9.62.p |
|
30 | - */ |
|
31 | - public function addAssets(); |
|
28 | + /** |
|
29 | + * @since 4.9.62.p |
|
30 | + */ |
|
31 | + public function addAssets(); |
|
32 | 32 | |
33 | 33 | |
34 | - /** |
|
35 | - * @return ManifestFile |
|
36 | - * @throws DuplicateCollectionIdentifierException |
|
37 | - * @throws InvalidDataTypeException |
|
38 | - * @throws InvalidEntityException |
|
39 | - * @since 4.9.62.p |
|
40 | - */ |
|
41 | - public function addManifestFile(); |
|
34 | + /** |
|
35 | + * @return ManifestFile |
|
36 | + * @throws DuplicateCollectionIdentifierException |
|
37 | + * @throws InvalidDataTypeException |
|
38 | + * @throws InvalidEntityException |
|
39 | + * @since 4.9.62.p |
|
40 | + */ |
|
41 | + public function addManifestFile(); |
|
42 | 42 | |
43 | 43 | |
44 | - /** |
|
45 | - * @return ManifestFile[] |
|
46 | - * @since 4.9.62.p |
|
47 | - */ |
|
48 | - public function getManifestFile(); |
|
44 | + /** |
|
45 | + * @return ManifestFile[] |
|
46 | + * @since 4.9.62.p |
|
47 | + */ |
|
48 | + public function getManifestFile(); |
|
49 | 49 | |
50 | 50 | |
51 | - /** |
|
52 | - * @param string $handle |
|
53 | - * @param string $source |
|
54 | - * @param array $dependencies |
|
55 | - * @param bool $load_in_footer |
|
56 | - * @return JavascriptAsset |
|
57 | - * @throws DuplicateCollectionIdentifierException |
|
58 | - * @throws InvalidDataTypeException |
|
59 | - * @throws InvalidEntityException |
|
60 | - * @since 4.9.62.p |
|
61 | - */ |
|
62 | - public function addJavascript( |
|
63 | - $handle, |
|
64 | - $source, |
|
65 | - array $dependencies = array(), |
|
66 | - $load_in_footer = true |
|
67 | - ); |
|
51 | + /** |
|
52 | + * @param string $handle |
|
53 | + * @param string $source |
|
54 | + * @param array $dependencies |
|
55 | + * @param bool $load_in_footer |
|
56 | + * @return JavascriptAsset |
|
57 | + * @throws DuplicateCollectionIdentifierException |
|
58 | + * @throws InvalidDataTypeException |
|
59 | + * @throws InvalidEntityException |
|
60 | + * @since 4.9.62.p |
|
61 | + */ |
|
62 | + public function addJavascript( |
|
63 | + $handle, |
|
64 | + $source, |
|
65 | + array $dependencies = array(), |
|
66 | + $load_in_footer = true |
|
67 | + ); |
|
68 | 68 | |
69 | 69 | |
70 | 70 | |
71 | - /** |
|
72 | - * @param string $handle |
|
73 | - * @param string $source |
|
74 | - * @param array $dependencies |
|
75 | - * @param string $media |
|
76 | - * @return StylesheetAsset |
|
77 | - * @throws DuplicateCollectionIdentifierException |
|
78 | - * @throws InvalidDataTypeException |
|
79 | - * @throws InvalidEntityException |
|
80 | - * @since 4.9.62.p |
|
81 | - */ |
|
82 | - public function addStylesheet( |
|
83 | - $handle, |
|
84 | - $source, |
|
85 | - array $dependencies = array(), |
|
86 | - $media = 'all' |
|
87 | - ); |
|
71 | + /** |
|
72 | + * @param string $handle |
|
73 | + * @param string $source |
|
74 | + * @param array $dependencies |
|
75 | + * @param string $media |
|
76 | + * @return StylesheetAsset |
|
77 | + * @throws DuplicateCollectionIdentifierException |
|
78 | + * @throws InvalidDataTypeException |
|
79 | + * @throws InvalidEntityException |
|
80 | + * @since 4.9.62.p |
|
81 | + */ |
|
82 | + public function addStylesheet( |
|
83 | + $handle, |
|
84 | + $source, |
|
85 | + array $dependencies = array(), |
|
86 | + $media = 'all' |
|
87 | + ); |
|
88 | 88 | |
89 | 89 | |
90 | - /** |
|
91 | - * @param string $handle |
|
92 | - * @return bool |
|
93 | - * @since 4.9.62.p |
|
94 | - */ |
|
95 | - public function enqueueAsset($handle); |
|
90 | + /** |
|
91 | + * @param string $handle |
|
92 | + * @return bool |
|
93 | + * @since 4.9.62.p |
|
94 | + */ |
|
95 | + public function enqueueAsset($handle); |
|
96 | 96 | } |