protected function TFTController::get_folder_operation_links in Taxonomy File Tree 8
Same name and namespace in other branches
- 3.x src/Controller/TFTController.php \Drupal\tft\Controller\TFTController::get_folder_operation_links()
Return an <ul> with links for the current folder.
Return value
array The render array.
Throws
\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
\Drupal\Component\Plugin\Exception\PluginNotFoundException
2 calls to TFTController::get_folder_operation_links()
- TFTController::ajaxGetFolder in src/Controller/ TFTController.php 
- Returns folder.
- TFTController::tft in src/Controller/ TFTController.php 
- File explorer.
File
- src/Controller/ TFTController.php, line 362 
Class
- TFTController
- Class TFTController.
Namespace
Drupal\tft\ControllerCode
protected function get_folder_operation_links($tid, $gid = NULL) {
  $items = [];
  // First link: got to parent.
  $parent_tid = _tft_get_parent_tid($tid);
  /** @var \Drupal\Core\TempStore\PrivateTempStore $tempstore */
  $tempstore = \Drupal::service('user.private_tempstore')
    ->get('tft');
  $root_tid = $tempstore
    ->get('root_tid');
  $query = 'destination=' . $tempstore
    ->get('q');
  $disabled = FALSE;
  if ($parent_tid > -1 && $tid != $root_tid) {
    if (!_tft_term_access($parent_tid)) {
      $disabled = TRUE;
    }
  }
  else {
    $disabled = TRUE;
  }
  $class = $disabled ? 'disabled' : '';
  $fragment = $disabled ? '#' : "#term/{$parent_tid}";
  $items[] = [
    '#wrapper_attributes' => [
      'id' => 'tft-back',
      'class' => 'folder-menu-ops-link first',
    ],
    '#type' => 'link',
    '#title' => t("parent folder"),
    '#url' => Url::fromUri("internal:{$fragment}"),
    '#attributes' => [
      'class' => $class,
      'id' => 'tft-back-link',
    ],
  ];
  // Third link: reorder child terms.
  $uri = "/tft/terms/reorder/{$tid}?{$query}";
  $group = Group::load($gid);
  $user = $this
    ->currentUser();
  if ($user
    ->hasPermission(TFT_REORDER_TERMS) || $group && $group
    ->hasPermission(TFT_REORDER_TERMS, $user)) {
    $items[] = [
      '#wrapper_attributes' => [
        'id' => 'manage-folders',
        'class' => 'folder-menu-ops-link',
      ],
      '#type' => 'link',
      '#title' => $this
        ->t("reorder elements"),
      '#url' => Url::fromUri('internal:' . $uri),
    ];
  }
  return [
    '#theme' => 'item_list',
    '#list_type' => 'ul',
    '#attributes' => [
      'class' => 'tabs primary',
      'id' => 'folder-menu-ops-links',
    ],
    '#items' => $items,
  ];
}