PackageManager

Package manager.

 class System\Classes\Asset\PackageManager

This class manages compilable asset "packages" registered by modules, plugins, and themes that provide configurations for Node.js based compilers (e.g. mix or vite) to process.

Traits

Trait Description
Singleton

Singleton trait.

Properties

protected static $callbacks : array

Registered callbacks.

protected $compilableConfigs : array

List of package types and registration methods

protected $packageJson : string

The filename that stores the package definition.

protected $packages : array

A list of packages registered for compiling.

Methods

public fireCallbacks () : void

Calls the deferred callbacks.

Returns
void

public getPackage (string $name, boolean $includeIgnored = false) : array

Returns package(s).

Parameters
Property Description
$name
string
$includeIgnored
boolean
Returns
array

public getPackageCount () : integer

Returns the count of packages registered.

Returns
integer

public getPackages (string $type, boolean $includeIgnored = false) : array

Returns all packages registered.

Parameters
Property Description
$type
string
$includeIgnored
boolean
Returns
array

public hasPackage (string $name, boolean $includeIgnored = false) : bool

Returns if package(s) is registered.

Parameters
Property Description
$name
string
$includeIgnored
boolean
Returns
bool

public init () : void

Constructor.

Returns
void

public static registerCallback (callable $callback) : void

Registers a callback for processing.

Parameters
Property Description
$callback
callable
Returns
void

public registerCompilable (string $name, array $config) : void

Register a compilable config.

Parameters
Property Description
$name
string
$config
array
Returns
void

public registerPackage (string $name, string $path, string $type = "mix") : void

Registers an entity as a package for compilation.

Entities can include plugins, components, themes, modules and much more.

The name of the package is an alias that can be used to reference this package in other methods within this class.

By default, the PackageManager class will look for a package.json file for Node dependencies, and a config file for the compilable configuration

Parameters
Property Description
$name
string

The name of the package being registered

$path
string

The path to the compilable JS configuration file. If there is a related package.json file then it is required to be present in the same directory as the config file

$type
string

The type of compilable

Returns
void

protected getRegistrationMethod (string $type) : string

Returns the registration method for a compiler type

Parameters
Property Description
$type
string
Returns
string

protected isPackageIgnored (string $packagePath) : bool

Check if the provided package is ignored.

Parameters
Property Description
$packagePath
string
Returns
bool

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