Table Of Contents

Previous topic

< Class Phalcon\Assets\Filters\None

Next topic

Class Phalcon\Assets\Resource >

Class Phalcon\Assets\Manager

Manages collections of CSS/Javascript assets

Methods

public __construct ([array $options])

Phalcon\Assets\Manager constructor

public Phalcon\Assets\Manager setOptions (array $options)

Sets the manager’s options

public array getOptions ()

Returns the manager’s options

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])

Traverses a collection calling the callback to generate its HTML

public outputCss ([string $collectionName])

Prints the HTML for CSS resources

public outputJs ([string $collectionName])

Prints the HTML for JS resources