Commit 5d798402 authored by ayduns's avatar ayduns

Add \Civi\Token\TokenProcessor::getContextValues() from Tim

parent 4f4a7d1f
......@@ -168,6 +168,29 @@ class TokenProcessor {
return new TokenRowIterator($this, new \ArrayIterator($this->rowContexts));
}
/**
* Get a list of all unique values for a given context field,
* whether defined at the processor or row level.
*
* @param string $field
* Ex: 'contactId'.
* @return array
* Ex: [12, 34, 56].
*/
public function getContextValues($field) {
$values = [];
if (isset($this->context[$field])) {
$values[] = $this->context[$field];
}
foreach ($this->getRows() as $row) {
if (isset($row->context[$field])) {
$values[] = $row->context[$field];
}
}
$values = array_unique($values);
return $values;
}
/**
* Get the list of available tokens.
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment