protected function TFTController::tft in Taxonomy File Tree 3.x
Same name and namespace in other branches
- 8 src/Controller/TFTController.php \Drupal\tft\Controller\TFTController::tft()
File explorer.
2 calls to TFTController::tft()
- TFTController::listDirectory in src/
Controller/ TFTController.php - Returns directory list.
- TFTController::listGroup in src/
Controller/ TFTController.php - Returns group list.
File
- src/
Controller/ TFTController.php, line 438
Class
- TFTController
- Class TFTController.
Namespace
Drupal\tft\ControllerCode
protected function tft($tid = 'all', $gid = NULL) {
if ($tid == 'all' || !(int) $tid) {
if ($this
->currentUser()
->hasPermission(TFT_ACCESS_FULL_TREE)) {
$tid = 0;
}
else {
throw new AccessDeniedHttpException();
}
}
// Check if the user has access to this tree.
if (!_tft_term_access($tid)) {
throw new AccessDeniedHttpException();
}
if ($tid) {
$term = Term::load($tid);
$name = $term
->getName();
}
else {
$name = $this
->t("Root");
}
/** @var \Drupal\Core\TempStore\PrivateTempStore $tempstore */
$tempstore = \Drupal::service('tempstore.private')
->get('tft');
$base_path = base_path();
$base_path = strlen($base_path) == '/' ? '' : substr($base_path, 0, -1);
// Store the URL query. Need the current path for some AJAX callbacks.
$tempstore
->set('q', $base_path . \Drupal::service('path.current')
->getPath());
// Store the current term tid.
$tempstore
->set('root_tid', $tid);
$path = drupal_get_path('module', 'tft');
return [
// Get the themed title bar.
[
'#theme' => 'tft_folder_menu',
'#name' => $name,
'#path' => $path,
],
// Prepare the folder content area.
[
'#type' => 'container',
'#attributes' => [
'id' => 'folder-content-container',
],
'content' => $this::content_table($tid, $gid),
],
// Add CSS and Javascript files.
'#attached' => [
'library' => [
'tft/tft',
],
'drupalSettings' => [
'tftDirectory' => $path,
],
],
];
}