PHP Class MiniAsset\AssetConfig

Afficher le fichier Open project: markstory/mini-asset Class Usage Examples

Protected Properties

Свойство Type Description
$_data array Parsed configuration data.
$_defaults array These defaults are used unless a key is redefined.
$_extensionTypes array handle.
$_filters array Filter configuration
$_modifiedTime integer The max modified time of all the config files loaded.
$_targets array Target configuration
$constantMap array A hash of constants that can be expanded when reading ini files.

Méthodes publiques

Méthode Description
__construct ( array $data = [], array $constants = [] ) Constructor, set some initial data for a AssetConfig object.
addExtension ( string $ext, array $config ) : void Add/Replace an extension configuration.
addTarget ( string $target, array $config ) Create a new build target.
allFilters ( ) : array Get configuration for all filters.
buildFromIniFile ( string $iniFile = null, $constants = [] ) Factory method
cachePath ( string $ext, string $path = null ) Accessor for getting the cachePath for a given extension.
constants ( ) : array Get the list of loaded constants.
extensions ( ) : array Get the list of extensions this config object supports.
files ( string $target ) : array Get the list of files that match the given build file.
filterConfig ( string $filter, array $settings = null ) : mixed. Get/Set filter Settings.
filters ( string $ext, array $filters = null ) : array Get/set filters for an extension
general ( string $key, mixed $value = null ) : mixed Get / set values from the General section. This is preferred to using get()/set() as you don't run the risk of making a mistake in General's casing.
get ( string $path ) Get values from the config data.
getExt ( string $file ) : string Get the extension for a filename.
hasTarget ( string $name ) : boolean Check if the named target exists.
isThemed ( string $target ) : boolean Check if a build target is themed.
load ( string $path, string $prefix = '' ) Load a config file into the current instance.
modifiedTime ( ) : integer Get the modified time of the loaded configuration files.
paths ( string $ext, string $target = null, array $paths = null ) : array Get/set paths for an extension. Setting paths will replace global or per target existing paths. Its only intended for testing.
requires ( string $target ) : array Get the required build targets for this target.
set ( string $path, string $value ) Set values into the config object, You can't modify targets, or filters with this. Use the appropriate methods for those settings.
targetFilters ( string $name ) : array Get the filters for a build target.
targets ( ) : array Get the build targets.
theme ( string $theme = null ) : mixed Set the active theme for building assets.

Méthodes protégées

Méthode Description
_addConstants ( array $constants ) : void Add path based constants to the mapped constants.
_parseExtensionDef ( $target ) : array Parses paths in an extension definition
_replacePathConstants ( string $path ) : string Replaces the file path constants used in Config files.
readConfig ( string $filename ) : array Read the configuration file from disk
resolveExtends ( ) : void Once all targets have been built, resolve extend options.

Method Details

__construct() public méthode

Any userland constants that resolve to file paths will automatically be added to the constants available in configuration files.
public __construct ( array $data = [], array $constants = [] )
$data array Initial data set for the object.
$constants array Additional constants that will be translated when parsing paths.

_addConstants() protected méthode

Add path based constants to the mapped constants.
protected _addConstants ( array $constants ) : void
$constants array The constants to map
Résultat void

_parseExtensionDef() protected méthode

Parses paths in an extension definition
protected _parseExtensionDef ( $target ) : array
Résultat array Array of build extension information with paths replaced.

_replacePathConstants() protected méthode

Will replace APP and WEBROOT
protected _replacePathConstants ( string $path ) : string
$path string Path to replace constants on
Résultat string constants replaced

addExtension() public méthode

Add/Replace an extension configuration.
public addExtension ( string $ext, array $config ) : void
$ext string Extension name
$config array Configuration for the extension
Résultat void

addTarget() public méthode

Create a new build target.
public addTarget ( string $target, array $config )
$target string Name of the target file. The extension will be inferred based on the last extension.
$config array Config data for the target. Should contain files, filters and theme key.

allFilters() public méthode

Useful for building FilterRegistry objects
public allFilters ( ) : array
Résultat array Config data related to all filters.

buildFromIniFile() public static méthode

Factory method
Deprecation: Use ConfigFinder::loadAll() instead.
public static buildFromIniFile ( string $iniFile = null, $constants = [] )
$iniFile string File path for the ini file to parse.

cachePath() public méthode

Accessor for getting the cachePath for a given extension.
public cachePath ( string $ext, string $path = null )
$ext string Extension to get paths for.
$path string The path to cache files using $ext to.

constants() public méthode

Get the list of loaded constants.
public constants ( ) : array
Résultat array

extensions() public méthode

Get the list of extensions this config object supports.
public extensions ( ) : array
Résultat array Extension list.

files() public méthode

Get the list of files that match the given build file.
public files ( string $target ) : array
$target string The build file with extension.
Résultat array An array of files for the chosen build.

filterConfig() public méthode

Get/Set filter Settings.
public filterConfig ( string $filter, array $settings = null ) : mixed.
$filter string The filter name
$settings array The settings to set, leave null to get
Résultat mixed.

filters() public méthode

Get/set filters for an extension
public filters ( string $ext, array $filters = null ) : array
$ext string Name of an extension
$filters array Filters to replace either the global or per target filters.
Résultat array Filters for extension.

general() public méthode

Get / set values from the General section. This is preferred to using get()/set() as you don't run the risk of making a mistake in General's casing.
public general ( string $key, mixed $value = null ) : mixed
$key string The key to read/write
$value mixed The value to set.
Résultat mixed Null when writing. Either a value or null when reading.

get() public méthode

Get values from the config data.
public get ( string $path )
$path string The path you want.

getExt() public méthode

Get the extension for a filename.
public getExt ( string $file ) : string
$file string
Résultat string

hasTarget() public méthode

Check if the named target exists.
public hasTarget ( string $name ) : boolean
$name string The name of the target to check.
Résultat boolean

isThemed() public méthode

Check if a build target is themed.
public isThemed ( string $target ) : boolean
$target string A build target.
Résultat boolean

load() public méthode

Load a config file into the current instance.
public load ( string $path, string $prefix = '' )
$path string The config file to load.
$prefix string The string to prefix all targets in $path with.

modifiedTime() public méthode

Get the modified time of the loaded configuration files.
public modifiedTime ( ) : integer
Résultat integer

paths() public méthode

Get/set paths for an extension. Setting paths will replace global or per target existing paths. Its only intended for testing.
public paths ( string $ext, string $target = null, array $paths = null ) : array
$ext string Extension to get paths for.
$target string A build target. If provided the target's paths (if any) will also be returned.
$paths array Paths to replace either the global or per target paths.
Résultat array An array of paths to search for assets on.

readConfig() protected méthode

Read the configuration file from disk
protected readConfig ( string $filename ) : array
$filename string Name of the inifile to parse
Résultat array Inifile contents

requires() public méthode

Required builds differ from extends in that the compiled asset is merged into the named target. In extends, the source files & filter for an asset are merged into a target.
public requires ( string $target ) : array
$target string The target to get requirements for.
Résultat array A list of required builds.

resolveExtends() protected méthode

Once all targets have been built, resolve extend options.
protected resolveExtends ( ) : void
Résultat void

set() public méthode

Set values into the config object, You can't modify targets, or filters with this. Use the appropriate methods for those settings.
public set ( string $path, string $value )
$path string The path to set.
$value string The value to set.

targetFilters() public méthode

Get the filters for a build target.
public targetFilters ( string $name ) : array
$name string The build target to get filters for.
Résultat array

targets() public méthode

Get the build targets.
public targets ( ) : array
Résultat array An array of build targets.

theme() public méthode

Set the active theme for building assets.
public theme ( string $theme = null ) : mixed
$theme string The theme name to set. Null to get
Résultat mixed Either null on set, or theme on get

Property Details

$_data protected_oe property

Parsed configuration data.
protected array $_data
Résultat array

$_defaults protected_oe static_oe property

These defaults are used unless a key is redefined.
protected static array $_defaults
Résultat array

$_extensionTypes protected_oe static_oe property

handle.
protected static array $_extensionTypes
Résultat array

$_filters protected_oe property

Filter configuration
protected array $_filters
Résultat array

$_modifiedTime protected_oe property

The max modified time of all the config files loaded.
protected int $_modifiedTime
Résultat integer

$_targets protected_oe property

Target configuration
protected array $_targets
Résultat array

$constantMap protected_oe property

A hash of constants that can be expanded when reading ini files.
protected array $constantMap
Résultat array