Packages

class Packages

Helps manage asset URLs.

Methods

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

Sets the default package.

addPackage(string $name, PackageInterface $package)

Adds a package.

PackageInterface 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

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

Parameters

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

setDefaultPackage(PackageInterface $defaultPackage)

Sets the default package.

Parameters

PackageInterface $defaultPackage The default package

addPackage(string $name, PackageInterface $package)

Adds a package.

Parameters

string $name The package name
PackageInterface $package The package

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

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

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
doc_Symfony
2016-10-28 06:25:42
Comments
Leave a Comment

Please login to continue.