$conf
$conf : \Phabstractic\Features\Zend\Config\Config
The objects configuration object
Should be an instance of Zend/Config
Path Class - Defines A Path Structure
A path consists of a directory, a file, and a file extension. This class keeps track of the directory path, and the assigned or acceptable extensions allowed by the path. It offers a function to test if a file is found in the path given the allowed extensions
CHANGELOG
1.0: Created Path - January 30th, 2014 2.0: Integrated Path for Primus 2 - October 20th, 2015 3.0: removed restrictedset for extensions removed identity methods removed automatic php extension addition reformatted for inclusion in phabstractic - August 1st, 2016
configure(array|string|\Phabstractic\Features\Zend\Config\Config $configuration, string $format = null, mixed $context = null) : boolean
Configure An Object
Expects an array for configuration however, you can also pass it a filepath where it will read the information from a file automatically detecting the format using the file extension. You can also pass a Zend/Config object already made.
You can also pass a format specifier (forced format) for use in a if $configuration is a string formatted with such information. E.G. to load from a string in the format ini:
$this->configure($configString, 'ini');
The $context argument is used for any additional reader constructor information, such as the constructor for the 'yaml' format.
NOTE: You can override/extend the classes used for reading formats by identifying an additional array in the property $this->configReaders. This will merge with the standard formats array.
array|string|\Phabstractic\Features\Zend\Config\Config | $configuration | The objects configuration information. |
string | $format | The forced format, or format for configuration string |
mixed | $context | Any additional information for a reader constructor, such as needed for the YAML format. |
True if instantiated
saveSettings(string $file, \Phabstractic\Features\Zend\Config\Writer\WriterInterface $writer = null, boolean $exclusive = true, mixed $context = null)
Save an Object's Configuration to a File
Takes an objects $conf property and writes the information contained therein to a file with a format automatically specified by the filename.
It is possible to retrieve a string of a particular format from this method by specifying the filename '#string' with an extension indicating the desired format, such as '#string.json'.
The $context argument is used for any additional reader constructor information, such as the constructor for the 'yaml' format.
NOTE: You can override/extend the classes used for writing formats by identifying an additional array in the property $this->configWriters. This will merge with the standard formats array.
string | $file | The file path to write to, or '#string.ext' |
\Phabstractic\Features\Zend\Config\Writer\WriterInterface | $writer | The optional writer object supplied to use (such as a MySQL writer) |
boolean | $exclusive | Argument provided to toFile(), file exclusive lock when writing |
mixed | $context | Any additionla writer constructor information (YAML) |
getSettings(string $format, $context = null) : string|boolean
Retrieve an Object's Configuration Information As String
This is a shortcut to ::saveSettings() which specifies a format and forces the return of a string, using the #string.ext filename -see documentation for ::saveSettings()-
string | $format | The format to return, must be supported by ::saveSettings(), use $this->configWriters to support additional formats. |
$context |
The formatted string, or false otherwise
processSettings(\Phabstractic\Features\Zend\Config\Processor\ProcessorInterface $processor)
Process an Object's Configuration
This uses a Zend\Config\Processor implementation to process the configuration information, such as constants. The processor must be supplied and implement ProcessorInterface
NOTE: Edits the $conf object in place.
\Phabstractic\Features\Zend\Config\Processor\ProcessorInterface | $processor | The given processor object |
__construct( $path = '', array $extensions = array(), array $options = array())
Path Construction
This constructs the path from the required variable. If an identifier is not provided a unique identifier is assigned to the path.
Paths have trailing slashes '/' removed, extensions have the FIRST period removed from them, so '.some.extension' becomes 'some.extension'.
Options: strict - should we throw errors? check - Check to make sure a path (directory) exists suppress_warnings - Suppress error warnings on file_exists identity_prefix - the prefix to use when creating this link
$path | ||
array | $extensions | |
array | $options |
setPath( $path) : \Phabstractic\Data\Components\Phabstractic\Data\Components\Path
Assign the path
NOTE: This should be a directory, NOT a file
If option Check has been specified we see if the directory actually exists.
$path |
Path does not exist (only thrown if Check option is set)
$this for chaining
addExtension( $extensions) : \Phabstractic\Data\Components\Phabstractic\Data\Components\Path
Add an allowed extension
This puts a extension or array of extensions into the list of allowed and looked for extensions when a filename is supplied to the path.
NOTE: Extensions preceding periods (the first only) are removed. '.some.extension' becomes 'some.extension'
$extensions |
$this for chaining
isFilename( $filename, $basePath = '', $reqExtension = '') : string|null
Find a particular filename in the path
This method returns a filename (or '' on failure) when a given filename is found in the path with an acceptable extension.
NOTE: Do not pass the required extension in $filename Use $reqExtension instead.
$filename | ||
$basePath | ||
$reqExtension |
The full path with extension, or null on failure