Class Phalcon\Assets\Asset
Исходный код на GitHub
Namespace |
Phalcon\Assets |
|
Implements |
AssetInterface |
Represents an asset asset
$asset = new \Phalcon\Assets\Asset("js", "javascripts/jquery.js");
Properties
/**
* @var array | null
*/
protected attributes;
/**
* @var bool
*/
protected autoVersion = false;
/**
* @var bool
*/
protected filter;
/**
* @var bool
*/
protected local;
/**
* @var string
*/
protected path;
/**
* @var string
*/
protected sourcePath;
/**
* @var string
*/
protected targetPath;
/**
* @var string
*/
protected targetUri;
/**
* @var string
*/
protected type;
/**
* Version of resource
* @var string
*/
protected version;
Методы
public function __construct( string $type, string $path, bool $local = bool, bool $filter = bool, array $attributes = [], string $version = null, bool $autoVersion = bool );
Phalcon\Assets\Asset constructor
public function getAssetKey(): string;
Gets the asset’s key.
public function getAttributes(): array | null
public function getContent( string $basePath = null ): string;
Returns the content of the asset as an string Optionally a base path where the asset is located can be set
public function getFilter(): bool
public function getLocal(): bool
public function getPath(): string
public function getRealSourcePath( string $basePath = null ): string;
Returns the complete location where the asset is located
public function getRealTargetPath( string $basePath = null ): string;
Returns the complete location where the asset must be written
public function getRealTargetUri(): string;
Returns the real target uri for the generated HTML
public function getSourcePath(): string
public function getTargetPath(): string
public function getTargetUri(): string
public function getType(): string
public function getVersion(): string
public function isAutoVersion(): bool;
Checks if resource is using auto version
public function setAttributes( array $attributes ): AssetInterface;
Sets extra HTML attributes
public function setAutoVersion( bool $autoVersion )
public function setFilter( bool $filter ): AssetInterface;
Sets if the asset must be filtered or not
public function setLocal( bool $local ): AssetInterface;
Sets if the asset is local or external
public function setPath( string $path ): AssetInterface;
Sets the asset’s path
public function setSourcePath( string $sourcePath ): AssetInterface;
Sets the asset’s source path
public function setTargetPath( string $targetPath ): AssetInterface;
Sets the asset’s target path
public function setTargetUri( string $targetUri ): AssetInterface;
Sets a target uri for the generated HTML
public function setType( string $type ): AssetInterface;
Sets the asset’s type
public function setVersion( string $version )
Class Phalcon\Assets\Asset\Css
Исходный код на GitHub
Namespace |
Phalcon\Assets\Asset |
|
Uses |
Phalcon\Assets\Asset |
|
Extends |
AssetBase |
Represents CSS assets
Методы
public function __construct( string $path, bool $local = bool, bool $filter = bool, array $attributes = [], string $version = null, bool $autoVersion = bool );
Phalcon\Assets\Asset\Css constructor
Class Phalcon\Assets\Asset\Js
Исходный код на GitHub
Namespace |
Phalcon\Assets\Asset |
|
Uses |
Phalcon\Assets\Asset |
|
Extends |
AssetBase |
Represents JavaScript assets
Методы
public function __construct( string $path, bool $local = bool, bool $filter = bool, array $attributes = [], string $version = null, bool $autoVersion = bool );
Phalcon\Assets\Asset\Js constructor
Interface Phalcon\Assets\AssetInterface
Исходный код на GitHub
Interface for custom Phalcon\Assets resources
Методы
public function getAssetKey(): string;
Gets the asset’s key.
public function getAttributes(): array | null;
Gets extra HTML attributes.
public function getFilter(): bool;
Gets if the asset must be filtered or not.
public function getType(): string;
Gets the asset’s type.
public function setAttributes( array $attributes ): AssetInterface;
Sets extra HTML attributes.
public function setFilter( bool $filter ): AssetInterface;
Sets if the asset must be filtered or not.
public function setType( string $type ): AssetInterface;
Sets the asset’s type.
Class Phalcon\Assets\Collection
Исходный код на GitHub
Namespace |
Phalcon\Assets |
|
Uses |
Countable, Iterator, Phalcon\Assets\Asset\Css, Phalcon\Assets\Asset\Js, Phalcon\Assets\Inline\Js, Phalcon\Assets\Inline\Css |
|
Implements |
Countable, Iterator |
Represents a collection of assets
Properties
/**
* @var array
*/
protected assets;
/**
* @var array
*/
protected attributes;
/**
* Should version be determined from file modification time
* @var bool
*/
protected autoVersion = false;
/**
* @var array
*/
protected codes;
/**
* @var array
*/
protected filters;
/**
* @var array
*/
protected includedAssets;
/**
* @var bool
*/
protected join = true;
/**
* @var bool
*/
protected local = true;
/**
* @var string
*/
protected prefix;
/**
* @var int
*/
protected position = 0;
/**
* @var string
*/
protected sourcePath;
/**
* @var bool
*/
protected targetLocal = true;
/**
* @var string
*/
protected targetPath;
/**
* @var string
*/
protected targetUri;
/**
* Version of resource
* @var string
*/
protected version;
Методы
public function __construct();
Phalcon\Assets\Collection constructor
public function add( AssetInterface $asset ): Collection;
Adds a asset to the collection
public function addCss( string $path, mixed $local = null, bool $filter = bool, mixed $attributes = null, string $version = null, bool $autoVersion = bool ): Collection;
Adds a CSS asset to the collection
public function addFilter( FilterInterface $filter ): Collection;
Adds a filter to the collection
public function addInline( Inline $code ): Collection;
Adds an inline code to the collection
public function addInlineCss( string $content, bool $filter = bool, mixed $attributes = null ): Collection;
Adds an inline CSS to the collection
public function addInlineJs( string $content, bool $filter = bool, mixed $attributes = null ): Collection;
Adds an inline JavaScript to the collection
public function addJs( string $path, mixed $local = null, bool $filter = bool, mixed $attributes = null, string $version = null, bool $autoVersion = bool ): Collection;
Adds a JavaScript asset to the collection
public function count(): int;
Returns the number of elements in the form
public function current(): Asset;
Returns the current asset in the iterator
public function getAssets(): array
public function getAttributes(): array
public function getCodes(): array
public function getFilters(): array
public function getJoin(): bool
public function getLocal(): bool
public function getPosition(): int
public function getPrefix(): string
public function getRealTargetPath( string $basePath ): string;
Returns the complete location where the joined/filtered collection must be written
public function getSourcePath(): string
public function getTargetLocal(): bool
public function getTargetPath(): string
public function getTargetUri(): string
public function getVersion(): string
public function has( AssetInterface $asset ): bool;
Checks this the asset is added to the collection.
use Phalcon\Assets\Asset;
use Phalcon\Assets\Collection;
$collection = new Collection();
$asset = new Asset("js", "js/jquery.js");
$collection->add($asset);
$collection->has($asset); // true
public function isAutoVersion(): bool;
Checks if collection is using auto version
public function join( bool $join ): Collection;
Sets if all filtered assets in the collection must be joined in a single result file
public function key(): int;
Returns the current position/key in the iterator
public function next(): void;
Moves the internal iteration pointer to the next position
public function rewind(): void;
Rewinds the internal iterator
public function setAttributes( array $attributes ): Collection;
Sets extra HTML attributes
public function setAutoVersion( bool $autoVersion )
public function setFilters( array $filters ): Collection;
Sets an array of filters in the collection
public function setLocal( bool $local ): Collection;
Sets if the collection uses local assets by default
public function setPrefix( string $prefix ): Collection;
Sets a common prefix for all the assets
public function setSourcePath( string $sourcePath ): Collection;
Sets a base source path for all the assets in this collection
public function setTargetLocal( bool $targetLocal ): Collection;
Sets the target local
public function setTargetPath( string $targetPath ): Collection;
Sets the target path of the file for the filtered/join output
public function setTargetUri( string $targetUri ): Collection;
Sets a target uri for the generated HTML
public function setVersion( string $version )
public function valid(): bool;
Check if the current element in the iterator is valid
final protected function addAsset( AssetInterface $asset ): bool;
Adds a asset or inline-code to the collection
Class Phalcon\Assets\Exception
Исходный код на GitHub
Namespace |
Phalcon\Assets |
|
Extends |
\Phalcon\Exception |
Exceptions thrown in Phalcon\Assets will use this class
Interface Phalcon\Assets\FilterInterface
Исходный код на GitHub
Interface for custom Phalcon\Assets filters
Методы
public function filter( string $content ): string;
Filters the content returning a string with the filtered content
Class Phalcon\Assets\Filters\Cssmin
Исходный код на GitHub
Namespace |
Phalcon\Assets\Filters |
|
Uses |
Phalcon\Assets\FilterInterface |
|
Implements |
FilterInterface |
Minify the CSS - removes comments removes newlines and line feeds keeping removes last semicolon from last property
Методы
public function filter( string $content ): string;
Filters the content using CSSMIN NOTE: This functionality is not currently available
Class Phalcon\Assets\Filters\Jsmin
Исходный код на GitHub
Namespace |
Phalcon\Assets\Filters |
|
Uses |
Phalcon\Assets\FilterInterface |
|
Implements |
FilterInterface |
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.
Методы
public function filter( string $content ): string;
Filters the content using JSMIN NOTE: This functionality is not currently available
Class Phalcon\Assets\Filters\None
Исходный код на GitHub
Namespace |
Phalcon\Assets\Filters |
|
Uses |
Phalcon\Assets\FilterInterface |
|
Implements |
FilterInterface |
Returns the content without make any modification to the original source
Методы
public function filter( string $content ): string;
Returns the content as is
Class Phalcon\Assets\Inline
Исходный код на GitHub
Namespace |
Phalcon\Assets |
|
Implements |
AssetInterface |
Represents an inline asset
$inline = new \Phalcon\Assets\Inline("js", "alert('hello world');");
Properties
/**
* @var array | null
*/
protected attributes;
/**
* @var string
*/
protected content;
/**
* @var bool
*/
protected filter;
/**
* @var string
*/
protected type;
Методы
public function __construct( string $type, string $content, bool $filter = bool, array $attributes = [] );
Phalcon\Assets\Inline constructor
public function getAssetKey(): string;
Gets the asset’s key.
public function getAttributes(): array | null
public function getContent(): string
public function getFilter(): bool
public function getType(): string
public function setAttributes( array $attributes ): AssetInterface;
Sets extra HTML attributes
public function setFilter( bool $filter ): AssetInterface;
Sets if the asset must be filtered or not
public function setType( string $type ): AssetInterface;
Sets the inline’s type
Class Phalcon\Assets\Inline\Css
Исходный код на GitHub
Namespace |
Phalcon\Assets\Inline |
|
Uses |
Phalcon\Assets\Inline |
|
Extends |
InlineBase |
Represents an inlined CSS
Методы
public function __construct( string $content, bool $filter = bool, mixed $attributes = null );
Phalcon\Assets\Inline\Css constructor
Class Phalcon\Assets\Inline\Js
Исходный код на GitHub
Namespace |
Phalcon\Assets\Inline |
|
Uses |
Phalcon\Assets\Inline |
|
Extends |
InlineBase |
Represents an inline JavaScript
Методы
public function __construct( string $content, bool $filter = bool, mixed $attributes = null );
Phalcon\Assets\Inline\Js constructor
Class Phalcon\Assets\Manager
Исходный код на GitHub
Namespace |
Phalcon\Assets |
|
Uses |
Phalcon\Tag, Phalcon\Assets\Asset\Js, Phalcon\Assets\Asset\Css, Phalcon\Assets\Inline\Css, Phalcon\Assets\Inline\Js, Phalcon\Di\DiInterface, Phalcon\Di\AbstractInjectionAware |
|
Extends |
AbstractInjectionAware |
Phalcon\Assets\Manager
Manages collections of CSS/JavaScript assets
Properties
//
protected collections;
/**
* Options configure
* @var array
*/
protected options;
/**
* @var bool
*/
protected implicitOutput = true;
Методы
public function __construct( array $options = [] );
Phalcon\Assets\Manager constructor
public function addAsset( Asset $asset ): Manager;
Adds a raw asset to the manager
$assets->addAsset(
new Phalcon\Assets\Asset("css", "css/style.css")
);
public function addAssetByType( string $type, Asset $asset ): Manager;
Adds a asset by its type
$assets->addAssetByType(
"css",
new \Phalcon\Assets\Asset\Css("css/style.css")
);
public function addCss( string $path, mixed $local = bool, bool $filter = bool, mixed $attributes = null, string $version = null, bool $autoVersion = bool ): Manager;
Adds a CSS asset to the ‘css’ collection
$assets->addCss("css/bootstrap.css");
$assets->addCss("http://bootstrap.my-cdn.com/style.css", false);
public function addInlineCode( Inline $code ): Manager;
Adds a raw inline code to the manager
public function addInlineCodeByType( string $type, Inline $code ): Manager;
Adds an inline code by its type
public function addInlineCss( string $content, mixed $filter = bool, mixed $attributes = null ): Manager;
Adds an inline CSS to the ‘css’ collection
public function addInlineJs( string $content, mixed $filter = bool, mixed $attributes = null ): Manager;
Adds an inline JavaScript to the ‘js’ collection
public function addJs( string $path, mixed $local = bool, bool $filter = bool, mixed $attributes = null, string $version = null, bool $autoVersion = bool ): Manager;
Adds a JavaScript asset to the ‘js’ collection
$assets->addJs("scripts/jquery.js");
$assets->addJs("http://jquery.my-cdn.com/jquery.js", false);
public function collection( string $name ): Collection;
Creates/Returns a collection of assets
public function collectionAssetsByType( array $assets, string $type ): array;
Creates/Returns a collection of assets by type
public function exists( string $id ): bool;
Returns true or false if collection exists.
if ($assets->exists("jsHeader")) {
// \Phalcon\Assets\Collection
$collection = $assets->get("jsHeader");
}
public function get( string $id ): Collection;
Returns a collection by its id.
$scripts = $assets->get("js");
public function getCollections(): Collection[];
Returns existing collections in the manager
public function getCss(): Collection;
Returns the CSS collection of assets
public function getJs(): Collection;
Returns the CSS collection of assets
public function getOptions(): array;
Returns the manager options
public function output( Collection $collection, mixed $callback, mixed $type ): string | null;
Traverses a collection calling the callback to generate its HTML
public function outputCss( string $collectionName = null ): string;
Prints the HTML for CSS assets
public function outputInline( Collection $collection, mixed $type ): string;
Traverses a collection and generate its HTML
public function outputInlineCss( string $collectionName = null ): string;
Prints the HTML for inline CSS
public function outputInlineJs( string $collectionName = null ): string;
Prints the HTML for inline JS
public function outputJs( string $collectionName = null ): string;
Prints the HTML for JS assets
public function set( string $id, Collection $collection ): Manager;
Sets a collection in the Assets Manager
$assets->set("js", $collection);
public function setOptions( array $options ): Manager;
Sets the manager options
public function useImplicitOutput( bool $implicitOutput ): Manager;
Sets if the HTML generated must be directly printed or returned