public function OrganigramsController::viewOrganigram in Organigrams 8
Same name and namespace in other branches
- 8.2 src/Controller/OrganigramsController.php \Drupal\organigrams\Controller\OrganigramsController::viewOrganigram()
Returns a form to add a new term to a vocabulary.
Parameters
\Drupal\taxonomy\VocabularyInterface $taxonomy_vocabulary: The vocabulary this term will be added to.
Return value
array The organigram as a render array.
1 string reference to 'OrganigramsController::viewOrganigram'
File
- src/Controller/ OrganigramsController.php, line 60 
Class
- OrganigramsController
- Provides route responses for organigrams.module.
Namespace
Drupal\organigrams\ControllerCode
public function viewOrganigram(VocabularyInterface $taxonomy_vocabulary) {
  $output = [];
  // Check for permission.
  if (!$this
    ->currentUser()
    ->hasPermission('view organigrams')) {
    return $output;
  }
  // Construct the orgchart settings.
  $organigram_settings = [
    'organigram_settings' => $taxonomy_vocabulary
      ->getThirdPartySettings('organigrams'),
    'nodes' => [],
  ];
  // Use our own service to get the hierarchical overview of taxonomy terms
  // in this vocabulary.
  $output = $this->taxonomyTermTree
    ->loadList($taxonomy_vocabulary
    ->id());
  // Include the excanvas library if it exists.
  $output['#attached']['library'][] = 'organigrams/explorercanvas';
  // Include the orgchart library.
  $output['#attached']['library'][] = 'organigrams/orgchart';
  // Include the organigram content loader.
  $output['#attached']['library'][] = 'organigrams/organigrams';
  // Add the organigram to the organigrams list.
  $output['#attached']['drupalSettings']['organigrams']['organigrams'] = [
    $taxonomy_vocabulary
      ->id() => $organigram_settings,
  ];
  return $output;
}