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
= {"mix":{"configFile":"winter.mix.js"},"vite":{"configFile":"vite.config.mjs"}}
List of package types and registration methods
protected
$packageJson
:
string
= "package.json"
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.
public
getPackage (string $name, boolean $includeIgnored = false
)
: array
Returns package(s).
Property | Type | Description |
---|---|---|
$name | string |
string
|
$includeIgnored | boolean |
boolean
|
public getPackageCount () : integer
Returns the count of packages registered.
public
getPackages (string $type, boolean $includeIgnored = false
)
: array
Returns all packages registered.
Property | Type | Description |
---|---|---|
$type | string |
string
|
$includeIgnored | boolean |
boolean
|
public
hasPackage (string $name, boolean $includeIgnored = false
)
: bool
Returns if package(s) is registered.
Property | Type | Description |
---|---|---|
$name | string |
string
|
$includeIgnored | boolean |
boolean
|
public init () : void
Constructor.
public static registerCallback (callable $callback) : void
Registers a callback for processing.
Property | Type | Description |
---|---|---|
$callback | callable |
callable
|
public registerCompilable (string $name, array $config) : void
Register a compilable config.
Property | Type | Description |
---|---|---|
$name | string |
string
|
$config | array |
array
|
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
Property | Type | Description |
---|---|---|
$name | string |
string
The name of the package being registered |
$path | string |
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 |
string
The type of compilable |
protected getRegistrationMethod (string $type) : string
Returns the registration method for a compiler type
Property | Type | Description |
---|---|---|
$type | string |
string
|
protected isPackageIgnored (string $packagePath) : bool
Check if the provided package is ignored.
Property | Type | Description |
---|---|---|
$packagePath | string |
string
|
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.