1 file.entity.inc | public FileStorageController::buildContent(EntityInterface $file, $view_mode = 'full', $langcode = NULL) |
Implements EntityControllerInterface::buildContent().
Overrides DefaultEntityController::buildContent
File
- core/
modules/ file/ file.entity.inc, line 335 - Entity controller and class for files.
Class
- FileStorageController
- File storage controller for files.
Code
public function buildContent(EntityInterface $file, $view_mode = 'full', $langcode = NULL) {
global $language_content;
$langcode = $langcode ? $langcode : $language_content->langcode;
// Remove previously built content, if exists.
$file->content = array();
// In case of a multiple view, file_view_multiple() already ran the
// 'prepare_view' step. An internal flag prevents the operation from running
// twice.
// Allow modules to change the view mode.
$view_mode = key(entity_view_mode_prepare('file', array($file->fid => $file), $view_mode, $langcode));
field_attach_prepare_view('file', array($file->fid => $file), $view_mode, $langcode);
entity_prepare_view('file', array($file->fid => $file), $langcode);
// Build the actual file display.
$file->content['file'] = file_view_file($file, $view_mode, $langcode);
// Build fields content.
$file->content += field_attach_view('file', $file, $view_mode, $langcode);
$links = array();
$file->content['links'] = array(
'#theme' => 'links__file',
'#pre_render' => array('backdrop_pre_render_links'),
'#attributes' => array('class' => array('links', 'inline')),
);
$file->content['links']['file'] = array(
'#theme' => 'links__file__file',
'#links' => $links,
'#attributes' => array('class' => array('links', 'inline')),
);
// Allow modules to make their own additions to the file.
module_invoke_all('file_view', $file, $view_mode, $langcode);
module_invoke_all('entity_view', $file, 'file', $view_mode, $langcode);
}