mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-18 10:36:16 +00:00
Added support for conditions on multi-nested numerically indexed items
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6657 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
593c4d7245
commit
1fdd44f6b2
2 changed files with 8 additions and 1 deletions
|
@ -417,13 +417,16 @@ class Set extends Object {
|
|||
}
|
||||
|
||||
$match = false;
|
||||
if (array_key_exists($token, $context['item']) && (!$conditions || Set::matches($conditions, $context['item'][$token], $i))) {
|
||||
if (array_key_exists($token, $context['item'])) {
|
||||
$items = $context['item'][$token];
|
||||
if (!is_array($items) || !isset($items[0])) {
|
||||
$items = array($items);
|
||||
}
|
||||
|
||||
foreach ($items as $item) {
|
||||
if ($conditions && !Set::matches($conditions, $item, $i)) {
|
||||
continue;
|
||||
}
|
||||
$matches[] = array(
|
||||
'trace' => am($context['trace'], $context['key']),
|
||||
'key' => $token,
|
||||
|
|
|
@ -476,6 +476,10 @@ class SetTest extends UnitTestCase {
|
|||
$r = Set::extract('/Comment/id', $common);
|
||||
$expected = array(1, 2, 3, 4, 5);
|
||||
$this->assertEqual($r, $expected);
|
||||
|
||||
$expected = array(1, 2, 4, 5);
|
||||
$r = Set::extract('/Comment[id!=3]/id', $common);
|
||||
$this->assertEqual($r, $expected);
|
||||
}
|
||||
/**
|
||||
* undocumented function
|
||||
|
|
Loading…
Add table
Reference in a new issue