public function CivicrmEntityController::buildContent in CiviCRM Entity 7.2
Implements EntityAPIControllerInterface.
Parameters
$content: Optionally. Allows pre-populating the built content to ease overriding this method.
Overrides EntityAPIController::buildContent
File
- ./
civicrm_entity_controller.inc, line 263
Class
- CivicrmEntityController
- Entity Controller for CiviCRM entities
Code
public function buildContent($entity, $view_mode = 'full', $langcode = NULL, $content = array()) {
$entity->content = $content;
$build = parent::buildContent($entity, $view_mode, $langcode, $content);
$langcode = isset($langcode) ? $langcode : $GLOBALS['language_content']->language;
// Add in fields.
if (!empty($this->entityInfo['fieldable'])) {
// Perform the preparation tasks if they have not been performed yet.
// An internal flag prevents the operation from running twice.
$key = isset($entity->{$this->idKey}) ? $entity->{$this->idKey} : NULL;
field_attach_prepare_view($this->entityType, array(
$key => $entity,
), $view_mode);
$entity->content = field_attach_view($this->entityType, $entity, $view_mode, $langcode);
}
$temp_build = $entity->content;
unset($entity->content);
foreach ($temp_build as $key => $value) {
$build[$key] = $value;
}
if (module_exists('ds')) {
$layout = ds_get_layout($this->entityType, $this->entityType, $view_mode);
if (!empty($layout['css']) && empty($layout['settings']['layout_disable_css'])) {
// Add css file.
if (isset($layout['module']) && $layout['module'] == 'panels') {
$build['#attached']['css'][] = $layout['path'] . '/' . $layout['panels']['css'];
}
else {
$build['#attached']['css'][] = $layout['path'] . '/' . $layout['layout'] . '.css';
}
}
}
return $build;
}