protected function TFTController::get_content in Taxonomy File Tree 8
Same name and namespace in other branches
- 3.x src/Controller/TFTController.php \Drupal\tft\Controller\TFTController::get_content()
Returns folder content.
Return value
array The folder content
Throws
\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
\Drupal\Component\Plugin\Exception\PluginNotFoundException
1 call to TFTController::get_content()
- TFTController::content_table in src/
Controller/ TFTController.php - Get the folder content in HTML table form.
File
- src/
Controller/ TFTController.php, line 170
Class
- TFTController
- Class TFTController.
Namespace
Drupal\tft\ControllerCode
protected function get_content($tid, $gid = NULL) {
$content = [];
$elements = _tft_folder_content($tid, FALSE, $gid);
foreach ($elements as $element) {
if ($element['type'] == 'term') {
$content[] = [
$this
->link($element, 'folder'),
'',
'',
$this
->t("Folder"),
$this
->operation_links('folder', $element['id'], NULL, $gid),
];
}
else {
/** @var \Drupal\media\Entity\Media $media */
$media = Media::load($element['id']);
$user = $media
->getOwner();
$fids = $media
->get('tft_file')
->getValue();
if (!empty($fids)) {
$fid = reset($fids)['target_id'];
$file = File::load($fid);
$file_name = $file
->getFilename();
$file_name_parts = explode('.', $file_name);
$file_extension = end($file_name_parts);
$content[] = [
$this
->link($element, $file
->getMimeType()),
$user
->getDisplayName(),
date('d/m/Y H:i', $media
->getChangedTime()),
$this
->t('@type file', [
'@type' => strtoupper($file_extension),
]),
$this
->operation_links('file', $element['id'], $media, $gid),
];
}
elseif (!empty($link = $media
->get('opigno_moxtra_recording_link')
->getValue())) {
$content[] = [
$this
->link($element, 'video/mp4', 'record'),
$user
->getDisplayName(),
date('d/m/Y H:i', $media
->getChangedTime()),
$this
->t('MP4 file'),
$this
->operation_links('file', $element['id'], $media, $gid),
];
}
}
}
// Fix error in jquery.tablesorter if table is empty.
if (empty($elements)) {
$content[] = [
'',
'',
'',
'',
'',
];
}
return $content;
}