return $this->query($sql, array($slug)) ->registerFilter(array($author_map, 'createFromForeign')) ->current();
Collection.phpforeach ($this->filters as $index => $filter) {$values = $filter($values);if (!is_array($values)) {throw new Exception(sprintf("Filters have to return an Array. Filter number %d returned a '%s'.", $index, gettype($values)));}
public function get($index)
{
if (isset($this->fetched[$index])) {
return $this->fetched[$index];
}
$values = $this->stmt->fetch(\PDO::FETCH_ASSOC, \PDO::FETCH_ORI_ABS, $index);
if ($values === false)
return false;
foreach ($this->filters as $index => $filter) {
if (is_array($filter)) {
$values = $filter[0]->$filter[1]($values);
}
else {
$values = $filter($values);
}
if (!is_array($values)) {
throw new Exception(sprintf("Filters have to return an Array. Filter number %d returned a '%s'.", $index, gettype($values)));
}
}
$fetched = $this->object_map->createObjectFromPg($values);
$this->fetched[] = $fetched;
return $fetched;
}
--
You received this message because you are subscribed to the Google Groups "PommProject" group.
Visit this group at http://groups.google.com/group/pommproject?hl=en.
Hi Grégoire,I get it. Indeed, there should be a check or something. But the fact is that the arguments given in the addFilter method have different structure (well at least in the current documentation):
- in on case it's an anonymous function
- in an other case it's an array with the Object map and the method to call.