protected function TFTController::tft in Taxonomy File Tree 8
Same name and namespace in other branches
- 3.x 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 433 
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('user.private_tempstore')
    ->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,
      '#ops_links' => $this
        ->get_folder_operation_links($tid, $gid),
    ],
    // 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,
      ],
    ],
  ];
}