Symfony2 API
Class

Symfony\Component\Templating\Helper\CoreAssetsHelper

class CoreAssetsHelper extends Helper implements PackageInterface

CoreAssetsHelper helps manage asset URLs.

Usage:

<code>
<img src="<?php echo $view['assets']->getUrl('foo.png') ?>" />
</code>

Methods

setCharset(string $charset)

Sets the default charset.

from Helper
string getCharset()

Gets the default charset.

from Helper
__construct(PackageInterface $defaultPackage, array $namedPackages = array())

Constructor.

setDefaultPackage(PackageInterface $defaultPackage)

Sets the default package.

addPackage(string $name, PackageInterface $package)

Adds an asset package to the helper.

PackageInterface getPackage(string $name = null)

Returns an asset package.

string getVersion(string $packageName = null)

Returns the asset package version.

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

Returns an absolute or root-relative public path.

string getName()

Returns the canonical name of this helper.

Details

in Helper at line 35
public setCharset(string $charset)

Sets the default charset.

Parameters

string $charset The charset

in Helper at line 47
public string getCharset()

Gets the default charset.

Return Value

string The default charset

at line 39
public __construct(PackageInterface $defaultPackage, array $namedPackages = array())

Constructor.

Parameters

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

at line 54
public setDefaultPackage(PackageInterface $defaultPackage)

Sets the default package.

Parameters

PackageInterface $defaultPackage The default package

at line 65
public addPackage(string $name, PackageInterface $package)

Adds an asset package to the helper.

Parameters

string $name The package name
PackageInterface $package The package

at line 79
public 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

at line 99
public string getVersion(string $packageName = null)

Returns the asset package version.

Parameters

string $packageName A package name

Return Value

string The current version

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

Returns an absolute or root-relative public path.

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

at line 124
public string getName()

Returns the canonical name of this helper.

Return Value

string The canonical name