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 Description
HANDLER_SCAFFOLD
string "_scaffold"
HANDLER_SETUP
string "_setup"

Properties

protected $defaultPackages : array

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

Parameters
Property Description
$name
string
$assetType
string
Returns
array

public getBundles () : array

Get all bundles configured

Returns
array

public getScaffoldHandler (string $name) : Closure | null

Gets the scaffold handler for a bundle.

Parameters
Property Description
$name
string
Returns
Closure | null

public getSetupHandler (string $name) : Closure | null

Gets the setup handler for a bundle.

Parameters
Property Description
$name
string
Returns
Closure | null

public init () : void

Initialize the singleton

Returns
void

public listRegisteredBundles () : array

Returns a list of the registered asset bundles.

Returns
array

public registerBundle (string $name, array $definition) : static

Registers a single asset bundle.

Parameters
Property Description
$name
string
$definition
array
Returns
static

public registerBundles (array $definitions) : static

Registers asset bundles.

Parameters
Property Description
$definitions
array
Returns
static

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([...]); });

Parameters
Property Description
$callback
callable
Returns
static

public registerScaffoldHandler (string $name, Closure $closure) : static

Registers a single bundle scaffold handler.

Parameters
Property Description
$name
string
$closure
Closure
Returns
static

public registerSetupHandler (string $name, Closure $closure) : static

Registers a single bundle setup handler.

Parameters
Property Description
$name
string
$closure
Closure
Returns
static

inherited public __clone ()

Inherited from Singleton
Returns
mixed

inherited public __wakeup ()

Inherited from Singleton
Returns
mixed

inherited public static final forgetInstance ($container = null) : void

Inherited from Singleton

Forget this singleton's instance if it exists

Parameters
Property Description
$container
mixed
Returns
void

inherited public static final instance ($container = null) : static

Inherited from Singleton

Create a new instance of this singleton.

Parameters
Property Description
$container
mixed
Returns
static

inherited protected final __construct ()

Inherited from Singleton

Constructor.

Returns
mixed
Copyright © 2024 Winter CMS