Commit 06baf6be authored by ziomizar's avatar ziomizar Committed by Damien McKenna
Browse files

Issue #2987107 by ziomizar: Add support for bubbeable metadata in the MetatagToken service

parent d166447c
Loading
Loading
Loading
Loading
+2
Changes for CHANGELOG.txt: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -42,6 +42,8 @@ Metatag 8.x-1.x, xxxx-xx-xx
  ZapevalovAnton, caspervoogt: Full support for meta tags that allow multiple
  values.
#2987904 by thejimbirch: Remove groups redundantly stored in the main module.
#2987107 by ziomizar: Add support for bubbeable metadata in the MetatagToken
  service.


Metatag 8.x-1.5, 2018-03-29
+6 −2
Changes for src/MetatagToken.php: 6 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@
namespace Drupal\metatag;

use Drupal\Core\Utility\Token;
use Drupal\Core\Render\BubbleableMetadata;

/**
 * Token handling service. Uses core token service or contributed Token.
@@ -35,17 +36,20 @@ class MetatagToken {
   *   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
   *   The processed string.
   */
  public function replace($string, array $data = [], array $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,
    ];

    $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.