Updated all the contrib modules to their latest versions.
[yaffs-website] / web / modules / contrib / metatag / src / MetatagToken.php
index ebaf310d20996ffc60211803ce8044186819dc51..e240fc01994145541b5b80372fb7dbb70a9d1b08 100644 (file)
@@ -1,7 +1,9 @@
 <?php
 
 namespace Drupal\metatag;
+
 use Drupal\Core\Utility\Token;
+use Drupal\Core\Render\BubbleableMetadata;
 
 /**
  * Token handling service. Uses core token service or contributed Token.
@@ -28,23 +30,30 @@ class MetatagToken {
   /**
    * Wrapper for the Token module's string parsing.
    *
-   * @param $string
-   * @param $data
+   * @param string $string
+   *   The string to parse.
+   * @param array $data
+   *   Arguments for token->replace().
    * @param array $options
+   *   Any additional options necessary.
+   * @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 mixed|string $string
+   * @return mixed|string
+   *   The processed string.
    */
-  public function replace($string, array $data = [], $options = []) {
+  public function replace($string, array $data = [], array $options = [], BubbleableMetadata $bubbleable_metadata = NULL) {
     // Set default requirements for metatag unless options specify otherwise.
     $options = $options + [
-      'clear' => TRUE
+      'clear' => TRUE,
     ];
 
-    $replaced = $this->token->replace($string, $data, $options);
+    $replaced = $this->token->replace($string, $data, $options, $bubbleable_metadata);
 
     // Ensure that there are no double-slash sequences due to empty token
     // values.
-    $replaced = preg_replace('/(?<!:)\/+\//', '/', $replaced);
+    $replaced = preg_replace('/(?<!:)(?<!)\/+\//', '/', $replaced);
 
     return $replaced;
   }
@@ -68,8 +77,8 @@ class MetatagToken {
 
     // Normalize taxonomy tokens.
     if (!empty($token_types)) {
-      $token_types = array_map(function($value) {
-        return stripos($value, 'taxonomy_') === 0 ? substr($value, strlen('taoxnomy_')) : $value;
+      $token_types = array_map(function ($value) {
+        return stripos($value, 'taxonomy_') === 0 ? substr($value, strlen('taxonomy_')) : $value;
       }, (array) $token_types);
     }