You are here

public function ThunderMetaTagTrait::replaceTokens in Thunder 8.4

Same name and namespace in other branches
  1. 8.5 tests/src/FunctionalJavascript/ThunderMetaTagTrait.php \Drupal\Tests\thunder\FunctionalJavascript\ThunderMetaTagTrait::replaceTokens()
  2. 8.2 tests/src/FunctionalJavascript/ThunderMetaTagTrait.php \Drupal\Tests\thunder\FunctionalJavascript\ThunderMetaTagTrait::replaceTokens()
  3. 8.3 tests/src/FunctionalJavascript/ThunderMetaTagTrait.php \Drupal\Tests\thunder\FunctionalJavascript\ThunderMetaTagTrait::replaceTokens()
  4. 6.2.x tests/src/FunctionalJavascript/ThunderMetaTagTrait.php \Drupal\Tests\thunder\FunctionalJavascript\ThunderMetaTagTrait::replaceTokens()
  5. 6.0.x tests/src/FunctionalJavascript/ThunderMetaTagTrait.php \Drupal\Tests\thunder\FunctionalJavascript\ThunderMetaTagTrait::replaceTokens()
  6. 6.1.x tests/src/FunctionalJavascript/ThunderMetaTagTrait.php \Drupal\Tests\thunder\FunctionalJavascript\ThunderMetaTagTrait::replaceTokens()

Replace tokens inside meta tag configuration.

Parameters

array $configuration: Meta tag configuration.

array $tokens: Tokens that should be replaced in configuration.

Return value

array Returns meta tag configuration with replace tokens.

1 call to ThunderMetaTagTrait::replaceTokens()
MetaInformationTest::testArticleMetaTags in tests/src/FunctionalJavascript/MetaInformationTest.php
Test Meta Tag default configuration and custom configuration for article.

File

tests/src/FunctionalJavascript/ThunderMetaTagTrait.php, line 142

Class

ThunderMetaTagTrait
Trait for manipulation of meta tag configuration and meta tags on page.

Namespace

Drupal\Tests\thunder\FunctionalJavascript

Code

public function replaceTokens(array $configuration, array $tokens) {
  foreach ($configuration as $metaTagName => $metaTagValue) {
    foreach ($tokens as $tokenName => $tokenValue) {
      if (strpos($metaTagValue, $tokenName) !== FALSE) {
        $configuration[$metaTagName] = str_replace($tokenName, $tokenValue, $metaTagValue);
      }
    }
  }
  return $configuration;
}