2 namespace Civi\Token\Event
;
5 * Class TokenValueEvent
6 * @package Civi\Token\Event
8 * A TokenValueEvent is fired to convert raw query data into mergeable
12 * $event = new TokenValueEvent($myContext, 'text/html', array(
13 * array('contact_id' => 123),
14 * array('contact_id' => 456),
17 * // Compute tokens one row at a time.
18 * foreach ($event->getRows() as $row) {
19 * $row->setTokens('contact', array(
20 * 'profileUrl' => CRM_Utils_System::url('civicrm/profile/view', 'reset=1&gid=456&id=' . $row['contact_id']'),
24 * // Compute tokens with a bulk lookup.
25 * $ids = implode(',', array_filter(CRM_Utils_Array::collect('contact_id', $event->getRows()), 'is_numeric'));
26 * $dao = CRM_Core_DAO::executeQuery("SELECT contact_id, foo, bar FROM foobar WHERE contact_id in ($ids)");
27 * while ($dao->fetch) {
28 * $row->setTokens('oddball', array(
36 class TokenValueEvent
extends TokenEvent
{
39 * @return \Traversable<TokenRow>
41 public function getRows() {
42 return $this->tokenProcessor
->getRows();