function FieldPluginBase::getEntity
Same name in other branches
- 9 core/modules/views/src/Plugin/views/field/FieldPluginBase.php \Drupal\views\Plugin\views\field\FieldPluginBase::getEntity()
- 8.9.x core/modules/views/src/Plugin/views/field/FieldPluginBase.php \Drupal\views\Plugin\views\field\FieldPluginBase::getEntity()
- 11.x core/modules/views/src/Plugin/views/field/FieldPluginBase.php \Drupal\views\Plugin\views\field\FieldPluginBase::getEntity()
Overrides FieldHandlerInterface::getEntity
20 calls to FieldPluginBase::getEntity()
- BulkForm::viewsForm in core/
modules/ views/ src/ Plugin/ views/ field/ BulkForm.php - Form constructor for the bulk form.
- CommentedEntity::getItems in core/
modules/ comment/ src/ Plugin/ views/ field/ CommentedEntity.php - Gets an array of items for the field.
- ContactLink::getUrlInfo in core/
modules/ contact/ src/ Plugin/ views/ field/ ContactLink.php - Returns the URI elements of the link.
- ContactLink::renderLink in core/
modules/ contact/ src/ Plugin/ views/ field/ ContactLink.php - Prepares the link to view an entity.
- EntityField::getItems in core/
modules/ views/ src/ Plugin/ views/ field/ EntityField.php - Gets an array of items for the field.
File
-
core/
modules/ views/ src/ Plugin/ views/ field/ FieldPluginBase.php, line 427
Class
- FieldPluginBase
- Base class for views fields.
Namespace
Drupal\views\Plugin\views\fieldCode
public function getEntity(ResultRow $values) {
$relationship_id = $this->options['relationship'];
$entity = NULL;
if ($relationship_id == 'none') {
$entity = $values->_entity;
}
elseif (isset($values->_relationship_entities[$relationship_id])) {
$entity = $values->_relationship_entities[$relationship_id];
}
if ($entity === NULL) {
// Don't log an error if we're getting an entity for an optional
// relationship.
if ($relationship_id !== 'none') {
$relationship = $this->view->relationship[$relationship_id] ?? NULL;
if ($relationship && !$relationship->options['required']) {
return NULL;
}
}
\Drupal::logger('views')->error('The view %id failed to load an entity of type %entity_type at row %index for field %field', [
'%id' => $this->view
->id(),
'%entity_type' => $this->configuration['entity_type'],
'%index' => $values->index,
'%field' => $this->label() ?: $this->realField,
]);
return NULL;
}
return $entity;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.