protected function WebformSubmissionLimitBlock::replaceTokens in Webform 6.x
Same name and namespace in other branches
- 8.5 src/Plugin/Block/WebformSubmissionLimitBlock.php \Drupal\webform\Plugin\Block\WebformSubmissionLimitBlock::replaceTokens()
 
Replace tokens in text.
Parameters
string|array $text: A string of text that may contain tokens.
Return value
string|array Text or array with tokens replaced.
1 call to WebformSubmissionLimitBlock::replaceTokens()
- WebformSubmissionLimitBlock::build in src/
Plugin/ Block/ WebformSubmissionLimitBlock.php  - Builds and returns the renderable array for this block plugin.
 
File
- src/
Plugin/ Block/ WebformSubmissionLimitBlock.php, line 322  
Class
- WebformSubmissionLimitBlock
 - Provides a 'Webform submission limit' block.
 
Namespace
Drupal\webform\Plugin\BlockCode
protected function replaceTokens($text) {
  // Replace [total] token.
  if (strpos($text, '[total]') !== FALSE) {
    $text = str_replace('[total]', $this
      ->getTotal(), $text);
  }
  // Replace [limit] token.
  if (strpos($text, '[limit]') !== FALSE) {
    $text = str_replace('[limit]', $this
      ->getLimit(), $text);
  }
  // Replace [remaining] token.
  if (strpos($text, '[remaining]') !== FALSE) {
    $text = str_replace('[remaining]', $this
      ->getLimit() - $this
      ->getTotal(), $text);
  }
  // Replace [interval] token.
  if (strpos($text, '[interval]') !== FALSE) {
    $text = str_replace('[interval]', $this
      ->getIntervalText(), $text);
  }
  // Replace webform tokens.
  return $this->tokenManager
    ->replace($text, $this
    ->getWebform());
}