Download the PHP package heimrichhannot/contao-encore-contracts without Composer
On this page you can find all versions of the php package heimrichhannot/contao-encore-contracts. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download heimrichhannot/contao-encore-contracts
More information about heimrichhannot/contao-encore-contracts
Files in heimrichhannot/contao-encore-contracts
Package contao-encore-contracts
Short Description A set of abstractions needed for encore bundle preparation.
License LGPL-3.0-or-later
Homepage https://github.com/heimrichhannot/contao-encore-contracts
Informations about the package contao-encore-contracts
Contao Encore Contracts
This package contains abstractions to add loose Encore bundle support.
Usage
Register entrypoints
To register encore entrypoints create an EncoreExtension class implementing EncoreExtensionInterface.
Add entrypoints for current page
To add entrypoints (must be registered beforehand) from your code, you can use the PageAssetsTrait.
It checks if encore bundle is installed and add the entry, if this is the case.
Otherwise, it adds the fallback assets to the contao global asset array.
Make your class implement ServiceSubscriberInterface and use PageAssetsTrait (it already implements the needed methods for the ServiceSubscriberInterface).
Afterwards just call $this->addPageEntrypoint(string $name, array $fallbackAssets = []).
If implementing the ServiceSubscriberInterface is not possible, you can use the AddPageEntrypointTrait, which
also provides the addPageEntrypoint method, but requires you to implement the getFrontendAsset method, which should
return the FrontendAsset service object.