Commit ba4369fd authored by davidajnered's avatar davidajnered Committed by Christopher C. Wells
Browse files

Issue #3222429 by nanak, khiem.nguyen, vitalius2009, kyberman, wells,...

Issue #3222429 by nanak, khiem.nguyen, vitalius2009, kyberman, wells, davidajnered, mchamps, ppblaauw, cristianalcaraz, Petr Illek, t.maquin, kaszarobert, oxy86, jlj, DamienMcKenna, Guy Spriggs: Error: Call to undefined method Drupal\views\Render\ViewsRenderPipelineMarkup::render()
parent e1a03916
Loading
Loading
Loading
Loading
+43 −3
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@
namespace Drupal\schema_metatag\Plugin\schema_metatag\PropertyType;

use Drupal\Core\Url;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
 * Provides a plugin for the 'ItemListElement' Schema.org property type.
@@ -20,6 +21,45 @@
 */
class BreadcrumbList extends ItemListElement {

  /**
   * Breadcrumb manager.
   *
   * @var \Drupal\Core\Breadcrumb\BreadcrumbManager
   */
  protected $breadcrumbManager;

  /**
   * Renderer.
   *
   * @var \Drupal\Core\Render\Renderer
   */
  protected $renderer;

  /**
   * Current route match.
   *
   * @var \Drupal\Core\Routing\CurrentRouteMatch
   */
  protected $routeMatch;

  /**
   * {@inheritDoc}
   */
  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
    $instance = parent::create(
      $container,
      $configuration,
      $plugin_id,
      $plugin_definition
    );

    $instance->breadcrumbManager = $container->get('breadcrumb');
    $instance->renderer = $container->get('renderer');
    $instance->routeMatch = $container->get('current_route_match');

    return $instance;
  }

  /**
   * {@inheritdoc}
   */
@@ -68,8 +108,8 @@ public function outputValue($input_value) {
  public function getItems($input_value) {
    $values = [];
    if (!empty($input_value)) {
      $entity_route = \Drupal::service('current_route_match')->getCurrentRouteMatch();
      $breadcrumbs = \Drupal::service('breadcrumb')->build($entity_route)->getLinks();
      $entity_route = $this->routeMatch->getCurrentRouteMatch();
      $breadcrumbs = $this->breadcrumbManager->build($entity_route)->getLinks();
      $key = 1;
      foreach ($breadcrumbs as $item) {
        // Modules that add the current page to the breadcrumb set it to an
@@ -79,7 +119,7 @@ public function getItems($input_value) {
          $url = Url::fromRoute('<current>')->setAbsolute()->toString();
        }
        $text = $item->getText();
        $text = is_object($text) ? $text->render() : $text;
        $text = is_array($text) ? $this->renderer->renderPlain($text) : $text;
        $values[$key] = [
          '@id' => $url,
          'name' => $text,