class Packages

Helps manage asset URLs.

Methods

__construct(PackageInterface $defaultPackage = null, array $packages = array())

No description

setDefaultPackage(PackageInterface $defaultPackage)

Sets the default package.

addPackage(string $name, PackageInterface $package)

Adds a package.

getPackage(string $name = null)

Returns an asset package.

string
getVersion(string $path, string $packageName = null)

Gets the version to add to public URL.

string
getUrl(string $path, string $packageName = null)

Returns the public path.

Details

at line line 32
__construct(PackageInterface $defaultPackage = null, array $packages = array())

Parameters

PackageInterface $defaultPackage The default package
array $packages Additional packages indexed by name

at line line 46
setDefaultPackage(PackageInterface $defaultPackage)

Sets the default package.

Parameters

PackageInterface $defaultPackage The default package

at line line 57
addPackage(string $name, PackageInterface $package)

Adds a package.

Parameters

string $name The package name
PackageInterface $package The package

at line line 72
PackageInterface getPackage(string $name = null)

Returns an asset package.

Parameters

string $name The name of the package or null for the default package

Return Value

PackageInterface An asset package

Exceptions

InvalidArgumentException If there is no package by that name
LogicException If no default package is defined

at line line 97
string getVersion(string $path, string $packageName = null)

Gets the version to add to public URL.

Parameters

string $path A public path
string $packageName A package name

Return Value

string The current version

at line line 112
string getUrl(string $path, string $packageName = null)

Returns the public path.

Absolute paths (i.e. http://...) are returned unmodified.

Parameters

string $path A public path
string $packageName The name of the asset package to use

Return Value

string A public path which takes into account the base path and URL path