public static function getSubscribedEvents() {
return [
- Events::TOKEN_REGISTER => 'registerTokens',
- Events::TOKEN_EVALUATE => 'evaluateTokens',
+ 'civi.token.list' => 'registerTokens',
+ 'civi.token.eval' => 'evaluateTokens',
\Civi\ActionSchedule\Events::MAILING_QUERY => 'alterActionScheduleQuery',
];
}
* 'label' => ts('Default Profile URL (View Mode)'),
* ));
* @endcode
+ *
+ * Event name: 'civi.token.list'
*/
class TokenRegisterEvent extends TokenEvent {
* Class TokenRenderEvent
* @package Civi\Token\Event
*
- * A TokenRenderEvent is fired after the TokenProcessor has rendered
- * a message.
+ * Perform post-processing on a rendered message. A TokenRenderEvent is fired
+ * after the TokenProcessor has rendered a message.
*
- * The render event may be used for post-processing the text, but
+ * WARNING: The render event may be used for post-processing the text, but
* it's very difficult to do substantive work in a secure, robust
* way within this event. The event primarily exists to facilitate
* a transition of some legacy code.
+ *
+ * Event name: 'civi.token.render'
*/
class TokenRenderEvent extends TokenEvent {
* }
* @encode
*
+ * Event name: 'civi.token.eval'
*/
class TokenValueEvent extends TokenEvent {
class Events {
/**
- * Create a list of supported tokens.
- *
* @see \Civi\Token\Event\TokenRegisterEvent
+ * @deprecated - You may simply use the event name directly. dev/core#1744
*/
const TOKEN_REGISTER = 'civi.token.list';
/**
- * Create a list of supported tokens.
- *
* @see \Civi\Token\Event\TokenValueEvent
+ * @deprecated - You may simply use the event name directly. dev/core#1744
*/
const TOKEN_EVALUATE = 'civi.token.eval';
/**
- * Perform post-processing on a rendered message.
- *
- * WARNING: It is difficult to develop robust,
- * secure code using this stage. However, we need
- * to support it during a transitional period
- * while the token logic is reorganized.
- *
* @see \Civi\Token\Event\TokenRenderEvent
+ * @deprecated - You may simply use the event name directly. dev/core#1744
*/
const TOKEN_RENDER = 'civi.token.render';
*/
public static function getSubscribedEvents() {
return [
- Events::TOKEN_EVALUATE => 'onEvaluate',
- Events::TOKEN_RENDER => 'onRender',
+ 'civi.token.eval' => 'onEvaluate',
+ 'civi.token.render' => 'onRender',
];
}
if ($this->tokens === NULL) {
$this->tokens = [];
$event = new TokenRegisterEvent($this, ['entity' => 'undefined']);
- $this->dispatcher->dispatch(Events::TOKEN_REGISTER, $event);
+ $this->dispatcher->dispatch('civi.token.list', $event);
}
return $this->tokens;
}
*/
public function evaluate() {
$event = new TokenValueEvent($this);
- $this->dispatcher->dispatch(Events::TOKEN_EVALUATE, $event);
+ $this->dispatcher->dispatch('civi.token.eval', $event);
return $this;
}
$event->context = $row->context;
$event->row = $row;
$event->string = strtr($message['string'], $filteredTokens);
- $this->dispatcher->dispatch(Events::TOKEN_RENDER, $event);
+ $this->dispatcher->dispatch('civi.token.render', $event);
return $event->string;
}
$this->useTransaction(TRUE);
parent::setUp();
$this->dispatcher = new EventDispatcher();
- $this->dispatcher->addListener(Events::TOKEN_REGISTER, [$this, 'onListTokens']);
- $this->dispatcher->addListener(Events::TOKEN_EVALUATE, [$this, 'onEvalTokens']);
+ $this->dispatcher->addListener('civi.token.list', [$this, 'onListTokens']);
+ $this->dispatcher->addListener('civi.token.eval', [$this, 'onEvalTokens']);
$this->counts = [
'onListTokens' => 0,
'onEvalTokens' => 0,