mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Optimizations in filterResults.
This commit is contained in:
parent
fea2b5798c
commit
d095f5fe8d
1 changed files with 13 additions and 16 deletions
|
@ -1126,33 +1126,30 @@ class DboSource extends DataSource {
|
||||||
* @param array $filtered List of classes already filtered, to be skipped
|
* @param array $filtered List of classes already filtered, to be skipped
|
||||||
* @return array Array of results that have been filtered through $model->afterFind
|
* @return array Array of results that have been filtered through $model->afterFind
|
||||||
*/
|
*/
|
||||||
protected function _filterResults(&$results, &$model, $filtered = array()) {
|
protected function _filterResults(&$results, Model $model, $filtered = array()) {
|
||||||
$filtering = array();
|
$filtering = array();
|
||||||
$count = count($results);
|
$_filtered = array_flip($filtered);
|
||||||
|
|
||||||
for ($i = 0; $i < $count; $i++) {
|
foreach ($results as &$result) {
|
||||||
if (is_array($results[$i])) {
|
if (is_array($result)) {
|
||||||
$classNames = array_keys($results[$i]);
|
if (!isset($keys)) {
|
||||||
$count2 = count($classNames);
|
$keys = array_keys($result);
|
||||||
|
}
|
||||||
for ($j = 0; $j < $count2; $j++) {
|
foreach ($keys as $className) {
|
||||||
$className = $classNames[$j];
|
if ($model->alias !== $className && !isset($_filtered[$className])) {
|
||||||
if ($model->alias != $className && !in_array($className, $filtered)) {
|
$filtering[] = $className;
|
||||||
if (!in_array($className, $filtering)) {
|
|
||||||
$filtering[] = $className;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($model->{$className}) && is_object($model->{$className})) {
|
if (isset($model->{$className}) && is_object($model->{$className})) {
|
||||||
$data = $model->{$className}->afterFind(array(array($className => $results[$i][$className])), false);
|
$data = $model->{$className}->afterFind(array(array($className => $result[$className])), false);
|
||||||
}
|
}
|
||||||
if (isset($data[0][$className])) {
|
if (isset($data[0][$className])) {
|
||||||
$results[$i][$className] = $data[0][$className];
|
$result[$className] = $data[0][$className];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $filtering;
|
return array_unique($filtering);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue