User tests: Successful: Unsuccessful:
This is update to #22435
Now the WebAssetRegistry shows a correct state of dependency, even before attach happen. So the asset state active/inactive should be correct at any time.
Also I have improved dependency calculation, to use Topological sorting.
Run somewhere:
$waInst = new \Joomla\CMS\WebAsset\WebAssetRegistry;
$waInst->setDispatcher($app->getDispatcher());
$waInst->addAsset(new \Joomla\CMS\WebAsset\WebAssetItem('mother'));
$waInst->addAsset(new \Joomla\CMS\WebAsset\WebAssetItem('father'));
$waInst->addAsset(new \Joomla\CMS\WebAsset\WebAssetItem('child1', ['dependencies' => ['mother', 'father']]));
$waInst->enableAsset('child1');
var_dump($waInst->getAsset('mother')->isActive());
var_dump($waInst->getAsset('father')->isActive());
var_dump($waInst->getAsset('child1')->isActive());
$waInst->enableAsset('mother');
$waInst->disableAsset('child1');
var_dump($waInst->getAsset('mother')->isActive());
var_dump($waInst->getAsset('father')->isActive());
var_dump($waInst->getAsset('child1')->isActive());
true
true
true
true
false
false
false
false
true
true
false
false
@mbabker one more review?
Need to decide how to use assets in layouts and other parts of the CMS.
Current ways are:
Factory::getDocument()->getWebAssetManager()->enableAsset('fooBar');
Factory::getContainer()->get('webasset')->enableAsset('fooBar');
Factory::getContainer()->get('webasset')
- does not depends from a request, and can be run at any time of execution, that I like
Factory::getDocument()->getWebAssetManager()
- depends from request, and can be run only "afterRoute"
what could be better, any ideas? something "between" these two.
Status | New | ⇒ | Pending |
Category | ⇒ | Libraries |
Labels |
Added:
?
|
Status | Pending | ⇒ | Fixed in Code Base |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2018-10-26 09:41:19 |
Closed_By | ⇒ | wilsonge |
Thanks!
Good. Plugins that are arbitrarily trying to load media in
onAfterInitialise
are problems anyway. Media loading shouldn't be allowed until we know the request format, the current API makes it way too easy to force HTML format if you are crazy enough to try a non-HTML outputting request.