Skip to content

Class Phalcon\Assets\Collection

implements Countable, Iterator, Traversable

Source on GitHub

Represents a collection of resources

Methods

public getPrefix ()

...

public getLocal ()

...

public getResources ()

...

public getCodes ()

...

public getPosition ()

...

public getFilters ()

...

public getAttributes ()

...

public getJoin ()

...

public getTargetUri ()

...

public getTargetPath ()

...

public getTargetLocal ()

...

public getSourcePath ()

...

public __construct ()

Phalcon\Assets\Collection constructor

public add (Phalcon\Assets\Resource $resource)

Adds a resource to the collection

public addInline (Phalcon\Assets\Inline $code)

Adds an inline code to the collection

public has (Phalcon\Assets\ResourceInterface $resource)

Checks this the resource is added to the collection.

<?php

use Phalcon\Assets\Resource;
use Phalcon\Assets\Collection;

$collection = new Collection();

$resource = new Resource("js", "js/jquery.js");
$resource->has($resource); // true

public addCss (mixed $path, [mixed $local], [mixed $filter], [mixed $attributes])

Adds a CSS resource to the collection

public addInlineCss (mixed $content, [mixed $filter], [mixed $attributes])

Adds an inline CSS to the collection

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

Adds a javascript resource to the collection

public addInlineJs (mixed $content, [mixed $filter], [mixed $attributes])

Adds an inline javascript to the collection

public count ()

Returns the number of elements in the form

public rewind ()

Rewinds the internal iterator

public current ()

Returns the current resource in the iterator

public int key ()

Returns the current position/key in the iterator

public next ()

Moves the internal iteration pointer to the next position

public valid ()

Check if the current element in the iterator is valid

public setTargetPath (mixed $targetPath)

Sets the target path of the file for the filtered/join output

public setSourcePath (mixed $sourcePath)

Sets a base source path for all the resources in this collection

public setTargetUri (mixed $targetUri)

Sets a target uri for the generated HTML

public setPrefix (mixed $prefix)

Sets a common prefix for all the resources

public setLocal (mixed $local)

Sets if the collection uses local resources by default

public setAttributes (array $attributes)

Sets extra HTML attributes

public setFilters (array $filters)

Sets an array of filters in the collection

public setTargetLocal (mixed $targetLocal)

Sets the target local

public join (mixed $join)

Sets if all filtered resources in the collection must be joined in a single result file

public getRealTargetPath (mixed $basePath)

Returns the complete location where the joined/filtered collection must be written

public addFilter (Phalcon\Assets\FilterInterface $filter)

Adds a filter to the collection

final protected addResource (Phalcon\Assets\ResourceInterface $resource)

Adds a resource or inline-code to the collection


Class Phalcon\Assets\Exception

extends class Phalcon\Exception

implements Throwable

Source on GitHub

Methods

final private Exception __clone () inherited from Exception

Clone the exception

public __construct ([mixed $message], [mixed $code], [mixed $previous]) inherited from Exception

Exception constructor

public __wakeup () inherited from Exception

...

final public string getMessage () inherited from Exception

Gets the Exception message

final public int getCode () inherited from Exception

Gets the Exception code

final public string getFile () inherited from Exception

Gets the file in which the exception occurred

final public int getLine () inherited from Exception

Gets the line in which the exception occurred

final public array getTrace () inherited from Exception

Gets the stack trace

final public Exception getPrevious () inherited from Exception

Returns previous Exception

final public Exception getTraceAsString () inherited from Exception

Gets the stack trace as a string

public string __toString () inherited from Exception

String representation of the exception


Interface Phalcon\Assets\FilterInterface

Source on GitHub

Methods

abstract public filter (mixed $content)

...


Class Phalcon\Assets\Filters\Cssmin

implements Phalcon\Assets\FilterInterface

Source on GitHub

Minify the css - removes comments removes newlines and line feeds keeping removes last semicolon from last property

Methods

public filter (mixed $content)

Filters the content using CSSMIN


Class Phalcon\Assets\Filters\Jsmin

implements Phalcon\Assets\FilterInterface

Source on GitHub

Deletes the characters which are insignificant to JavaScript. Comments will be removed. Tabs will be replaced with spaces. Carriage returns will be replaced with linefeeds. Most spaces and linefeeds will be removed.

Methods

public filter (mixed $content)

Filters the content using JSMIN


Class Phalcon\Assets\Filters\None

implements Phalcon\Assets\FilterInterface

Source on GitHub

Returns the content without make any modification to the original source

Methods

public filter (mixed $content)

Returns the content without be touched


Class Phalcon\Assets\Inline

implements Phalcon\Assets\ResourceInterface

Source on GitHub

Represents an inline asset

<?php

$inline = new \Phalcon\Assets\Inline("js", "alert('hello world');");

Methods

public getType ()

...

public getContent ()

...

public getFilter ()

...

public getAttributes ()

...

public __construct (string $type, string $content, [boolean $filter], [array $attributes])

Phalcon\Assets\Inline constructor

public setType (mixed $type)

Sets the inline's type

public setFilter (mixed $filter)

Sets if the resource must be filtered or not

public setAttributes (array $attributes)

Sets extra HTML attributes

public getResourceKey ()

Gets the resource's key.


Class Phalcon\Assets\Inline\Css

extends class Phalcon\Assets\Inline

implements Phalcon\Assets\ResourceInterface

Source on GitHub

Represents an inlined CSS

Methods

public __construct (string $content, [boolean $filter], [array $attributes])

Phalcon\Assets\Inline\Css Constructor

public string getType () inherited from Phalcon\Assets\Inline

Gets the resource's type.

public string getContent () inherited from Phalcon\Assets\Inline

Gets the content.

public boolean getFilter () inherited from Phalcon\Assets\Inline

Gets if the resource must be filtered or not.

public array getAttributes () inherited from Phalcon\Assets\Inline

Gets extra HTML attributes.

public self setType (string $type) inherited from Phalcon\Assets\Inline

Sets the inline's type

public self setFilter (boolean $filter) inherited from Phalcon\Assets\Inline

Sets if the resource must be filtered or not

public self setAttributes (array $attributes) inherited from Phalcon\Assets\Inline

Sets extra HTML attributes

public string getResourceKey () inherited from Phalcon\Assets\Inline

Gets the resource's key.


Class Phalcon\Assets\Inline\Js

extends class Phalcon\Assets\Inline

implements Phalcon\Assets\ResourceInterface

Source on GitHub

Represents an inline Javascript

Methods

public __construct (string $content, [boolean $filter], [array $attributes])

public getType () inherited from Phalcon\Assets\Inline

...

public getContent () inherited from Phalcon\Assets\Inline

...

public getFilter () inherited from Phalcon\Assets\Inline

...

public getAttributes () inherited from Phalcon\Assets\Inline

...

public setType (mixed $type) inherited from Phalcon\Assets\Inline

Sets the inline's type

public setFilter (mixed $filter) inherited from Phalcon\Assets\Inline

Sets if the resource must be filtered or not

public setAttributes (array $attributes) inherited from Phalcon\Assets\Inline

Sets extra HTML attributes

public getResourceKey () inherited from Phalcon\Assets\Inline

Gets the resource's key.


Class Phalcon\Assets\Manager

Source on GitHub

Manages collections of CSS/Javascript assets

Methods

public __construct ([array $options])

public setOptions (array $options)

Sets the manager options

public getOptions ()

Returns the manager options

public useImplicitOutput (mixed $implicitOutput)

Sets if the HTML generated must be directly printed or returned

public addCss (mixed $path, [mixed $local], [mixed $filter], [mixed $attributes])

Adds a Css resource to the 'css' collection

<?php

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

public addInlineCss (mixed $content, [mixed $filter], [mixed $attributes])

Adds an inline Css to the 'css' collection

public addJs (mixed $path, [mixed $local], [mixed $filter], [mixed $attributes])

Adds a javascript resource to the 'js' collection

<?php

$assets->addJs("scripts/jquery.js");
$assets->addJs("https://jquery.my-cdn.com/jquery.js", false);

public addInlineJs (mixed $content, [mixed $filter], [mixed $attributes])

Adds an inline javascript to the 'js' collection

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

Adds a resource by its type

<?php

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

public addInlineCodeByType (mixed $type, Phalcon\Assets\Inline $code)

Adds an inline code by its type

public addResource (Phalcon\Assets\Resource $resource)

Adds a raw resource to the manager

<?php

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

public addInlineCode (Phalcon\Assets\Inline $code)

Adds a raw inline code to the manager

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

Sets a collection in the Assets Manager

<?php

$assets->set("js", $collection);

public get (mixed $id)

Returns a collection by its id.

<?php

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

public getCss ()

Returns the CSS collection of assets

public getJs ()

Returns the CSS collection of assets

public collection (mixed $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 outputInline (Phalcon\Assets\Collection $collection, string $type)

Traverses a collection and generate its HTML

public outputCss ([string $collectionName])

Prints the HTML for CSS resources

public outputInlineCss ([string $collectionName])

Prints the HTML for inline CSS

public outputJs ([string $collectionName])

Prints the HTML for JS resources

public outputInlineJs ([string $collectionName])

Prints the HTML for inline JS

public getCollections ()

Returns existing collections in the manager

public exists (mixed $id)

Returns true or false if collection exists.

<?php

if ($assets->exists("jsHeader")) {
    // \Phalcon\Assets\Collection
    $collection = $assets->get("jsHeader");
}

Class Phalcon\Assets\Resource

implements Phalcon\Assets\ResourceInterface

Source on GitHub

Represents an asset resource

<?php

$resource = new \Phalcon\Assets\Resource("js", "javascripts/jquery.js");

Methods

public getType ()

public getPath ()

public getLocal ()

public getFilter ()

public getAttributes ()

public getSourcePath ()

...

public getTargetPath ()

...

public getTargetUri ()

...

public __construct (string $type, string $path, [boolean $local], [boolean $filter], [array $attributes])

Phalcon\Assets\Resource constructor

public setType (mixed $type)

Sets the resource's type

public setPath (mixed $path)

Sets the resource's path

public setLocal (mixed $local)

Sets if the resource is local or external

public setFilter (mixed $filter)

Sets if the resource must be filtered or not

public setAttributes (array $attributes)

Sets extra HTML attributes

public setTargetUri (mixed $targetUri)

Sets a target uri for the generated HTML

public setSourcePath (mixed $sourcePath)

Sets the resource's source path

public setTargetPath (mixed $targetPath)

Sets the resource's target path

public getContent ([mixed $basePath])

Returns the content of the resource as an string Optionally a base path where the resource is located can be set

public getRealTargetUri ()

Returns the real target uri for the generated HTML

public getRealSourcePath ([mixed $basePath])

Returns the complete location where the resource is located

public getRealTargetPath ([mixed $basePath])

Returns the complete location where the resource must be written

public getResourceKey ()

Gets the resource's key.


Class Phalcon\Assets\Resource\Css

extends class Phalcon\Assets\Resource

implements Phalcon\Assets\ResourceInterface

Source on GitHub

Represents CSS resources

Methods

public __construct (string $path, [boolean $local], [boolean $filter], [array $attributes])

public getType () inherited from Phalcon\Assets\Resource

public getPath () inherited from Phalcon\Assets\Resource

public getLocal () inherited from Phalcon\Assets\Resource

public getFilter () inherited from Phalcon\Assets\Resource

public getAttributes () inherited from Phalcon\Assets\Resource

public getSourcePath () inherited from Phalcon\Assets\Resource

...

public getTargetPath () inherited from Phalcon\Assets\Resource

...

public getTargetUri () inherited from Phalcon\Assets\Resource

...

public setType (mixed $type) inherited from Phalcon\Assets\Resource

Sets the resource's type

public setPath (mixed $path) inherited from Phalcon\Assets\Resource

Sets the resource's path

public setLocal (mixed $local) inherited from Phalcon\Assets\Resource

Sets if the resource is local or external

public setFilter (mixed $filter) inherited from Phalcon\Assets\Resource

Sets if the resource must be filtered or not

public setAttributes (array $attributes) inherited from Phalcon\Assets\Resource

Sets extra HTML attributes

public setTargetUri (mixed $targetUri) inherited from Phalcon\Assets\Resource

Sets a target uri for the generated HTML

public setSourcePath (mixed $sourcePath) inherited from Phalcon\Assets\Resource

Sets the resource's source path

public setTargetPath (mixed $targetPath) inherited from Phalcon\Assets\Resource

Sets the resource's target path

public getContent ([mixed $basePath]) inherited from Phalcon\Assets\Resource

Returns the content of the resource as an string Optionally a base path where the resource is located can be set

public getRealTargetUri () inherited from Phalcon\Assets\Resource

Returns the real target uri for the generated HTML

public getRealSourcePath ([mixed $basePath]) inherited from Phalcon\Assets\Resource

Returns the complete location where the resource is located

public getRealTargetPath ([mixed $basePath]) inherited from Phalcon\Assets\Resource

Returns the complete location where the resource must be written

public getResourceKey () inherited from Phalcon\Assets\Resource

Gets the resource's key.


Class Phalcon\Assets\Resource\Js

extends class Phalcon\Assets\Resource

implements Phalcon\Assets\ResourceInterface

Source on GitHub

Represents Javascript resources

Methods

public __construct (string $path, [boolean $local], [boolean $filter], [array $attributes])

public getType () inherited from Phalcon\Assets\Resource

public getPath () inherited from Phalcon\Assets\Resource

public getLocal () inherited from Phalcon\Assets\Resource

public getFilter () inherited from Phalcon\Assets\Resource

public getAttributes () inherited from Phalcon\Assets\Resource

public getSourcePath () inherited from Phalcon\Assets\Resource

...

public getTargetPath () inherited from Phalcon\Assets\Resource

...

public getTargetUri () inherited from Phalcon\Assets\Resource

...

public setType (mixed $type) inherited from Phalcon\Assets\Resource

Sets the resource's type

public setPath (mixed $path) inherited from Phalcon\Assets\Resource

Sets the resource's path

public setLocal (mixed $local) inherited from Phalcon\Assets\Resource

Sets if the resource is local or external

public setFilter (mixed $filter) inherited from Phalcon\Assets\Resource

Sets if the resource must be filtered or not

public setAttributes (array $attributes) inherited from Phalcon\Assets\Resource

Sets extra HTML attributes

public setTargetUri (mixed $targetUri) inherited from Phalcon\Assets\Resource

Sets a target uri for the generated HTML

public setSourcePath (mixed $sourcePath) inherited from Phalcon\Assets\Resource

Sets the resource's source path

public setTargetPath (mixed $targetPath) inherited from Phalcon\Assets\Resource

Sets the resource's target path

public getContent ([mixed $basePath]) inherited from Phalcon\Assets\Resource

Returns the content of the resource as an string Optionally a base path where the resource is located can be set

public getRealTargetUri () inherited from Phalcon\Assets\Resource

Returns the real target uri for the generated HTML

public getRealSourcePath ([mixed $basePath]) inherited from Phalcon\Assets\Resource

Returns the complete location where the resource is located

public getRealTargetPath ([mixed $basePath]) inherited from Phalcon\Assets\Resource

Returns the complete location where the resource must be written

public getResourceKey () inherited from Phalcon\Assets\Resource

Gets the resource's key.


Interface Phalcon\Assets\ResourceInterface

Source on GitHub

Methods

abstract public setType (mixed $type)

...

abstract public getType ()

...

abstract public setFilter (mixed $filter)

...

abstract public getFilter ()

...

abstract public setAttributes (array $attributes)

...

abstract public getAttributes ()

...

abstract public getResourceKey ()

...