PHP Class M1\Vars\Vars

Since: 0.1.0
Inheritance: extends M1\Vars\Resource\AbstractResource, use trait M1\Vars\Traits\PathTrait, use trait M1\Vars\Traits\TransformerTrait
Mostrar archivo Open project: m1/Vars Class Usage Examples

Public Properties

Property Type Description
$cache M1\Vars\Cache\CacheProvider The cache object if the cache is wanted, else false
$loader M1\Vars\Loader\LoaderProvider The loaderProvider for Vars supplies the file loaders and the extensions that are supported
$variables M1\Vars\Variables\VariableProvider The variable provider

Public Methods

Method Description
__construct ( string | array $resource, array $options = [] ) Creates a new instance of Vars
addResource ( string $resource ) : integer Adds a resource to $this->resources
getCache ( ) : CacheProvider Returns the CacheProvider if set
getGlobals ( ) : array Returns the imported resources
getResource ( string $resource ) : FileResource | boolean Searches the resource stack for a certain resource
getResources ( ) : array Returns the imported resources
pathsLoadedCheck ( string $resource ) Checks if the base and cache paths have been set, if not\ set then will use the $resource as the base path
resourceImported ( FileResource | string $resource ) : boolean Tests to see if the resource has been imported already -- this is to avoid getting into a infinite loop
updateResource ( FileResource $resource, integer $pos ) : Vars Updates the string resource with the FileResource

Private Methods

Method Description
loadFromCache ( ) Loads the cached file into the current class
makeCache ( array $options, array | string $resource ) Makes the CacheProvider with the options
makeLoader ( array $options ) Makes the LoaderProvider with the options
makePaths ( array $options ) Sets the base path if the options have been set and the cache path if the cache path has not been set but the base path has
makeVariables ( array | null $options ) Sets the replacement variables if the option has been set
mergeGlobals ( array $content, array $options ) : array Gets the _globals from the file and merges them if merge_globals is true
parseOptions ( array $options ) : array Parses the options so Vars can use them

Method Details

__construct() public method

Creates a new instance of Vars
public __construct ( string | array $resource, array $options = [] )
$resource string | array The main configuration resource
$options array The options being used for Vars

addResource() public method

Adds a resource to $this->resources
public addResource ( string $resource ) : integer
$resource string Resource to add to the stack
return integer The position of the added resource

getCache() public method

Returns the CacheProvider if set
public getCache ( ) : CacheProvider
return M1\Vars\Cache\CacheProvider The CacheProvider

getGlobals() public method

Returns the imported resources
public getGlobals ( ) : array
return array The Vars imported resources

getResource() public method

Searches the resource stack for a certain resource
public getResource ( string $resource ) : FileResource | boolean
$resource string The resource to search for
return M1\Vars\Resource\FileResource | boolean Returns the resource if found

getResources() public method

Returns the imported resources
public getResources ( ) : array
return array The Vars imported resources

pathsLoadedCheck() public method

Checks if the base and cache paths have been set, if not\ set then will use the $resource as the base path
public pathsLoadedCheck ( string $resource )
$resource string The resource to use to set the paths if they haven't been set

resourceImported() public method

Tests to see if the resource has been imported already -- this is to avoid getting into a infinite loop
public resourceImported ( FileResource | string $resource ) : boolean
$resource M1\Vars\Resource\FileResource | string Resource to check
return boolean Has resource already been imported

updateResource() public method

Updates the string resource with the FileResource
public updateResource ( FileResource $resource, integer $pos ) : Vars
$resource M1\Vars\Resource\FileResource The FileResource to add
$pos integer The position of the string resource
return Vars

Property Details

$cache public_oe property

The cache object if the cache is wanted, else false
public CacheProvider,M1\Vars\Cache $cache
return M1\Vars\Cache\CacheProvider

$loader public_oe property

The loaderProvider for Vars supplies the file loaders and the extensions that are supported
public LoaderProvider,M1\Vars\Loader $loader
return M1\Vars\Loader\LoaderProvider

$variables public_oe property

The variable provider
public VariableProvider,M1\Vars\Variables $variables
return M1\Vars\Variables\VariableProvider