class Fid in Drupal 10
Same name and namespace in other branches
- 8 core/modules/file/src/Plugin/views/argument/Fid.php \Drupal\file\Plugin\views\argument\Fid
- 9 core/modules/file/src/Plugin/views/argument/Fid.php \Drupal\file\Plugin\views\argument\Fid
Argument handler to accept multiple file ids.
Plugin annotation
@ViewsArgument("file_fid");
Hierarchy
- class \Drupal\views\Plugin\views\argument\NumericArgument extends \Drupal\views\Plugin\views\argument\ArgumentPluginBase
- class \Drupal\file\Plugin\views\argument\Fid implements ContainerFactoryPluginInterface
Expanded class hierarchy of Fid
1 string reference to 'Fid'
- views.view.files.yml in core/
modules/ file/ config/ optional/ views.view.files.yml - core/modules/file/config/optional/views.view.files.yml
File
- core/
modules/ file/ src/ Plugin/ views/ argument/ Fid.php, line 17
Namespace
Drupal\file\Plugin\views\argumentView 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;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Fid:: |
protected | property | The entity type manager. | |
Fid:: |
public static | function |
Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface:: |
|
Fid:: |
public | function |
Override the behavior of titleQuery(). Get the filenames. Overrides NumericArgument:: |
|
Fid:: |
public | function | Constructs a Drupal\file\Plugin\views\argument\Fid object. | |
NumericArgument:: |
public | property | The actual value which is used for querying. | |
NumericArgument:: |
public | function | 1 | |
NumericArgument:: |
protected | function | 1 | |
NumericArgument:: |
public | function | ||
NumericArgument:: |
public | function | ||
NumericArgument:: |
public | function | 1 | |
NumericArgument:: |
public | function | 2 |