Render controller for taxonomy terms.
Expanded class hierarchy of TermRenderController
class TermRenderController extends EntityRenderController {
/**
* Overrides Drupal\Core\Entity\EntityRenderController::buildContent().
*/
public function buildContent(array $entities = array(), $view_mode = 'full', $langcode = NULL) {
parent::buildContent($entities, $view_mode, $langcode);
foreach ($entities as $entity) {
// Add the description if enabled.
$bundle = $entity
->bundle();
$entity_view_mode = $entity->content['#view_mode'];
$fields = field_extra_fields_get_display($this->entityType, $bundle, $entity_view_mode);
if (!empty($entity->description) && isset($fields['description']) && $fields['description']['visible']) {
$entity->content['description'] = array(
'#markup' => check_markup($entity->description, $entity->format, '', TRUE),
'#weight' => $fields['description']['weight'],
'#prefix' => '<div class="taxonomy-term-description">',
'#suffix' => '</div>',
);
}
}
}
protected function getBuildDefaults(EntityInterface $entity, $view_mode, $langcode) {
$return = parent::getBuildDefaults($entity, $view_mode, $langcode);
// TODO: rename "term" to "taxonomy_term" in theme_taxonomy_term().
$return['#term'] = $return["#{$this->entityType}"];
unset($return["#{$this->entityType}"]);
return $return;
}
protected function alterBuild(array &$build, EntityInterface $entity, $view_mode, $langcode = NULL) {
parent::alterBuild($build, $entity, $view_mode, $langcode);
$build['#attached']['css'][] = drupal_get_path('module', 'taxonomy') . '/taxonomy.css';
}
}