protected function SearchApiEntityField::getEntityFieldRenderer in Search API 8
Returns the entity field renderer.
Return value
\Drupal\views\Entity\Render\EntityFieldRenderer The entity field renderer.
Overrides EntityField::getEntityFieldRenderer
File
- src/
Plugin/ views/ field/ SearchApiEntityField.php, line 265
Class
- SearchApiEntityField
- Displays entity field data.
Namespace
Drupal\search_api\Plugin\views\fieldCode
protected function getEntityFieldRenderer() {
if (!isset($this->entityFieldRenderer)) {
// This can be invoked during field handler initialization in which case
// view fields are not set yet.
foreach ($this->view->field ?? [] as $field) {
// An entity field renderer can handle only a single relationship.
if (($field->entityFieldRenderer ?? NULL) instanceof EntityFieldRenderer && $field->entityFieldRenderer
->compatibleWithField($this)) {
$this->entityFieldRenderer = $field->entityFieldRenderer;
break;
}
}
if (!isset($this->entityFieldRenderer)) {
$entity_type = $this->entityTypeManager
->getDefinition($this
->getEntityType());
$this->entityFieldRenderer = new EntityFieldRenderer($this->view, $this->relationship, $this->languageManager, $entity_type, $this->entityTypeManager, $this->entityRepository);
$this->entityFieldRenderer
->setDatasourceId($this
->getDatasourceId())
->setParentPath($this
->getParentPath());
}
}
return $this->entityFieldRenderer;
}