class Fid

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

Argument handler to accept multiple file ids.

Plugin annotation

@ViewsArgument("file_fid");

Hierarchy

Expanded class hierarchy of Fid

Related topics

55 string references to 'Fid'
AggregatorFeedViewsData::getViewsData in core/modules/aggregator/src/AggregatorFeedViewsData.php
ContentEntityTest::testFileSource in core/modules/migrate_drupal/tests/src/Kernel/Plugin/migrate/source/ContentEntityTest.php
Tests file source plugin.
d6_aggregator_feed.yml in core/modules/aggregator/migrations/d6_aggregator_feed.yml
core/modules/aggregator/migrations/d6_aggregator_feed.yml
d6_aggregator_item.yml in core/modules/aggregator/migrations/d6_aggregator_item.yml
core/modules/aggregator/migrations/d6_aggregator_item.yml
d6_upload.yml in core/modules/file/migrations/d6_upload.yml
core/modules/file/migrations/d6_upload.yml

... See full list

File

core/modules/file/src/Plugin/views/argument/Fid.php, line 17

Namespace

Drupal\file\Plugin\views\argument
View source
class Fid extends NumericArgument implements ContainerFactoryPluginInterface {
  
  /**
   * The entity type manager.
   *
   * @var \Drupal\Core\Entity\EntityTypeManagerInterface
   */
  protected $entityTypeManager;
  
  /**
   * Constructs a Drupal\file\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'));
  }
  
  /**
   * Override the behavior of titleQuery(). Get the filenames.
   */
  public function titleQuery() {
    $storage = $this->entityTypeManager
      ->getStorage('file');
    $fids = $storage->getQuery()
      ->accessCheck(FALSE)
      ->condition('fid', $this->value, 'IN')
      ->execute();
    $files = $storage->loadMultiple($fids);
    $titles = [];
    foreach ($files as $file) {
      $titles[] = $file->getFilename();
    }
    return $titles;
  }

}

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