class NodeSelection

Provides specific access control for the node entity type.

Plugin annotation


@Plugin(
  id = "node_default",
  module = "node",
  label = @Translation("Node selection"),
  entity_types = {"node"},
  group = "default",
  weight = 1
)

Hierarchy

Expanded class hierarchy of NodeSelection

File

drupal/core/modules/node/lib/Drupal/node/Plugin/entity_reference/selection/NodeSelection.php, line 27
Contains \Drupal\node\Plugin\Type\selection\NodeSelection.

Namespace

Drupal\node\Plugin\entity_reference\selection
View source
class NodeSelection extends SelectionBase {

  /**
   * Overrides SelectionBase::buildEntityQuery().
   */
  public function buildEntityQuery($match = NULL, $match_operator = 'CONTAINS') {
    $query = parent::buildEntityQuery($match, $match_operator);

    // Adding the 'node_access' tag is sadly insufficient for nodes: core
    // requires us to also know about the concept of 'published' and
    // 'unpublished'. We need to do that as long as there are no access control
    // modules in use on the site. As long as one access control module is there,
    // it is supposed to handle this check.
    if (!user_access('bypass node access') && !count(module_implements('node_grants'))) {
      $query
        ->condition('status', NODE_PUBLISHED);
    }
    return $query;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
NodeSelection::buildEntityQuery public function Overrides SelectionBase::buildEntityQuery(). Overrides SelectionBase::buildEntityQuery
SelectionBase::$entity protected property The entity object, or NULL
SelectionBase::$field protected property The field array.
SelectionBase::$instance protected property The instance array.
SelectionBase::countReferencableEntities public function Implements SelectionInterface::countReferencableEntities(). Overrides SelectionInterface::countReferencableEntities
SelectionBase::entityQueryAlter public function Implements SelectionInterface::entityQueryAlter(). Overrides SelectionInterface::entityQueryAlter 3
SelectionBase::getReferencableEntities public function Implements SelectionInterface::getReferencableEntities(). Overrides SelectionInterface::getReferencableEntities 1
SelectionBase::reAlterQuery protected function Helper method: Passes a query to the alteration system again.
SelectionBase::settingsForm public static function Implements SelectionInterface::settingsForm(). Overrides SelectionInterface::settingsForm 2
SelectionBase::validateAutocompleteInput public function Implements SelectionInterface::validateAutocompleteInput(). Overrides SelectionInterface::validateAutocompleteInput
SelectionBase::validateReferencableEntities public function Implements SelectionInterface::validateReferencableEntities(). Overrides SelectionInterface::validateReferencableEntities
SelectionBase::__construct public function Constructs a SelectionBase object.