class Bundle
Same name and namespace in other branches
- 11.x core/modules/views/src/Plugin/views/filter/Bundle.php \Drupal\views\Plugin\views\filter\Bundle
- 10 core/modules/views/src/Plugin/views/filter/Bundle.php \Drupal\views\Plugin\views\filter\Bundle
- 8.9.x core/modules/views/src/Plugin/views/filter/Bundle.php \Drupal\views\Plugin\views\filter\Bundle
Filter class which allows filtering by entity bundles.
Plugin annotation
@ViewsFilter("bundle");
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements \Drupal\Component\Plugin\PluginInspectionInterface, \Drupal\Component\Plugin\DerivativeInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Messenger\MessengerTrait extends \Drupal\Component\Plugin\PluginBase
- class \Drupal\views\Plugin\views\PluginBase implements \Drupal\Core\Plugin\ContainerFactoryPluginInterface, \Drupal\views\Plugin\views\ViewsPluginInterface, \Drupal\Component\Plugin\DependentPluginInterface, \Drupal\Core\Security\TrustedCallbackInterface extends \Drupal\Core\Plugin\PluginBase
- class \Drupal\views\Plugin\views\HandlerBase implements \Drupal\views\Plugin\views\ViewsHandlerInterface extends \Drupal\views\Plugin\views\PluginBase
- class \Drupal\views\Plugin\views\filter\FilterPluginBase implements \Drupal\Core\Cache\CacheableDependencyInterface extends \Drupal\views\Plugin\views\HandlerBase
- class \Drupal\views\Plugin\views\filter\InOperator extends \Drupal\views\Plugin\views\filter\FilterPluginBase
- class \Drupal\views\Plugin\views\filter\Bundle extends \Drupal\views\Plugin\views\filter\InOperator
- class \Drupal\views\Plugin\views\filter\InOperator extends \Drupal\views\Plugin\views\filter\FilterPluginBase
- class \Drupal\views\Plugin\views\filter\FilterPluginBase implements \Drupal\Core\Cache\CacheableDependencyInterface extends \Drupal\views\Plugin\views\HandlerBase
- class \Drupal\views\Plugin\views\HandlerBase implements \Drupal\views\Plugin\views\ViewsHandlerInterface extends \Drupal\views\Plugin\views\PluginBase
- class \Drupal\views\Plugin\views\PluginBase implements \Drupal\Core\Plugin\ContainerFactoryPluginInterface, \Drupal\views\Plugin\views\ViewsPluginInterface, \Drupal\Component\Plugin\DependentPluginInterface, \Drupal\Core\Security\TrustedCallbackInterface extends \Drupal\Core\Plugin\PluginBase
- class \Drupal\Core\Plugin\PluginBase uses \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Messenger\MessengerTrait extends \Drupal\Component\Plugin\PluginBase
Expanded class hierarchy of Bundle
Related topics
175 string references to 'Bundle'
- block_content_body_field.yml in core/
modules/ block_content/ migrations/ block_content_body_field.yml - core/modules/block_content/migrations/block_content_body_field.yml
- block_content_entity_display.yml in core/
modules/ block_content/ migrations/ block_content_entity_display.yml - core/modules/block_content/migrations/block_content_entity_display.yml
- block_content_entity_form_display.yml in core/
modules/ block_content/ migrations/ block_content_entity_form_display.yml - core/modules/block_content/migrations/block_content_entity_form_display.yml
- Bundle::init in core/
modules/ views/ src/ Plugin/ views/ filter/ Bundle.php - BundleConstraint::getDefaultOption in core/
lib/ Drupal/ Core/ Entity/ Plugin/ Validation/ Constraint/ BundleConstraint.php
File
-
core/
modules/ views/ src/ Plugin/ views/ filter/ Bundle.php, line 18
Namespace
Drupal\views\Plugin\views\filterView source
class Bundle extends InOperator {
/**
* The entity type for the filter.
*
* @var string
*/
protected $entityTypeId;
/**
* The entity type definition.
*
* @var \Drupal\Core\Entity\EntityTypeInterface
*/
protected $entityType;
/**
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* The bundle info service.
*
* @var \Drupal\Core\Entity\EntityTypeBundleInfoInterface
*/
protected $bundleInfoService;
/**
* Constructs a Bundle 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.
* @param \Drupal\Core\Entity\EntityTypeBundleInfoInterface $bundle_info_service
* The bundle info service.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager, EntityTypeBundleInfoInterface $bundle_info_service) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->entityTypeManager = $entity_type_manager;
$this->bundleInfoService = $bundle_info_service;
}
/**
* {@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'), $container->get('entity_type.bundle.info'));
}
/**
* {@inheritdoc}
*/
public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
parent::init($view, $display, $options);
$this->entityTypeId = $this->getEntityType();
$this->entityType = \Drupal::entityTypeManager()->getDefinition($this->entityTypeId);
$this->real_field = $this->entityType
->getKey('bundle');
}
/**
* {@inheritdoc}
*/
public function getValueOptions() {
if (!isset($this->valueOptions)) {
$types = $this->bundleInfoService
->getBundleInfo($this->entityTypeId);
$this->valueTitle = $this->t('@entity types', [
'@entity' => $this->entityType
->getLabel(),
]);
$options = [];
foreach ($types as $type => $info) {
$options[$type] = $info['label'];
}
asort($options);
$this->valueOptions = $options;
}
return $this->valueOptions;
}
/**
* {@inheritdoc}
*/
public function query() {
// Make sure that the entity base table is in the query.
$this->ensureMyTable();
parent::query();
}
/**
* {@inheritdoc}
*/
public function calculateDependencies() {
$dependencies = parent::calculateDependencies();
$bundle_entity_type = $this->entityType
->getBundleEntityType();
$bundle_entity_storage = $this->entityTypeManager
->getStorage($bundle_entity_type);
foreach (array_keys($this->value) as $bundle) {
if ($bundle_entity = $bundle_entity_storage->load($bundle)) {
$dependencies[$bundle_entity->getConfigDependencyKey()][] = $bundle_entity->getConfigDependencyName();
}
}
return $dependencies;
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.