Documentation

Class Phalcon\Assets\Manager

Source on GitHub

Manages collections of CSS/Javascript assets

Methods

public __construct ([array $options])

Phalcon\Assets\Manager constructor

public Phalcon\Assets\Manager setSourceBasePath (string $basePath)

Sets the source base path

public string getSourceBasePath ()

Returns the source base path

public Phalcon\Assets\Manager setTargetBasePath (string $basePath)

Sets the target base path

public string getTargetBasePath ()

Returns the target base path

public Phalcon\Assets\Manager setTargetBaseUri (string $baseUri)

Sets the target base uri

public string getTargetBaseUri ()

Returns the target base uri

public Phalcon\Assets\Manager useImplicitOutput (boolean $implicitOutput)

Sets if the HTML generated must be directly printed or returned

public Phalcon\Assets\Manager addCss (string $path, [boolean $local], [boolean $filter], [array $attributes])

Adds a Css resource to the ‘css’ collection

<?php

$assets->addCss('css/bootstrap.css');
$assets->addCss('http://bootstrap.my-cdn.com/style.css', false);

public Phalcon\Assets\Manager addJs (string $path, [boolean $local], [boolean $filter], [array $attributes])

Adds a javascript resource to the ‘js’ collection

<?php

$assets->addJs('scripts/jquery.js');
$assets->addJs('http://jquery.my-cdn.com/jquery.js', true);

public Phalcon\Assets\Manager addResourceByType (string $type, Phalcon\Assets\Resource $resource)

Adds a resource by its type

<?php

$assets->addResourceByType('css', new Phalcon\Assets\Resource\Css('css/style.css'));

public Phalcon\Assets\Manager addResource (Phalcon\Assets\Resource $resource)

Adds a raw resource to the manager

<?php

 $assets->addResource(new Phalcon\Assets\Resource('css', 'css/style.css'));

public Phalcon\Assets\Manager set (string $id, Phalcon\Assets\Collection $collection)

Sets a collection in the Assets Manager

<?php

 $assets->get('js', $collection);

public Phalcon\Assets\Collection get (string $id)

Returns a collection by its id

<?php

 $scripts = $assets->get('js');

public Phalcon\Assets\Collection getCss ()

Returns the CSS collection of assets

public Phalcon\Assets\Collection getJs ()

Returns the CSS collection of assets

public Phalcon\Assets\Collection collection (string $name)

Creates/Returns a collection of resources

public output (Phalcon\Assets\Collection $collection, callback $callback, [string $type], [array $args])

Traverses a collection calling the callback to generate its HTML

public outputCss ([string $collectionName], [array $args])

Prints the HTML for CSS resources

public outputJs ([string $collectionName], [array $args])

Prints the HTML for JS resources