Reputation: 1826
How can i scope the function in Hash::map()
?
Example:
$users = $this->User->find('all');
$results = Hash::map($users, '{n}', 'foo');
Where foo
should be called as $this->foo
.
http://book.cakephp.org/2.0/en/core-utility-libraries/hash.html
Thanks.
Upvotes: 0
Views: 949
Reputation: 60453
You do so by passing an array where the first entry points to the object, and the second one holds the method name: array($this, 'foo')
Hash::map($users, '{n}', array($this, 'foo'));
See also http://php.net/manual/en/language.types.callable.php
Upvotes: 2