Fid.php

Same filename in this branch
  1. 9 core/modules/file/src/Plugin/views/argument/Fid.php
Same filename and directory in other branches
  1. 8.9.x core/modules/file/src/Plugin/views/argument/Fid.php
  2. 8.9.x core/modules/aggregator/src/Plugin/views/argument/Fid.php
  3. 10 core/modules/file/src/Plugin/views/argument/Fid.php
  4. 11.x core/modules/file/src/Plugin/views/argument/Fid.php

Namespace

Drupal\aggregator\Plugin\views\argument

File

core/modules/aggregator/src/Plugin/views/argument/Fid.php

View source
<?php

namespace Drupal\aggregator\Plugin\views\argument;

use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\views\Plugin\views\argument\NumericArgument;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
 * Argument handler to accept an aggregator feed id.
 *
 * @ingroup views_argument_handlers
 *
 * @ViewsArgument("aggregator_fid")
 */
class Fid extends NumericArgument {
    
    /**
     * The entity type manager.
     *
     * @var \Drupal\Core\Entity\EntityTypeManagerInterface
     */
    protected $entityTypeManager;
    
    /**
     * Constructs a \Drupal\aggregator\Plugin\views\argument\Fid object.
     *
     * @param array $configuration
     *   A configuration array containing information about the plugin instance.
     * @param string $plugin_id
     *   The plugin_id for the plugin instance.
     * @param mixed $plugin_definition
     *   The plugin implementation definition.
     * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
     *   The entity type manager.
     */
    public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager) {
        parent::__construct($configuration, $plugin_id, $plugin_definition);
        $this->entityTypeManager = $entity_type_manager;
    }
    
    /**
     * {@inheritdoc}
     */
    public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
        return new static($configuration, $plugin_id, $plugin_definition, $container->get('entity_type.manager'));
    }
    
    /**
     * {@inheritdoc}
     */
    public function titleQuery() {
        $titles = [];
        $feeds = $this->entityTypeManager
            ->getStorage('aggregator_feed')
            ->loadMultiple($this->value);
        foreach ($feeds as $feed) {
            $titles[] = $feed->label();
        }
        return $titles;
    }

}

Classes

Title Deprecated Summary
Fid Argument handler to accept an aggregator feed id.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.