mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
rename set::getValue to set::get - and make it public
This commit is contained in:
parent
941d503726
commit
7414d0f77b
1 changed files with 14 additions and 7 deletions
|
@ -1146,8 +1146,8 @@ class Set {
|
||||||
foreach ($data as $result) {
|
foreach ($data as $result) {
|
||||||
$result[$options['children']] = array();
|
$result[$options['children']] = array();
|
||||||
|
|
||||||
$id = Set::getValue($result, $idKeys);
|
$id = Set::get($result, $idKeys);
|
||||||
$parentId = Set::getValue($result, $parentKeys);
|
$parentId = Set::get($result, $parentKeys);
|
||||||
|
|
||||||
if (isset($idMap[$id][$options['children']])) {
|
if (isset($idMap[$id][$options['children']])) {
|
||||||
$idMap[$id] = array_merge($result, (array)$idMap[$id]);
|
$idMap[$id] = array_merge($result, (array)$idMap[$id]);
|
||||||
|
@ -1161,10 +1161,10 @@ class Set {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$root = Set::getValue($return[0], $parentKeys);
|
$root = Set::get($return[0], $parentKeys);
|
||||||
|
|
||||||
foreach ($return as $i => $result) {
|
foreach ($return as $i => $result) {
|
||||||
$parentId = Set::getValue($result, $parentKeys);
|
$parentId = Set::get($result, $parentKeys);
|
||||||
if ($parentId != $root) {
|
if ($parentId != $root) {
|
||||||
unset($return[$i]);
|
unset($return[$i]);
|
||||||
}
|
}
|
||||||
|
@ -1174,18 +1174,25 @@ class Set {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A slimmed down set extract
|
* Return the value at the specified position
|
||||||
*
|
*
|
||||||
* @param mixed $input an array
|
* @param mixed $input an array
|
||||||
* @param mixed $path string or array of array keys
|
* @param mixed $path string or array of array keys
|
||||||
* @return the value at the specified position or null if it doesn't exist
|
* @return the value at the specified position or null if it doesn't exist
|
||||||
*/
|
*/
|
||||||
protected static function getValue($input, $path) {
|
public static function get($input, $path = null) {
|
||||||
if (is_string($path)) {
|
if (is_string($path)) {
|
||||||
$keys = explode('/', trim($path, '/'));
|
if (strpos($path, '/') !== false) {
|
||||||
|
$keys = explode('/', trim($path, '/'));
|
||||||
|
} else {
|
||||||
|
$keys = explode('.', trim($path, '.'));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$keys = $path;
|
$keys = $path;
|
||||||
}
|
}
|
||||||
|
if (!$keys) {
|
||||||
|
return $input;
|
||||||
|
}
|
||||||
|
|
||||||
$return = $input;
|
$return = $input;
|
||||||
foreach($keys as $key) {
|
foreach($keys as $key) {
|
||||||
|
|
Loading…
Reference in a new issue