EQUAL
EQUAL
Return Data Equal To Given Urgency Index?
The Handler Priority Queue Class
This class lines up Handlers in a line of priority. It then is able to propagate an event down the handlers 'chain'.
CHANGELOG
1.0: Created Handler Priority Queue - August 16th, 2013 1.1: Eliminated __destruct as obselete - October 7th, 2013 2.0: Integrated with Primus 2 in mind - October 14th, 2015 3.0: reformatted for inclusion in phabstractic - July 30th, 2016
$observedSubjects : \Phabstractic\Patterns\Phabstractic\Patterns\Resource\PublisherInterface
The subjects that this observer is listening to
For an observer that listens to multiple publishers with some added functionality see Phabstractic\Event\Aggregator
detachPublisher(\Phabstractic\Patterns\Resource\PublisherInterface $publisher)
This detaches the observer from its subject
Reciprocal methods exist in the publisher
\Phabstractic\Patterns\Resource\PublisherInterface | $publisher |
attachPublisher(\Phabstractic\Patterns\Resource\PublisherInterface $publisher)
Attach this observer to a new publisher
This also acts like a 'set' function, and null is an acceptable value to be passed
\Phabstractic\Patterns\Resource\PublisherInterface | $publisher |
notifyObserver(\Phabstractic\Patterns\Resource\PublisherInterface $target, \Phabstractic\Patterns\Resource\StateInterface $state) : boolean
Notify the object of an event
This causes the object to 'fire' on any event passed to it.
Don't subclass this class to build a filter in this area, use a filter object instead. See handler class description
\Phabstractic\Patterns\Resource\PublisherInterface | $target | |
\Phabstractic\Patterns\Resource\StateInterface | $state |
Return true if propagated (state is AbstractEvent)
__construct(mixed $data = null, \Phabstractic\Data\Types\Resource\FilterInterface $restrictions = null, array $options = array())
The Sorted List constructor
Accepts data, and the obligatory options parameter
Passes the required restrictions onto the parent class along with the options
NOTE: In order to sort a list it MUST all be the same type, so restrictions are set up.
This instantiates the class and sets the index
mixed | $data | The data to initialize the queue |
\Phabstractic\Data\Types\Resource\FilterInterface | $restrictions | |
array | $options | The options to pass into the object |
top() : string|\Phabstractic\Data\Types\Resource\Phabstractic\Data\Types\None
Returns the top value
This abstract class only sorts
if no top exists
'Top' value of list otherwise
topReference() : string|\Phabstractic\Data\Types\Resource\Phabstractic\Data\Types\None
Returns the top value as a reference
This abstract class only sorts
if top is empty
bottom() : mixed|\Phabstractic\Data\Types\Phabstractic\Data\Types\None
Returns the least urgent item from the list
The data from the priority object, null if otherwise
bottomReference() : mixed|\Phabstractic\Data\Types\Phabstractic\Data\Types\None
Returns the least urgent item from the list as a reference
The data from the priority object as a reference, null if otherwise
index(integer $i) : string|\Phabstractic\Data\Types\Resource\Phabstractic\Data\Types\None
Returns the data objects specified by the index request
This abstract class only sorts
integer | $i | the given index |
if index is out of range
indexRange(\Phabstractic\Data\Types\Phabstractic\Data\Types\Range $r) : array
Get A Range Of Indexes
This gets an array of objects that have priorities between ranges
NOTE: The utility function must be used because of incompatibility of array_unique algorithm
\Phabstractic\Data\Types\Phabstractic\Data\Types\Range | $r | The range to include |
The appropriate array
indexReference(integer $i) : string|\Phabstractic\Data\Types\Resource\Phabstractic\Data\Types\None
Returns the data objects specified by the index request
This abstract class only sorts
integer | $i | the given index |
if index is out of range
indexRangeReference(\Phabstractic\Data\Types\Phabstractic\Data\Types\Range $r) : array
Get A Range Of Index References
This gets an array of objects that have priorities between ranges
NOTE: The utility function must be used because of incompatibility of array_unique algorithm
\Phabstractic\Data\Types\Phabstractic\Data\Types\Range | $r | The range to include |
The appropriate array
delete(mixed $data) : boolean
Deletes an element given by data from the list
This does not need sorting because the list will already be sorted by urgency, eliminating one item does not upset that sort
mixed | $data | The given data item to remove from the list |
if set to strict and element doesn't exist
Whether the data item was deleted, returns false if data item not in queue
pull() : mixed|\Phabstractic\Data\Types\Phabstractic\Data\Types\None
Pull the least urgent item off the list
This truncates the lsit from the bottom, and return it's value
NOTE: This returns the priority's DATA
The data associated with the lowest urgency, null otherwise
pullReference() : mixed|\Phabstractic\Data\Types\Phabstractic\Data\Types\None
Pull the least urgent item off the list as a reference
This truncates the lsit from the bottom, and return it's value
NOTE: This returns the priority's DATA
The data reference associated with the lowest urgency, null otherwise
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 |
propagate(\Phabstractic\Patterns\Resource\PublisherInterface $publisher, \Phabstractic\Event\Resource\EventInterface $event)
Propagate an event down through the list of handlers
This checks if an event has been stopped or is unstoppable These can be set in the handlers themselves.
NOTE: PriorityQueue inherits from AbsractSortedList getList() will already be sorted with the appropriate queues
It's important that the event passed is a reference, so that it can be potentially stopped.
\Phabstractic\Patterns\Resource\PublisherInterface | $publisher | |
\Phabstractic\Event\Resource\EventInterface | $event |