\Phabstractic\Data\Types\ResourceAbstractLeaf

Abstract Leaf Class - Defines A Leaf/Branch Structure

This implements LeafInterface, but adds an identity variable

It leaves data handling to the child class.

CHANGELOG

1.0: Created Module - February 7th, 2014 1.1: Repurposed to Leaf - February 9th, 2014 Documented Leaf - February 21st, 2014 2.0: Incorporated AbstractLeaf into Primus - August 26th, 2015 3.0: removed data methods removed RestrictedList, implemented using basic array reformatted for inclusion in phabstractic - August 1st, 2016

Summary

Methods
Properties
Constants
configure()
saveSettings()
getSettings()
processSettings()
getLeafIdentifier()
setLeafIdentifier()
__construct()
getLeaves()
addLeaf()
removeLeaf()
isLeaf()
__debugInfo()
No public properties found
No constants found
No protected methods found
$conf
$leaves
N/A
No private methods found
No private properties found
N/A

Properties

$conf

$conf : \Phabstractic\Features\Zend\Config\Config

The objects configuration object

Should be an instance of Zend/Config

Type

\Phabstractic\Features\Zend\Config\Config — The object configuration info

$leaves

$leaves : \Phabstractic\Data\Types\Resource\Falcraft\Data\Types\RestrictedList

The collection of leaves this leaf is connected to

This uses the leave's identifiers as keys

Type

\Phabstractic\Data\Types\Resource\Falcraft\Data\Types\RestrictedList — (Falcraft\Data\Types\Tree\LeafInterface)

Methods

configure()

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.

Parameters

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.

Returns

boolean —

True if instantiated

saveSettings()

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.

Parameters

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()

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()-

Parameters

string $format

The format to return, must be supported by ::saveSettings(), use $this->configWriters to support additional formats.

$context

Returns

string|boolean —

The formatted string, or false otherwise

processSettings()

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.

Parameters

\Phabstractic\Features\Zend\Config\Processor\ProcessorInterface $processor

The given processor object

getLeafIdentifier()

getLeafIdentifier() : string

Get this particular leaf's identifier

Returns

string

setLeafIdentifier()

setLeafIdentifier(  $newIdentifier) 

Set this particular leaf's identifier

Parameters

$newIdentifier

__construct()

__construct(array  $leaves = array(), array  $options = array()) 

The Leaf Constructor

This accepts an array of leaves (LeafInterface)

Options - strict: throw errors

Parameters

array $leaves

A plain array of LeafInterface compatible objects

array $options

An array of options, as keys (see above)

getLeaves()

getLeaves() : array

Get a plain array of the leaves contained by this leaf

Returns

array —

The connected leaves

addLeaf()

addLeaf(\Phabstractic\Data\Types\Resource\Phabstractic\Data\Type\Resource\LeafInterface  $leaf) : string

Add a leaf to the set of leaves this leaf is connected to

Parameters

\Phabstractic\Data\Types\Resource\Phabstractic\Data\Type\Resource\LeafInterface $leaf

The leaf to connect

Returns

string —

The new leaf's local identity

removeLeaf()

removeLeaf(\Phabstractic\Data\Types\Resource\Phabstractic\Data\Type\Resource\LeafInterface  $leaf) : boolean

Remove a leaf

Parameters

\Phabstractic\Data\Types\Resource\Phabstractic\Data\Type\Resource\LeafInterface $leaf

The leaf to remove

Returns

boolean

isLeaf()

isLeaf(\Phabstractic\Data\Types\Resource\Phabstractic\Data\Type\Resource\LeafInterface  $leaf) : string

Does this leaf have the identifier for another leaf?

Parameters

\Phabstractic\Data\Types\Resource\Phabstractic\Data\Type\Resource\LeafInterface $leaf

The leaf to find

Returns

string

__debugInfo()

__debugInfo() 

Debug Info (var_dump)

Display debug info

Requires PHP 5.6+