AssetPackage
API reference › Foxy › Asset › AssetPackage
Maintains Composer-provided dependencies in a frontend package manifest.
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
__construct() | Loads the frontend package manifest and injects metadata inherited from the Composer root package. | AssetPackage |
addNewDependencies() | Adds Composer asset dependencies and returns the names that were already installed. | AssetPackage |
getInstalledDependencies() | Returns Composer-managed dependencies currently declared in the package manifest. | AssetPackage |
getPackage() | Returns the complete frontend package manifest. | AssetPackage |
removeUnusedDependencies() | Removes Composer-managed dependencies absent from the current dependency set. | AssetPackage |
setPackage() | Replaces the in-memory frontend package manifest. | AssetPackage |
write() | Writes the in-memory package manifest to its JSON file. | AssetPackage |
Constants
Section titled “Constants”| Constant | Value | Description | Defined by |
|---|---|---|---|
COMPOSER_PREFIX | '@composer-asset/' | AssetPackage | |
SECTION_DEPENDENCIES | 'dependencies' | AssetPackage | |
SECTION_DEV_DEPENDENCIES | 'devDependencies' | AssetPackage |
Method details
Section titled “Method details”__construct()
Section titled “__construct() ”public function __construct(Composer\Package\RootPackageInterface $rootPackage, Composer\Json\JsonFile $jsonFile, Composer\Util\Filesystem|null $fs = null)Loads the frontend package manifest and injects metadata inherited from the Composer root package.
Parameters
| Parameter | Type | Description |
|---|---|---|
$rootPackage | Composer\ | The composer root package |
$jsonFile | Composer\ | The JSON file |
$fs | Composer\ |
Throws
Seld\JsonLint\ParsingException
addNewDependencies()
Section titled “addNewDependencies() ”public function addNewDependencies(array $dependencies): list<string>Adds Composer asset dependencies and returns the names that were already installed.
Parameters
| Parameter | Type | Description |
|---|---|---|
$dependencies | array | The dependencies |
Returns
list<string>: The existing packages.
getInstalledDependencies()
Section titled “getInstalledDependencies() ”public function getInstalledDependencies(): arrayReturns Composer-managed dependencies currently declared in the package manifest.
Returns
array
getPackage()
Section titled “getPackage() ”public function getPackage(): arrayReturns the complete frontend package manifest.
Returns
array
removeUnusedDependencies()
Section titled “removeUnusedDependencies() ”public function removeUnusedDependencies(array $dependencies): selfRemoves Composer-managed dependencies absent from the current dependency set.
Parameters
| Parameter | Type | Description |
|---|---|---|
$dependencies | array |
Returns
self
setPackage()
Section titled “setPackage() ”public function setPackage(array $package): selfReplaces the in-memory frontend package manifest.
Parameters
| Parameter | Type | Description |
|---|---|---|
$package | array |
Returns
self
write()
Section titled “write() ”public function write(): selfWrites the in-memory package manifest to its JSON file.