function filebrowser_node_view in Filebrowser 8.2
Same name and namespace in other branches
- 8 filebrowser.module \filebrowser_node_view()
- 7.4 filebrowser.module \filebrowser_node_view()
- 7.2 filebrowser.module \filebrowser_node_view()
- 7.3 filebrowser.module \filebrowser_node_view()
- 3.x filebrowser.module \filebrowser_node_view()
Implements hook_ENTITY_TYPE_view(). @inheritdoc
File
- ./
filebrowser.module, line 235
Code
function filebrowser_node_view(array &$build, NodeInterface $node, EntityViewDisplayInterface $display, $view_mode) {
/** @var \Drupal\filebrowser\FilebrowserManager $manager */
/** @var \Drupal\filebrowser\Filebrowser $filebrowser*/
if ($view_mode == 'full' && $node
->bundle() == 'dir_listing') {
$manager = \Drupal::service('filebrowser.manager');
// get the argument $fid from query
$fid = \Drupal::request()->query
->get('fid');
$list = new \Drupal\filebrowser\File\DisplayFileList($node, $fid);
$display_list = $list
->get();
// Show file listing content part
if ($display
->getComponent('filebrowser_file_list')) {
$contents = $manager
->createPresentation($node, $display_list);
$build['filebrowser_file_list'] = $contents;
}
// Show the statistics of this listing
if ($display
->getComponent('filebrowser_statistics')) {
$statistics = new \Drupal\filebrowser\Statistics($display_list);
$build['filebrowser_statistics'] = $statistics
->get();
}
// we will not use cache
$build['#cache']['max-age'] = 0;
\Drupal::service('page_cache_kill_switch')
->trigger();
}
}