AllExceptHostEntity.php
Same filename in other branches
Namespace
Drupal\entity_reference_test\Plugin\EntityReferenceSelectionFile
-
core/
modules/ system/ tests/ modules/ entity_reference_test/ src/ Plugin/ EntityReferenceSelection/ AllExceptHostEntity.php
View source
<?php
namespace Drupal\entity_reference_test\Plugin\EntityReferenceSelection;
use Drupal\Core\Entity\Attribute\EntityReferenceSelection;
use Drupal\Core\Entity\Plugin\EntityReferenceSelection\DefaultSelection;
use Drupal\Core\StringTranslation\TranslatableMarkup;
/**
* Allows access to all entities except for the host entity.
*/
class AllExceptHostEntity extends DefaultSelection {
/**
* {@inheritdoc}
*/
protected function buildEntityQuery($match = NULL, $match_operator = 'CONTAINS') {
$query = parent::buildEntityQuery($match, $match_operator);
/** @var \Drupal\Core\Entity\EntityInterface $entity */
if ($entity = $this->configuration['entity']) {
$target_type = $this->configuration['target_type'];
$entity_type = $this->entityTypeManager
->getDefinition($target_type);
$query->condition($entity_type->getKey('id'), $entity->id(), '<>');
}
return $query;
}
}
Classes
Title | Deprecated | Summary |
---|---|---|
AllExceptHostEntity | Allows access to all entities except for the host entity. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.