Skip to content

[6.x]: yii2-adapter: Assets are not registered when $view->registerAssetBundle() is called in the plugin’s init() method #19381

Description

@vnali

What happened?

Description

I am trying to register assets in my plugin -which require yii2-adapter - by calling $view->registerAssetBundle(...) for frontend requests in the plugin’s init() method, but the assets are not included in the rendered page.

I can confirm that the init() method of the asset bundle is being called, but the asset resources themselves are not added to the frontend output.

I also tested the same approach with a CP request and got the same behavior.

if (!Craft::$app->getRequest()->getIsConsoleRequest() && !Craft::$app->getRequest()->getIsCpRequest() && $settings->registerCounter) {
   $view->registerAssetBundle(CounterAsset::class);
}

Craft CMS version

6.0.0-alpha.16

PHP version

No response

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

  • craft-counter

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions