lithium\data\model\Relationship::query()
Generates query parameters for a related object (or objects) for the given object connected to it by this relationship.
Parameters
-
object
$object
The object to get the related data for.
Returns
objectReturns the object(s) for this relationship.
Source
public function query($object) {
$conditions = (array) $this->constraints();
foreach ($this->key() as $from => $to) {
if (!isset($object->{$from})) {
return null;
}
$conditions[$to] = $object->{$from};
if (is_object($conditions[$to]) && $conditions[$to] instanceof Countable) {
$conditions[$to] = iterator_to_array($conditions[$to]);
}
}
$fields = $this->fields();
$fields = $fields === true ? null : $fields;
return compact('conditions', 'fields');
}