$conf
$conf : \Phabstractic\Features\Zend\Config\Config
The objects configuration object
Should be an instance of Zend/Config
Prototype Class - Defines a JavaScript Like Prototype
In order for a prototype to work in the hierarchy correctly, we must chain prototype objects together using __parent. If you don't use a base prototype object, you must use something with an interface that will be compatible. It is thus necessary to always use new Prototype(), ::fromRegistry($key), ::fromPrototype($prototype).
You can register prototypes into a 'global' registry using a strings. If you 'add' a registry entry with the same key, the old entry is overwritten.
CHANGELOG
1.0: Created Prototype - November, 23th, 2015 2.0: eliminated map for registry, made it swappable eliminated local static methods reformatted for inclusion in phabstractic - August 4th, 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 |
addToRegistry(\Phabstractic\Patterns\Falcraft\Patterns\Prototype $prototype, mixed $key = '') : \Phabstractic\Patterns\result
Add a value to the map with a key that previously did not exist
\Phabstractic\Patterns\Falcraft\Patterns\Prototype | $prototype | |
mixed | $key |
of setting operation
__construct(array $options = array())
The Prototype Constructor
The constructor itself establishes the options that a particular prototype might have. If you wish to change a prototype's configuration call $prototype->configure($options) You can pass an array, or a a Zend Conf object.
The key/value pair is constructed according to the array elements data type.
Currently available options: strict => whether to output errors or remain silent
array | $options | The options for the Map as outlined above |
__call(string $name, array $arguments) : mixed
Magical Call Function
This uses call_user_func_array to call the closures set in the object. It overrides the error handling temporarily so that it can catch warnings about non-existing properties. If it can't find a property, it looks up the __parent chain to see if it can resolve.
If it can't find anything, it reports an error.
It's important that at the end that it deregisters its handler for normal function
NOTE: This catches a specific RunTime Exception instance, and should pass all others... hopefully.
string | $name | of desired function |
array | $arguments | of desired function |
Result of user function
__get( $var) : mixed
Magical Get Function
This one is simpler than the magical call function. This simply searches up the __parent chain looking for a property until it runs out of parents.
NOTE: This is useful because it will also return the function objects associated with a key (closures) if you want access to the closure itself.
$var | name of variable |