Skip to content
PHP Ecosystem
Explore

AssetPackage

API reference › Foxy › Asset › AssetPackage

final classFoxy\Asset\AssetPackage
ImplementsAssetPackageInterface
Sourcesrc/Asset/AssetPackage.php

Maintains Composer-provided dependencies in a frontend package manifest.

MethodDescriptionDefined 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
ConstantValueDescriptionDefined by
COMPOSER_PREFIX'@composer-asset/'AssetPackage
SECTION_DEPENDENCIES'dependencies'AssetPackage
SECTION_DEV_DEPENDENCIES'devDependencies'AssetPackage
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

ParameterTypeDescription
$rootPackageComposer\Package\RootPackageInterfaceThe composer root package
$jsonFileComposer\Json\JsonFileThe JSON file
$fsComposer\Util\Filesystem|null

Throws

  • Seld\JsonLint\ParsingException
public function addNewDependencies(array $dependencies): list<string>

Adds Composer asset dependencies and returns the names that were already installed.

Parameters

ParameterTypeDescription
$dependenciesarrayThe dependencies

Returns

list<string>: The existing packages.

public function getInstalledDependencies(): array

Returns Composer-managed dependencies currently declared in the package manifest.

Returns

array

public function getPackage(): array

Returns the complete frontend package manifest.

Returns

array

public function removeUnusedDependencies(array $dependencies): self

Removes Composer-managed dependencies absent from the current dependency set.

Parameters

ParameterTypeDescription
$dependenciesarray

Returns

self

public function setPackage(array $package): self

Replaces the in-memory frontend package manifest.

Parameters

ParameterTypeDescription
$packagearray

Returns

self

public function write(): self

Writes the in-memory package manifest to its JSON file.

Returns

self

Throws