BundleManager
Asset Bundle manager.
class System\Classes\Asset\BundleManager
This class manages "asset bundles" registered by the core and plugins that are used by the [mix|vite]:create commands to generate & populate the required files for a given bundle. Bundles include information on the specific packages & versions required for the bundle to function in the context of the Winter package (plugin or theme) it is being used in, as well as dependencies specific to the desired compiler (e.g. mix or vite).
Traits
Trait | Description |
---|---|
Singleton
|
Singleton trait. |
Constants
Constant | Type | Value | Description |
---|---|---|---|
HANDLER_SCAFFOLD
|
string |
"_scaffold"
|
string
"_scaffold"
|
HANDLER_SETUP
|
string |
"_setup"
|
string
"_setup"
|
Properties
protected
$defaultPackages
:
array
= {"tailwind":{"tailwindcss":"^3.4.0","@tailwindcss\/forms":"^0.5.3","@tailwindcss\/typography":"^0.5.2"},"vue":{"vue":"^3.4.0","vite":{"@vitejs\/plugin-vue":"^5.0.5"}}}
List of packages available to install. Allows for $compilerName
=> [CompilerSpecificPackage
]
protected
$registeredBundles
:
array
= []
List of registered asset bundles in the system
Methods
public getBundlePackages (string $name, string $assetType) : array
Get the packages for a bundle, with compiler specific packages
Property | Type | Description |
---|---|---|
$name | string |
string
|
$assetType | string |
string
|
public getBundles () : array
Get all bundles configured
public getScaffoldHandler (string $name) : Closure | null
Gets the scaffold handler for a bundle.
Property | Type | Description |
---|---|---|
$name | string |
string
|
public getSetupHandler (string $name) : Closure | null
Gets the setup handler for a bundle.
Property | Type | Description |
---|---|---|
$name | string |
string
|
public init () : void
Initialize the singleton
public listRegisteredBundles () : array
Returns a list of the registered asset bundles.
public registerBundle (string $name, array $definition) : static
Registers a single asset bundle.
Property | Type | Description |
---|---|---|
$name | string |
string
|
$definition | array |
array
|
public registerBundles (array $definitions) : static
Registers asset bundles.
Property | Type | Description |
---|---|---|
$definitions | array |
array
|
public registerCallback (callable $callback) : static
Registers a callback function that defines asset bundles. The callback function should register bundles by calling the manager's registerBundles() function.
This instance is passed to the callback function as an argument. Usage:
BundleManager::registerCallback(function ($manager) { $manager->registerAssetBundles([...]); });
Property | Type | Description |
---|---|---|
$callback | callable |
callable
|
public registerScaffoldHandler (string $name, Closure $closure) : static
Registers a single bundle scaffold handler.
Property | Type | Description |
---|---|---|
$name | string |
string
|
$closure | Closure |
Closure
|
public registerSetupHandler (string $name, Closure $closure) : static
Registers a single bundle setup handler.
Property | Type | Description |
---|---|---|
$name | string |
string
|
$closure | Closure |
Closure
|
inherited public __clone ()
inherited public __wakeup ()
inherited
public
static
final
forgetInstance ($container = null
)
: void
Forget this singleton's instance if it exists
Property | Type | Description |
---|---|---|
$container | mixed |
mixed
|
inherited
public
static
final
instance ($container = null
)
: static
Create a new instance of this singleton.
Property | Type | Description |
---|---|---|
$container | mixed |
mixed
|
inherited protected final __construct ()
Constructor.