class SelectionEntityTypeTaxonomyTerm in Entity reference 8
Hierarchy
- class \Drupal\entityreference\Plugin\entityreference\selection\SelectionBase implements SelectionInterface
- class \Drupal\entityreference\Plugin\Type\Selection\SelectionEntityTypeTaxonomyTerm
Expanded class hierarchy of SelectionEntityTypeTaxonomyTerm
File
- lib/
Drupal/ entityreference/ Plugin/ Type/ Selection/ SelectionEntityTypeTaxonomyTerm.php, line 17 - Definition of Drupal\entityreference\Plugin\entityreference\selection\SelectionEntityTypeTaxonomyTerm.
Namespace
Drupal\entityreference\Plugin\Type\SelectionView source
class SelectionEntityTypeTaxonomyTerm extends SelectionBase {
public function entityFieldQueryAlter(AlterableInterface $query) {
// The Taxonomy module doesn't implement any proper taxonomy term access,
// and as a consequence doesn't make sure that taxonomy terms cannot be viewed
// when the user doesn't have access to the vocabulary.
$tables = $query
->getTables();
$base_table = key($tables);
$vocabulary_alias = $query
->innerJoin('taxonomy_vocabulary', 'n', '%alias.vid = ' . $base_table . '.vid');
$query
->addMetadata('base_table', $vocabulary_alias);
// Pass the query to the taxonomy access control.
$this
->reAlterQuery($query, 'taxonomy_vocabulary_access', $vocabulary_alias);
// Also, the taxonomy term entity exposes a bundle, but doesn't have a bundle
// column in the database. We have to alter the query ourself to go fetch
// the bundle.
$conditions =& $query
->conditions();
foreach ($conditions as $key => &$condition) {
if ($key !== '#conjunction' && is_string($condition['field']) && $condition['field'] === 'vocabulary_machine_name') {
$condition['field'] = $vocabulary_alias . '.machine_name';
break;
}
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
SelectionBase:: |
protected | function | Build an EntityFieldQuery to get referencable entities. | 1 |
SelectionBase:: |
public | function |
Implements EntityReferenceHandler::countReferencableEntities(). Overrides SelectionInterface:: |
|
SelectionBase:: |
public | function |
Implements EntityReferenceHandler::getReferencableEntities(). Overrides SelectionInterface:: |
|
SelectionBase:: |
protected | function | Helper method: pass a query to the alteration system again. | |
SelectionBase:: |
public static | function |
Implements EntityReferenceHandler::settingsForm(). Overrides SelectionInterface:: |
|
SelectionBase:: |
public | function |
Implements EntityReferenceHandler::validateAutocompleteInput(). Overrides SelectionInterface:: |
|
SelectionBase:: |
public | function |
Implements EntityReferenceHandler::validateReferencableEntities(). Overrides SelectionInterface:: |
|
SelectionBase:: |
public | function | ||
SelectionEntityTypeTaxonomyTerm:: |
public | function |
Implements EntityReferenceHandler::entityFieldQueryAlter(). Overrides SelectionBase:: |