You are here

Id.php in Recipe 8.2

File

modules/ingredient/src/Plugin/views/argument/Id.php
View source
<?php

namespace Drupal\ingredient\Plugin\views\argument;

use Drupal\ingredient\Entity\Ingredient;
use Drupal\views\Plugin\views\argument\NumericArgument;

/**
 * Argument handler to accept an ingredient id.
 *
 * @ViewsArgument("ingredient_id")
 */
class Id extends NumericArgument {

  /**
   * Override the behavior of title(). Get the title of the node.
   */
  public function titleQuery() {
    $titles = [];
    $ingredients = Ingredient::loadMultiple($this->value);
    foreach ($ingredients as $ingredient) {
      $titles[] = $ingredient
        ->label();
    }
    return $titles;
  }

}

Classes

Namesort descending Description
Id Argument handler to accept an ingredient id.