You are here

trait TokenTrait in Courier 2.x

Same name and namespace in other branches
  1. 8 src/TokenTrait.php \Drupal\courier\TokenTrait

Provides an implementation of TokenInterface.

Hierarchy

See also

\Drupal\courier\TokenInterface

1 file declares its use of TokenTrait
TemplateCollection.php in src/Entity/TemplateCollection.php

File

src/TokenTrait.php, line 10

Namespace

Drupal\courier
View source
trait TokenTrait {

  /**
   * Token values keyed by token type.
   *
   * @var array
   */
  protected $tokens = [];

  /**
   * Token options to pass to replace calls.
   *
   * @var array
   */
  protected $token_options = [];

  /**
   * Implements \Drupal\courier\TokenInterface::setTokenValue().
   */
  public function setTokenValue($token, $value) {
    $this->tokens[$token] = $value;
    return $this;
  }

  /**
   * Implements \Drupal\courier\TokenInterface::getTokenValues().
   */
  public function getTokenValues() {
    return $this->tokens;
  }

  /**
   * Implements \Drupal\courier\TokenInterface::getTokenOptions().
   */
  public function getTokenOptions() {
    return $this->token_options;
  }

  /**
   * Implements \Drupal\courier\TokenInterface::setTokenOption().
   */
  public function setTokenOption($option, $value) {
    $this->token_options[$option] = $value;
    return $this;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
TokenTrait::$tokens protected property Token values keyed by token type.
TokenTrait::$token_options protected property Token options to pass to replace calls.
TokenTrait::getTokenOptions public function Implements \Drupal\courier\TokenInterface::getTokenOptions().
TokenTrait::getTokenValues public function Implements \Drupal\courier\TokenInterface::getTokenValues().
TokenTrait::setTokenOption public function Implements \Drupal\courier\TokenInterface::setTokenOption().
TokenTrait::setTokenValue public function Implements \Drupal\courier\TokenInterface::setTokenValue().