Inheritance diagram for Set:

Public Member Functions | |
| __array ($array) | |
| __flatten ($results, $key=null) | |
| & | get () |
Static Public Member Functions | |
| __map (&$array, $class, $primary=false) | |
| check ($data, $path=null) | |
| classicExtract ($data, $path=null) | |
| combine ($data, $path1=null, $path2=null, $groupPath=null) | |
| contains ($val1, $val2=null) | |
| countDim ($array=null, $all=false, $count=0) | |
| diff ($val1, $val2=null) | |
| enum ($select, $list=null) | |
| extract ($path, $data=null, $options=array()) | |
| filter ($var, $isArray=false) | |
| flatten ($data, $separator= '.') | |
| format ($data, $format, $keys) | |
| insert ($list, $path, $data=null) | |
| isEqual ($val1, $val2=null) | |
| map ($class= 'stdClass', $tmp= 'stdClass') | |
| matches ($conditions, $data=array(), $i=null, $length=null) | |
| merge ($arr1, $arr2=null) | |
| normalize ($list, $assoc=true, $sep= ',', $trim=true) | |
| numeric ($array=null) | |
| pushDiff ($array, $array2) | |
| remove ($list, $path=null) | |
| reverse ($object) | |
| sort ($data, $path, $dir) | |
Public Attributes | |
| $value = array() | |
Definition at line 33 of file set.php.
| Set::__array | ( | $ | array | ) |
Get the array value of $array. If $array is null, it will return the current array Set holds. If it is an object of type Set, it will return its value. If it is another object, its object variables. If it is anything else but an array, it will return an array whose first element is $array.
| mixed | $array Data from where to get the array. |
| Set::__flatten | ( | $ | results, | |
| $ | key = null | |||
| ) |
| Set::__map | ( | &$ | array, | |
| $ | class, | |||
| $ | primary = false | |||
| ) | [static] |
Maps the given value as an object. If $value is an object, it returns $value. Otherwise it maps $value as an object of type $class, and if primary assign _name_ $key on first array. If $value is not empty, it will be used to set properties of returned object (recursively). If $key is numeric will maintain array structure
| mixed | $value Value to map | |
| string | $class Class name | |
| boolean | $primary whether to assign first array key as the _name_ |
Definition at line 173 of file set.php.
References $out, $value, and countDim().
Referenced by map().
| Set::check | ( | $ | data, | |
| $ | path = null | |||
| ) | [static] |
| Set::classicExtract | ( | $ | data, | |
| $ | path = null | |||
| ) | [static] |
Gets a value from an array or object that is contained in a given path using an array path syntax, i.e.: "{n}.Person.{[a-z]+}" - Where "{n}" represents a numeric key, "Person" represents a string literal, and "{[a-z]+}" (i.e. any string literal enclosed in brackets besides {n} and {s}) is interpreted as a regular expression.
| array | $data Array from where to extract | |
| mixed | $path As an array, or as a dot-separated string. |
Definition at line 590 of file set.php.
References $path, App::import(), and String::tokenize().
Referenced by extract().
| Set::combine | ( | $ | data, | |
| $ | path1 = null, |
|||
| $ | path2 = null, |
|||
| $ | groupPath = null | |||
| ) | [static] |
Creates an associative array using a $path1 as the path to build its keys, and optionally $path2 as path to get the values. If $path2 is not specified, all values will be initialized to null (useful for Set::merge). You can optionally group the values by what is obtained when following the path specified in $groupPath.
| mixed | $data Array or object from where to extract keys and values | |
| mixed | $path1 As an array, or as a dot-separated string. | |
| mixed | $path2 As an array, or as a dot-separated string. | |
| string | $groupPath As an array, or as a dot-separated string. |
Definition at line 929 of file set.php.
References $out, extract(), and format().
Referenced by Model::_findList(), and TreeBehavior::generatetreelist().
| Set::contains | ( | $ | val1, | |
| $ | val2 = null | |||
| ) | [static] |
| Set::countDim | ( | $ | array = null, |
|
| $ | all = false, |
|||
| $ | count = 0 | |||
| ) | [static] |
Counts the dimensions of an array. If $all is set to false (which is the default) it will only consider the dimension of the first element in the array.
| array | $array Array to count dimensions on | |
| boolean | $all Set to true to count the dimension considering all elements in array | |
| integer | $count Start the dimension count at this number |
Definition at line 848 of file set.php.
Referenced by __map(), and FormHelper::create().
| Set::diff | ( | $ | val1, | |
| $ | val2 = null | |||
| ) | [static] |
Computes the difference between a Set and an array, two Sets, or two arrays
| mixed | $val1 First value | |
| mixed | $val2 Second value |
Definition at line 773 of file set.php.
References $out.
Referenced by DboSource::__mergeAssociation(), DboOracle::queryAssociation(), and PaginatorHelper::url().
| Set::enum | ( | $ | select, | |
| $ | list = null | |||
| ) | [static] |
Return a value from an array list if the key exists.
If a comma separated $list is passed arrays are numeric with the key of the first being 0 $list = 'no, yes' would translate to $list = array(0 => 'no', 1 => 'yes');
If an array is used, keys can be strings example: array('no' => 0, 'yes' => 1);
$list defaults to 0 = no 1 = yes if param is not passed
| mixed | $select Key in $list to return | |
| mixed | $list can be an array or a comma-separated list. |
Definition at line 272 of file set.php.
References normalize().
| Set::extract | ( | $ | path, | |
| $ | data = null, |
|||
| $ | options = array() | |||
| ) | [static] |
Implements partial support for XPath 2.0. If $path is an array or $data is empty it the call is delegated to Set::classicExtract.
Currently implemented selectors:
Other limitations:
Warning: Even so it has plenty of unit tests the XPath support has not gone through a lot of real-world testing. Please report Bugs as you find them. Suggestions for additional features to imlement are also very welcome!
| string | $path An absolute XPath 2.0 path | |
| string | $data An array of data to extract from | |
| string | $options Currently only supports 'flatten' which can be disabled for higher XPath-ness |
Definition at line 371 of file set.php.
References $path, a(), classicExtract(), and matches().
Referenced by Model::__saveMulti(), Model::_findNeighbors(), Model::_findThreaded(), DboSource::_matchRecords(), AclBehavior::afterDelete(), ModelTask::bakeTest(), check(), DbAcl::check(), combine(), AclShell::create(), Model::deleteAll(), format(), DbAcl::getAclLink(), DboMysqlBase::index(), ConsoleShell::main(), matches(), DboSource::name(), read(), sort(), and write().
| Set::filter | ( | $ | var, | |
| $ | isArray = false | |||
| ) | [static] |
Filters empty elements out of a route array, excluding '0'.
| mixed | $var Either an array to filter, or value when in callback | |
| boolean | $isArray Force to tell $var is an array when $var is empty |
Definition at line 78 of file set.php.
Referenced by FormHelper::__secure(), Model::create(), View::entity(), PaginatorHelper::link(), and Helper::setEntity().
| Set::flatten | ( | $ | data, | |
| $ | separator = '.' | |||
| ) | [static] |
Collapses a multi-dimensional array into a single dimension, using a delimited array path for each array element's key, i.e. array(array('Foo' => array('Bar' => 'Far'))) becomes array('0.Foo.Bar' => 'Far').
| array | $data Array to flatten | |
| string | $separator String used to separate array key elements in a path, defaults to '.' |
Definition at line 1034 of file set.php.
References $path.
| Set::format | ( | $ | data, | |
| $ | format, | |||
| $ | keys | |||
| ) | [static] |
Returns a series of values extracted from an array, formatted in a format string.
| array | $data Source array from which to extract the data | |
| string | $format Format string into which values will be inserted, see sprintf() | |
| array | $keys An array containing one or more Set::extract()-style key paths |
Definition at line 295 of file set.php.
References $out, and extract().
Referenced by combine().
| & Set::get | ( | ) |
| Set::insert | ( | $ | list, | |
| $ | path, | |||
| $ | data = null | |||
| ) | [static] |
| Set::isEqual | ( | $ | val1, | |
| $ | val2 = null | |||
| ) | [static] |
| Set::map | ( | $ | class = 'stdClass', |
|
| $ | tmp = 'stdClass' | |||
| ) | [static] |
Maps the contents of the Set object to an object hierarchy. Maintains numeric keys as arrays of objects
| string | $class A class name of the type of object to map to | |
| string | $tmp A temporary class name used as $class if $class is an array |
Definition at line 124 of file set.php.
References __map().
Referenced by XmlNode::append().
| Set::matches | ( | $ | conditions, | |
| $ | data = array(), |
|||
| $ | i = null, |
|||
| $ | length = null | |||
| ) | [static] |
This function can be used to see if a single item or a given xpath match certain conditions.
| mixed | $conditions An array of condition strings or an XPath expression | |
| array | $data An array of data to execute the match on | |
| integer | $i Optional: The 'nth'-number of the item being matched. |
Definition at line 516 of file set.php.
References extract().
Referenced by extract().
| Set::merge | ( | $ | arr1, | |
| $ | arr2 = null | |||
| ) | [static] |
This function can be thought of as a hybrid between PHP's array_merge and array_merge_recursive. The difference to the two is that if an array key contains another array then the function behaves recursive (unlike array_merge) but does not do if for keys containing strings (unlike array_merge_recursive). See the unit test for more information.
Note: This function will work with an unlimited amount of arguments and typecasts non-array parameters into arrays.
| array | $arr1 Array to be merged | |
| array | $arr2 Array to merge with |
Definition at line 52 of file set.php.
Referenced by HttpSocket::__construct(), Model::__construct(), Controller::__mergeVars(), Component::_loadComponents(), HttpSocket::configUri(), ContainableBehavior::containments(), HttpSocket::delete(), HttpSocket::get(), HttpSocket::post(), HttpSocket::put(), HttpSocket::request(), and Model::save().
| Set::normalize | ( | $ | list, | |
| $ | assoc = true, |
|||
| $ | sep = ',', |
|||
| $ | trim = true | |||
| ) | [static] |
Normalizes a string or array list.
| mixed | $list List to normalize | |
| boolean | $assoc If true, $list will be converted to an associative array | |
| string | $sep If $list is a string, it will be split into an array with $sep | |
| boolean | $trim If true, separated strings will be trimmed |
Definition at line 877 of file set.php.
Referenced by Controller::__mergeVars(), Component::_loadComponents(), enum(), and BehaviorCollection::init().
| Set::numeric | ( | $ | array = null |
) | [static] |
Checks to see if all the values in the array are numeric
| array | $array The array to check. If null, the value of the current Set object |
Definition at line 235 of file set.php.
Referenced by DboSource::fields(), and Model::saveAll().
| Set::pushDiff | ( | $ | array, | |
| $ | array2 | |||
| ) | [static] |
Pushes the differences in $array2 onto the end of $array
| mixed | $array Original array | |
| mixed | $array2 Differences to push |
Definition at line 97 of file set.php.
References $value.
Referenced by I18n::__bindTextDomain(), __initPluralRules(), __initSingularRules(), and DboSource::__mergeHasMany().
| Set::remove | ( | $ | list, | |
| $ | path = null | |||
| ) | [static] |
| Set::reverse | ( | $ | object | ) | [static] |
Converts an object into an array. If $object is no object, reverse will return the same value.
| object | $object Object to reverse |
Definition at line 986 of file set.php.
References $out.
Referenced by Model::set().
| Set::sort | ( | $ | data, | |
| $ | path, | |||
| $ | dir | |||
| ) | [static] |
Sorts an array by any value, determined by a Set-compatible path
| array | $data | |
| string | $path A Set-compatible path to the array value | |
| string | $dir asc/desc |
Definition at line 1090 of file set.php.
References $path, __flatten(), and extract().
| Set::$value = array() |
1.4.7