Description:
This package is a helper package and contains different utility classes
and interfaces. They do not rely on other Freeform packages and can be
used even in non-Freeform applications.
See also:
Authors:
Interfaces:
-
Callback
This is a generic callback interface.
-
Comparator
This is a general-purpose comparator interface. Its sole method,
Comparator::compare should return -1, 0, or 1 if the first argument is
less, equal or greater than the second, respectively
-
Iterable
This interface is a replacement for SPL Iterator since the latter
has a somewhat strange naming. Moreover, the behaviour is also slightly
different - a call to Iterable::hasMore() returns true if there are more items
in the iterable, but Iterable::getNext() returns the next item AND advances the
iterable so that subsequent calls to this method will fetch new items.
-
Matcher
This is a general-purpose matcher interface. Its sole method, match,
should return true if the passed parameter satisfies conditions of the
matcher object.
-
PaginatedIterable
The PaginatedIterable interface is an extension to the Iterable interface and
allows to paginate entities that are iterated over.
Classes:
-
AccessDeniedException
This is a general-purpose "Access Denied" exception. It can be used to convey a reason
code and message and the object access to which was denied
-
ComboIterable
This class allows you to combine several iterables into one so that you
iterate them in parallel. The result of a call to ComboIterable::getNext() will be
an array that holds key=>value pairs combined from the results of calls to
Iterable::getNext() methods of each iterable contained by this
ComboIterable. The primary use of this class is allowing to iterate over
keys and values of a single array so that each call to ComboIterable::getNext
will return an array containing current key and value. The keys of this resulting array
will be fixed like 'key' and 'value' (you can specify them when instantiating a
ComboIterable).
The usage of this class is best illustrated by the following example:
<?
$a = array('one'=>'1', 'two'=>'2', 'three'=>'3'); // We will iterate over key=>value pairs of this array $ci = new ComboIterable(array('key', array_keys($a)), array('val', array_values($a))); while($ci->hasMore()) { $r = $ci->getNext(); echo $r['key'], '=', $r['val'], "\n"; } ?>
This snippet will print
one=1
two=2
three=3
Such approach is very convenient when you need to display keys and values of a single array
with the HTMLShowIterable tag - if this tag iterates over an iterable that
returns scalar values, it is impossible to access array keys from the template; only values
are available as the template variable html.showiterable.value. Using ComboIterable
you can easily loop through array keys and values, as well as combine more parallel arrays
into one Iterable.
You can also use iterables that return arrays with this class. In this case just
pass the iterables themselves to the constructor. For example:
<?
$a1 = new IterableArray(array(array('alpha'=>1), array('alpha'=>2), array('alpha'=>3))); $a2 = new IterableArray(array(array('beta'=>10), array('beta'=>20), array('beta'=>30))); $ci = new ComboIterable($a1, $a2); while($ci->hasMore()) { $r = $ci->getNext(); echo $r['alpha'], ', ', $r['beta'], "\n"; } ?>
produces
1, 10
2, 20
3, 30
-
ComboTest
-
ConfigurationException
This is a general-purpose exception that should be thrown when a particular package discovers
that it has not been setup properly.
-
IterableADODBRecordSet
This class is a PaginatedIterable wrapper around ADODB RecordSet object that allows to
iterate and paginate it in the comfort of Freeform iterators.
-
IterableArray
An Iterable interface over an array. Upon construction, an array
is passed as a sole parameter, that will be iterated over.
Note that the array passed will be copied, so it's possible to
alter the passed array not changing the behaviour of this object.
-
IterableIterator
This is a helper class allows Iterable be accessed via SPL Iterator interface (ie using foreach statement).
-
IterablePDOResult
This class is a PaginatedIterable wrapper around PDOStatement
that is used to fetch results of a SELECT query
-
IterablePearDbResult
This class is an Iterable wrapper around PEAR::DB_result.
It allows to treat DB_result as a PaginatedIterable. This means that
you can paginate it in a more comfort way.
-
NoMoreElementsException
This exception is thrown from Iterable::getNext method if there
are no more elements.
-
NotSupportedException
Generic exception to be utilized as notifier on feature isn't supported
-
PCREValidator
This validator uses PCRE function preg_match to validate the value against the pattern
that was given at the time of the validator construction.
-
PaginatedIterableArray
-
PaginatedIterableIterator
This is a helper class allows PaginatedIterable be accessed via SPL Iterator interface (ie using foreach statement).
-
RegexValidator
A regular expression validator. It uses the mb_ereg function to validate the values so
it will correctly handle non-latin characters.
-
URL
The URL class represents an URL and provides a way to relocate
it to new places taking into account absolute/relative URLs,
paths etc.
This class provides support for things like ports, subprotocols,
user name and password, query strings and references.
This class gives an easy access to different parts of an URL,
so relocation is really straighforward.
When constucting an URL, keep in mind that protocol and host will be converted to lower case;
everything else will retain case. So, when comparing URLs, www.somehost.com/myFolder doesn't equal
www.somehost.com/myfolder, however, it equals Www.SomeHost.Com/myFolder
-
Validator
This is an abstract Validator class. Validators serve the sole purpose of
validating values passed to their Validator::isValid method based on the different
criteria set in extending classes.
-
ValidatorSet
A complex validator that consists of several Validators and validates only
if every validator in the set validates the test value
-
ValueValidator
This validator returns true if the value passed matches the value stored in the validator (that was given at the time of the validator construction).
It uses typeless compare (==)
|
|