Class Phalcon\Assets\Asset
Código fuente en GitHub
Namespace |
Phalcon\Assets |
|
Implements |
AssetInterface |
Represents an asset
$asset = new \Phalcon\Assets\Asset("js", "js/jquery.js");
Propiedades
/**
* @var array
*/
protected attributes;
/**
* @var bool
*/
protected isAutoVersion = false;
/**
* @var bool
*/
protected filter;
/**
* @var bool
*/
protected isLocal;
/**
* @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|null
*/
protected version;
Métodos
public function __construct( string $type, string $path, bool $isLocal = bool, bool $filter = bool, array $attributes = [], string $version = null, bool $isAutoVersion = bool );
Asset constructor.
public function getAssetKey(): string;
Obtiene la clave del recurso.
public function getAttributes(): array;
Obtiene los atributos HTML extra.
public function getContent( string $basePath = null ): string;
Devuelve el contenido del recurso como una cadena Opcionalmente se puede establecer una ruta base donde localizar el recurso
public function getFilter(): bool;
public function getPath(): string;
public function getRealSourcePath( string $basePath = null ): string;
Devuelve la ubicación completa donde se localiza el recurso
public function getRealTargetPath( string $basePath = null ): string;
Devuelve la ubicación completa donde se debe escribir el recurso
public function getRealTargetUri(): string;
Devuelve la uri destino real para el HTML generado
public function getSourcePath(): string;
public function getTargetPath(): string;
public function getTargetUri(): string;
public function getType(): string;
public function getVersion(): string | null;
Version of resource
public function isAutoVersion(): bool;
Checks if the asset is using auto version
public function isLocal(): bool;
Checks if the asset is local or not
public function setAttributes( array $attributes ): AssetInterface;
Establece atributos HTML extra
public function setAutoVersion( bool $flag ): AssetInterface;
public function setFilter( bool $filter ): AssetInterface;
Establece si el recurso se debe filtrar o no
public function setIsLocal( bool $flag ): AssetInterface;
Establece si el recurso es local o externo
public function setPath( string $path ): AssetInterface;
Establece la ruta del recurso
public function setSourcePath( string $sourcePath ): AssetInterface;
Establece la ruta origen del recurso
public function setTargetPath( string $targetPath ): AssetInterface;
Establece la ruta destino del recurso
public function setTargetUri( string $targetUri ): AssetInterface;
Establece una uri destino para el HTML generado
public function setType( string $type ): AssetInterface;
Establece el tipo de recurso
public function setVersion( string $version ): AssetInterface;
Sets the asset’s version
protected function phpFileExists( string $filename ): bool;
@todo to be removed when we get traits
protected function phpFileGetContents( string $filename );
Class Phalcon\Assets\Asset\Css
Código fuente en GitHub
Namespace |
Phalcon\Assets\Asset |
|
Uses |
Phalcon\Assets\Asset |
|
Extends |
AssetBase |
Representa recursos CSS
Métodos
public function __construct( string $path, bool $local = bool, bool $filter = bool, array $attributes = [], string $version = null, bool $autoVersion = bool );
Constructor Phalcon\Assets\Asset\Css
Class Phalcon\Assets\Asset\Js
Código fuente en GitHub
Namespace |
Phalcon\Assets\Asset |
|
Uses |
Phalcon\Assets\Asset |
|
Extends |
AssetBase |
Representa recursos JavaScript
Métodos
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
Código fuente en GitHub
Interfaz para recursos Phalcon\Assets personalizados
Métodos
public function getAssetKey(): string;
Obtiene la clave del recurso.
public function getAttributes(): array | null;
Obtiene los atributos HTML extra.
public function getFilter(): bool;
Obtiene si el recurso se debe filtrar o no.
public function getType(): string;
Obtiene el tipo de recurso.
public function setAttributes( array $attributes ): AssetInterface;
Establece los atributos HTML extra.
public function setFilter( bool $filter ): AssetInterface;
Establece si el recurso se debe filtrar o no.
public function setType( string $type ): AssetInterface;
Establece el tipo de recurso.
Class Phalcon\Assets\Collection
Código fuente en GitHub
Namespace |
Phalcon\Assets |
|
Uses |
ArrayIterator, Countable, IteratorAggregate |
|
Implements |
Countable, IteratorAggregate |
Collection of asset objects
Propiedades
/**
* @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 bool
*/
protected isLocal = true;
/**
* @var bool
*/
protected join = true;
/**
* @var string
*/
protected prefix = ;
/**
* @var string
*/
protected sourcePath = ;
/**
* @var bool
*/
protected targetIsLocal = true;
/**
* @var string
*/
protected targetPath = ;
/**
* @var string
*/
protected targetUri = ;
/**
* @var string
*/
protected version = ;
Métodos
public function add( AssetInterface $asset ): Collection;
Adds an asset to the collection
public function addCss( string $path, mixed $isLocal = null, bool $filter = bool, array $attributes = [], string $version = null, bool $autoVersion = bool ): Collection;
Añade un recurso CSS a la colección
public function addFilter( FilterInterface $filter ): Collection;
Añade un filtro a la colección
public function addInline( Inline $code ): Collection;
Añade un código en línea a la colección
public function addInlineCss( string $content, bool $filter = bool, array $attributes = [] ): Collection;
Añade un CSS en línea a la colección
public function addInlineJs( string $content, bool $filter = bool, array $attributes = [] ): Collection;
Añade un JavaScript en línea a la colección
public function addJs( string $path, mixed $isLocal = null, bool $filter = bool, array $attributes = [], string $version = null, bool $autoVersion = bool ): Collection;
Añade un recurso JavaScript a la colección
public function count(): int;
Return the count of the assets
public function getAssets(): array;
public function getAttributes(): array;
public function getCodes(): array;
public function getFilters(): array;
public function getIterator(): \Traversable;
Returns the generator of the class
@link https://php.net/manual/en/iteratoraggregate.getiterator.php
public function getJoin(): bool;
public function getPrefix(): string;
public function getRealTargetPath( string $basePath ): string;
Devuelve la ubicación completa donde la colección unida/filtrada se debe escribir
public function getSourcePath(): string;
public function getTargetIsLocal(): bool;
public function getTargetPath(): string;
public function getTargetUri(): string;
public function getVersion(): string;
public function has( AssetInterface $asset ): bool;
Comprueba si este recurso está añadido a la colección.
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;
Comprueba si la colección está usando versión automática
public function isLocal(): bool;
public function join( bool $flag ): Collection;
Establece si todos los recursos filtrados de la colección se deben unir en un sólo fichero resultante
public function setAttributes( array $attributes ): Collection;
Establece atributos HTML extra
public function setAutoVersion( bool $flag ): Collection;
public function setFilters( array $filters ): Collection;
Establece un vector de filtros en la colección
public function setIsLocal( bool $flag ): Collection;
Establece si la colección usa recursos locales por defecto
public function setPrefix( string $prefix ): Collection;
Establece un prefijo común para todos los recursos
public function setSourcePath( string $sourcePath ): Collection;
Establece una ruta de origen base para todos los recursos de esta colección
public function setTargetIsLocal( bool $flag ): Collection;
Sets if the target local or not
public function setTargetPath( string $targetPath ): Collection;
Establece la ruta destino del fichero para la salida filtrada/unida
public function setTargetUri( string $targetUri ): Collection;
Establece una uri destino para el HTML generado
public function setVersion( string $version ): Collection;
Sets the version
final protected function addAsset( AssetInterface $asset ): bool;
Adds an asset or inline-code to the collection
Class Phalcon\Assets\Exception
Código fuente en GitHub
Namespace |
Phalcon\Assets |
|
Extends |
\Exception |
Las excepciones lanzadas en Phalcon\Assets usarán esta clase
Interface Phalcon\Assets\FilterInterface
Código fuente en GitHub
Interfaz para filtros de Phalcon\Assets personalizados
Métodos
public function filter( string $content ): string;
Filtran el contenido devolviendo una cadena con el contenido filtrado
Class Phalcon\Assets\Filters\Cssmin
Código fuente en GitHub
Namespace |
Phalcon\Assets\Filters |
|
Uses |
Phalcon\Assets\FilterInterface |
|
Implements |
FilterInterface |
Minimiza el CSS - elimina comentarios, elimina las líneas nuevas y los avances de línea que se mantienen, elimina el punto y coma de la última propiedad
Métodos
public function filter( string $content ): string;
Filters the content using CSSMIN
NOTE: This functionality is not currently available
Class Phalcon\Assets\Filters\Jsmin
Código fuente en GitHub
Namespace |
Phalcon\Assets\Filters |
|
Uses |
Phalcon\Assets\FilterInterface |
|
Implements |
FilterInterface |
Elimina los caracteres que son insignificantes para JavaScript. Se eliminarán los comentarios. Las tabulaciones se reemplazarán con espacios. Los retornos de carro se reemplazarán con saltos de línea. La mayoría de saltos de línea y espacios se eliminarán.
Métodos
public function filter( string $content ): string;
Filters the content using JSMIN
NOTE: This functionality is not currently available
Class Phalcon\Assets\Filters\None
Código fuente en GitHub
Namespace |
Phalcon\Assets\Filters |
|
Uses |
Phalcon\Assets\FilterInterface |
|
Implements |
FilterInterface |
Devuelve el contenido sin hacer ninguna modificación sobre la fuente original
Métodos
public function filter( string $content ): string;
Devuelve el contenido tal cual
Class Phalcon\Assets\Inline
Código fuente en GitHub
Namespace |
Phalcon\Assets |
|
Implements |
AssetInterface |
Representa un recurso en línea
$inline = new \Phalcon\Assets\Inline("js", "alert('hello world');");
Propiedades
/**
* @var array
*/
protected attributes;
/**
* @var string
*/
protected content;
/**
* @var bool
*/
protected filter;
/**
* @var string
*/
protected type;
Métodos
public function __construct( string $type, string $content, bool $filter = bool, array $attributes = [] );
Constructor Phalcon\Assets\Inline
public function getAssetKey(): string;
Obtiene la clave del recurso.
public function getAttributes(): array;
public function getContent(): string;
public function getFilter(): bool;
public function getType(): string;
public function setAttributes( array $attributes ): AssetInterface;
Establece atributos HTML extra
public function setFilter( bool $filter ): AssetInterface;
Establece si el recurso se debe filtrar o no
public function setType( string $type ): AssetInterface;
Establece el tipo en línea
Class Phalcon\Assets\Inline\Css
Código fuente en GitHub
Namespace |
Phalcon\Assets\Inline |
|
Uses |
Phalcon\Assets\Inline |
|
Extends |
InlineBase |
Representa un CSS en línea
Métodos
public function __construct( string $content, bool $filter = bool, array $attributes = [] );
Constructor Phalcon\Assets\Inline\Css
Class Phalcon\Assets\Inline\Js
Código fuente en GitHub
Namespace |
Phalcon\Assets\Inline |
|
Uses |
Phalcon\Assets\Inline |
|
Extends |
InlineBase |
Representa un JavaScript en línea
Métodos
public function __construct( string $content, bool $filter = bool, array $attributes = [] );
Constructor Phalcon\Assets\Inline\Js
Class Phalcon\Assets\Manager
Código fuente en GitHub
Namespace |
Phalcon\Assets |
|
Uses |
Phalcon\Assets\Asset\Css, Phalcon\Assets\Asset\Js, Phalcon\Assets\Inline\Css, Phalcon\Assets\Inline\Js, Phalcon\Di\AbstractInjectionAware, Phalcon\Html\Helper\Element, Phalcon\Html\Helper\Link, Phalcon\Html\Helper\Script, Phalcon\Html\TagFactory |
|
Extends |
AbstractInjectionAware |
Gestiona colecciones de recursos CSS/JavaScript
Propiedades
/**
* @var array
*/
protected collections;
/**
* @var bool
*/
protected implicitOutput = true;
/**
* @var array
*/
protected options;
/**
* @var TagFactory
*/
protected tagFactory;
Métodos
public function __construct( TagFactory $tagFactory, array $options = [] );
Constructor del gestor.
public function addAsset( Asset $asset ): Manager;
Añade un recurso en bruto al gestor
public function addAssetByType( string $type, Asset $asset ): Manager;
Añade un recurso por su tipo
public function addCss( string $path, bool $local = bool, bool $filter = bool, array $attributes = [], string $version = null, bool $autoVersion = bool ): Manager;
Añade un recurso CSS a la colección ‘css’
public function addInlineCode( Inline $code ): Manager;
Añade un código en línea en bruto al gestor
public function addInlineCodeByType( string $type, Inline $code ): Manager;
Añade un código en línea por su tipo
public function addInlineCss( string $content, bool $filter = bool, array $attributes = [] ): Manager;
Añade un CSS en línea a la colección ‘css’
public function addInlineJs( string $content, bool $filter = bool, array $attributes = [] ): Manager;
Añade un JavaScript en línea a la colección ‘js’
public function addJs( string $path, bool $local = bool, bool $filter = bool, array $attributes = [], string $version = null, bool $autoVersion = bool ): Manager;
Añade un recurso JavaScript a la colección ‘js’
$assets->addJs("scripts/jquery.js");
$assets->addJs("http://jquery.my-cdn.com/jquery.js", false);
public function collection( string $name ): Collection;
Crea/Devuelve una colección de recursos
public function collectionAssetsByType( array $assets, string $type ): array;
Crea/Devuelve una colección de recursos por tipo
public function exists( string $name ): bool;
Devuelve true
o false
si existe la colección.
if ($manager->exists("jsHeader")) {
// \Phalcon\Assets\Collection
$collection = $manager->get("jsHeader");
}
public function get( string $name ): Collection;
Devuelve una colección por su id.
$scripts = $assets->get("js");
public function getCollections(): Collection[];
Devuelve las colecciones existentes en el gestor
public function getCss(): Collection;
Devuelve la colección de recursos JavaScript
public function getJs(): Collection;
Devuelve la colección de recursos JavaScript
public function getOptions(): array;
Devuelve las opciones del gestor
public function has( string $name ): bool;
Devuelve true
o false
si existe la colección.
if ($manager->has("jsHeader")) {
// \Phalcon\Assets\Collection
$collection = $manager->get("jsHeader");
}
public function output( Collection $collection, string $type ): string | null;
Recorre una colección llamando a la función de retorno para generar su HTML
public function outputCss( string $name = null ): string;
Imprime el HTML para los recursos CSS
public function outputInline( Collection $collection, mixed $type ): string;
Recorre una colección y genera su HTML
public function outputInlineCss( string $name = null ): string;
Imprime el HTML para CSS en línea
public function outputInlineJs( string $name = null ): string;
Imprime el HTML para JS en línea
public function outputJs( string $name = null ): string;
Imprime el HTML para recursos JS
public function set( string $name, Collection $collection ): Manager;
Establece una colección en el Gestor de Recursos
$assets->set("js", $collection);
public function setOptions( array $options ): Manager;
Establece las opciones del gestor
public function useImplicitOutput( bool $implicitOutput ): Manager;
Establece si el HTML generado debe ser impreso directamente o devuelto