mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-18 18:46:17 +00:00
Modified Set::extract to be available from combine and other functions as well
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6659 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
de4807e726
commit
9f040bd395
2 changed files with 15 additions and 0 deletions
|
@ -383,9 +383,17 @@ class Set extends Object {
|
|||
* @access public
|
||||
*/
|
||||
function extract($path, $data = null, $options = array()) {
|
||||
if (is_string($data) && $data{0} == '/') {
|
||||
$tmp = $path;
|
||||
$path = $data;
|
||||
$data = $tmp;
|
||||
}
|
||||
if (is_array($path) || empty($data) || is_object($path) || empty($path)) {
|
||||
return Set::classicExtract($path, $data);
|
||||
}
|
||||
if ($path == '/') {
|
||||
return $data;
|
||||
}
|
||||
$contexts = $data;
|
||||
$options = am(array('flatten' => true), $options);
|
||||
if (!isset($contexts[0])) {
|
||||
|
|
|
@ -487,6 +487,13 @@ class SetTest extends UnitTestCase {
|
|||
$expected = array(1, 2, 4, 5);
|
||||
$r = Set::extract('/Comment[id!=3]/id', $common);
|
||||
$this->assertEqual($r, $expected);
|
||||
|
||||
$r = Set::extract('/', $common);
|
||||
$this->assertEqual($r, $common);
|
||||
|
||||
$expected = array(1, 2, 4, 5);
|
||||
$r = Set::extract($common, '/Comment[id!=3]/id');
|
||||
$this->assertEqual($r, $expected);
|
||||
}
|
||||
/**
|
||||
* undocumented function
|
||||
|
|
Loading…
Add table
Reference in a new issue