*/
protected $tokens = NULL;
+ /**
+ * A list of available tokens formatted for display
+ * @var array
+ * Array('{' . $dottedName . '}' => 'labelString')
+ */
+ protected $listTokens = NULL;
+
protected $next = 0;
/**
return $this->tokens;
}
+ /**
+ * Get the list of available tokens, formatted for display
+ *
+ * @return array
+ * Ex: $tokens[ '{token.name}' ] = "Token label"
+ */
+ public function listTokens() {
+ if ($this->listTokens === NULL) {
+ $this->listTokens = array();
+ foreach ($this->getTokens() as $token => $values) {
+ $this->listTokens['{' . $token . '}'] = $values['label'];
+ }
+ }
+ return $this->listTokens;
+ }
+
/**
* Compute and store token values.
*/
$this->assertEquals($expected, $p->getMessageTokens());
}
+ public function testListTokens() {
+ $p = new TokenProcessor($this->dispatcher, array(
+ 'controller' => __CLASS__,
+ ));
+ $p->addToken(array('entity' => 'MyEntity', 'field' => 'myField', 'label' => 'My Label'));
+ $this->assertEquals(array('{MyEntity.myField}' => 'My Label'), $p->listTokens());
+ }
+
/**
* Perform a full mail-merge, substituting multiple tokens for multiple
* contacts in multiple messages.