"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/ORM/Association.php" between
cakephp-4.0.1.tar.gz and cakephp-4.0.2.tar.gz

About: CakePHP is a rapid development framework for PHP applications. Source code.

Association.php  (cakephp-4.0.1):Association.php  (cakephp-4.0.2)
skipping to change at line 993 skipping to change at line 993
protected function _formatAssociationResults(Query $query, Query $surrogate, array $options): void protected function _formatAssociationResults(Query $query, Query $surrogate, array $options): void
{ {
$formatters = $surrogate->getResultFormatters(); $formatters = $surrogate->getResultFormatters();
if (!$formatters || empty($options['propertyPath'])) { if (!$formatters || empty($options['propertyPath'])) {
return; return;
} }
$property = $options['propertyPath']; $property = $options['propertyPath'];
$propertyPath = explode('.', $property); $propertyPath = explode('.', $property);
$query->formatResults(function ($results) use ($formatters, $property, $ propertyPath) { $query->formatResults(function ($results) use ($formatters, $property, $ propertyPath, $query) {
$extracted = []; $extracted = [];
foreach ($results as $result) { foreach ($results as $result) {
foreach ($propertyPath as $propertyPathItem) { foreach ($propertyPath as $propertyPathItem) {
if (!isset($result[$propertyPathItem])) { if (!isset($result[$propertyPathItem])) {
$result = null; $result = null;
break; break;
} }
$result = $result[$propertyPathItem]; $result = $result[$propertyPathItem];
} }
$extracted[] = $result; $extracted[] = $result;
} }
$extracted = new Collection($extracted); $extracted = new Collection($extracted);
foreach ($formatters as $callable) { foreach ($formatters as $callable) {
$extracted = new ResultSetDecorator($callable($extracted)); $extracted = new ResultSetDecorator($callable($extracted));
} }
/** @var \Cake\Collection\CollectionInterface $results */ /** @var \Cake\Collection\CollectionInterface $results */
return $results->insert($property, $extracted); $results = $results->insert($property, $extracted);
if ($query->isHydrationEnabled()) {
$results = $results->map(function ($result) {
$result->clean();
return $result;
});
}
return $results;
}, Query::PREPEND); }, Query::PREPEND);
} }
/** /**
* Applies all attachable associations to `$query` out of the containments f ound * Applies all attachable associations to `$query` out of the containments f ound
* in the `$surrogate` query. * in the `$surrogate` query.
* *
* Copies all contained associations from the `$surrogate` query into the * Copies all contained associations from the `$surrogate` query into the
* passed `$query`. Containments are altered so that they respect the associ ations * passed `$query`. Containments are altered so that they respect the associ ations
* chain from which they originated. * chain from which they originated.
 End of changes. 2 change blocks. 
2 lines changed or deleted 11 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)