/**
  * Register the declared tokens.
  *
  * @param TokenRegisterEvent $e
  *   The registration event. Add new tokens using register().
  */
 public function registerTokens(TokenRegisterEvent $e)
 {
     if (!$this->checkActive($e->getTokenProcessor())) {
         return;
     }
     foreach ($this->tokenNames as $name => $label) {
         $e->register(array('entity' => $this->entity, 'field' => $name, 'label' => $label));
     }
 }
 public function onListTokens(TokenRegisterEvent $e)
 {
     $this->counts[__FUNCTION__]++;
     $e->register('custom', array('foobar' => 'A special message about foobar'));
 }