You are here

interface WebformTokenManagerInterface in Webform 8.5

Same name and namespace in other branches
  1. 6.x src/WebformTokenManagerInterface.php \Drupal\webform\WebformTokenManagerInterface

Defines an interface for token manager classes.

Hierarchy

Expanded class hierarchy of WebformTokenManagerInterface

All classes that implement WebformTokenManagerInterface

33 files declare their use of WebformTokenManagerInterface
ActionWebformHandler.php in src/Plugin/WebformHandler/ActionWebformHandler.php
EmailWebformHandler.php in src/Plugin/WebformHandler/EmailWebformHandler.php
ExampleWebformHandler.php in modules/webform_example_handler/src/Plugin/WebformHandler/ExampleWebformHandler.php
OptionsLimitWebformHandler.php in modules/webform_options_limit/src/Plugin/WebformHandler/OptionsLimitWebformHandler.php
RemotePostWebformHandler.php in src/Plugin/WebformHandler/RemotePostWebformHandler.php

... See full list

File

src/WebformTokenManagerInterface.php, line 11

Namespace

Drupal\webform
View source
interface WebformTokenManagerInterface {

  /**
   * Replace tokens in text.
   *
   * @param string|array $text
   *   A string of text that may contain tokens.
   * @param \Drupal\Core\Entity\EntityInterface|null $entity
   *   A Webform or Webform submission entity.
   * @param array $data
   *   (optional) An array of keyed objects.
   * @param array $options
   *   (optional) A keyed array of settings and flags to control the token
   *   replacement process. Supported options are:
   *   - langcode: A language code to be used when generating locale-sensitive
   *     tokens.
   *   - callback: A callback function that will be used to post-process the
   *     array of token replacements after they are generated.
   *   - clear: A boolean flag indicating that tokens should be removed from the
   *     final text if no replacement value can be generated.
   * @param \Drupal\Core\Render\BubbleableMetadata|null $bubbleable_metadata
   *   (optional) An object to which static::generate() and the hooks and
   *   functions that it invokes will add their required bubbleable metadata.
   *
   * @return string|array
   *   Text or array with tokens replaced.
   *
   * @see \Drupal\Core\Utility\Token::replace
   */
  public function replace($text, EntityInterface $entity = NULL, array $data = [], array $options = [], BubbleableMetadata $bubbleable_metadata = NULL);

  /**
   * Replace tokens in text with no render context.
   *
   * This method allows tokens to be replaced when there is no render context
   * via REST and JSON API requests.
   *
   * @param string|array $text
   *   A string of text that may contain tokens.
   * @param \Drupal\Core\Entity\EntityInterface|null $entity
   *   A Webform or Webform submission entity.
   * @param array $data
   *   (optional) An array of keyed objects.
   * @param array $options
   *   (optional) A keyed array of settings and flags to control the token
   *   replacement process. Supported options are:
   *   - langcode: A language code to be used when generating locale-sensitive
   *     tokens.
   *   - callback: A callback function that will be used to post-process the
   *     array of token replacements after they are generated.
   *   - clear: A boolean flag indicating that tokens should be removed from the
   *     final text if no replacement value can be generated.
   *
   * @return string|array
   *   Text or array with tokens replaced.
   *
   * @see \Drupal\Core\Utility\Token::replace
   */
  public function replaceNoRenderContext($text, EntityInterface $entity = NULL, array $data = [], array $options = []);

  /**
   * Build token tree link if token.module is installed.
   *
   * @param array $token_types
   *   An array containing token types that should be shown in the tree.
   *
   * @return array
   *   A render array containing a token tree link.
   */
  public function buildTreeLink(array $token_types = [
    'webform',
    'webform_submission',
  ]);

  /**
   * Build token tree element if token.module is installed.
   *
   * @param array $token_types
   *   An array containing token types that should be shown in the tree.
   * @param string $description
   *   (optional) Description to appear after the token tree link.
   *
   * @return array
   *   A render array containing a token tree link wrapped in a div.
   */
  public function buildTreeElement(array $token_types = [
    'webform',
    'webform_submission',
  ], $description = NULL);

  /**
   * Validate form that should have tokens in it.
   *
   * @param array $form
   *   A form.
   * @param array $token_types
   *   An array containing token types that should be validated.
   *
   * @see token_element_validate()
   */
  public function elementValidate(array &$form, array $token_types = [
    'webform',
    'webform_submission',
    'webform_handler',
  ]);

}

Members

Namesort descending Modifiers Type Description Overrides
WebformTokenManagerInterface::buildTreeElement public function Build token tree element if token.module is installed. 1
WebformTokenManagerInterface::buildTreeLink public function Build token tree link if token.module is installed. 1
WebformTokenManagerInterface::elementValidate public function Validate form that should have tokens in it. 1
WebformTokenManagerInterface::replace public function Replace tokens in text. 1
WebformTokenManagerInterface::replaceNoRenderContext public function Replace tokens in text with no render context. 1