class BlockContentSelection
Provides specific selection control for the block_content entity type.
Attributes
#[EntityReferenceSelection(id: "default:block_content", label: new TranslatableMarkup("Block content selection"), group: "default", weight: 1, entity_types: [
"block_content",
])]
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements \Drupal\Component\Plugin\PluginInspectionInterface, \Drupal\Component\Plugin\DerivativeInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses \Drupal\Core\DependencyInjection\AutowiredInstanceTrait, \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Messenger\MessengerTrait extends \Drupal\Component\Plugin\PluginBase
- class \Drupal\Core\Plugin\ConfigurablePluginBase implements \Drupal\Component\Plugin\ConfigurableInterface uses \Drupal\Core\Plugin\ConfigurableTrait extends \Drupal\Core\Plugin\PluginBase
- class \Drupal\Core\Entity\EntityReferenceSelection\SelectionPluginBase implements \Drupal\Core\Entity\EntityReferenceSelection\SelectionInterface, \Drupal\Component\Plugin\DependentPluginInterface extends \Drupal\Core\Plugin\ConfigurablePluginBase
- class \Drupal\Core\Entity\Plugin\EntityReferenceSelection\DefaultSelection implements \Drupal\Core\Plugin\ContainerFactoryPluginInterface, \Drupal\Core\Entity\EntityReferenceSelection\SelectionWithAutocreateInterface extends \Drupal\Core\Entity\EntityReferenceSelection\SelectionPluginBase
- class \Drupal\block_content\Plugin\EntityReferenceSelection\BlockContentSelection extends \Drupal\Core\Entity\Plugin\EntityReferenceSelection\DefaultSelection
- class \Drupal\Core\Entity\Plugin\EntityReferenceSelection\DefaultSelection implements \Drupal\Core\Plugin\ContainerFactoryPluginInterface, \Drupal\Core\Entity\EntityReferenceSelection\SelectionWithAutocreateInterface extends \Drupal\Core\Entity\EntityReferenceSelection\SelectionPluginBase
- class \Drupal\Core\Entity\EntityReferenceSelection\SelectionPluginBase implements \Drupal\Core\Entity\EntityReferenceSelection\SelectionInterface, \Drupal\Component\Plugin\DependentPluginInterface extends \Drupal\Core\Plugin\ConfigurablePluginBase
- class \Drupal\Core\Plugin\ConfigurablePluginBase implements \Drupal\Component\Plugin\ConfigurableInterface uses \Drupal\Core\Plugin\ConfigurableTrait extends \Drupal\Core\Plugin\PluginBase
- class \Drupal\Core\Plugin\PluginBase uses \Drupal\Core\DependencyInjection\AutowiredInstanceTrait, \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Messenger\MessengerTrait extends \Drupal\Component\Plugin\PluginBase
Expanded class hierarchy of BlockContentSelection
1 file declares its use of BlockContentSelection
- BlockContentHooks.php in core/
modules/ block_content/ src/ Hook/ BlockContentHooks.php
File
-
core/
modules/ block_content/ src/ Plugin/ EntityReferenceSelection/ BlockContentSelection.php, line 15
Namespace
Drupal\block_content\Plugin\EntityReferenceSelectionView source
class BlockContentSelection extends DefaultSelection {
/**
* {@inheritdoc}
*/
protected function buildEntityQuery($match = NULL, $match_operator = 'CONTAINS') {
$query = parent::buildEntityQuery($match, $match_operator);
// Only reusable blocks should be able to be referenced.
$query->condition('reusable', TRUE);
return $query;
}
/**
* {@inheritdoc}
*/
public function validateReferenceableNewEntities(array $entities) {
$entities = parent::validateReferenceableNewEntities($entities);
// Mirror the conditions checked in buildEntityQuery().
return array_filter($entities, static fn(BlockContentInterface $blockContent) => $blockContent->isReusable());
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.