You are here

public function OpignoGroupManagerController::index in Opigno group manager 8

Same name and namespace in other branches
  1. 3.x src/Controller/OpignoGroupManagerController.php \Drupal\opigno_group_manager\Controller\OpignoGroupManagerController::index()

Root page for angular app.

1 string reference to 'OpignoGroupManagerController::index'
opigno_group_manager.routing.yml in ./opigno_group_manager.routing.yml
opigno_group_manager.routing.yml

File

src/Controller/OpignoGroupManagerController.php, line 77

Class

OpignoGroupManagerController
Controller for all the actions of the Opigno group manager app.

Namespace

Drupal\opigno_group_manager\Controller

Code

public function index(Group $group, Request $request) {

  // Check if user has uncompleted steps.
  LearningPathValidator::stepsValidate($group);
  if ($group instanceof GroupInterface) {
    $current_step = opigno_learning_path_get_current_step();
    $next_step = $current_step < 5 ? $current_step + 1 : NULL;
    $link_text = !$next_step ? $this
      ->t('Publish') : $this
      ->t('Next');
    $next_link = Link::createFromRoute($link_text, 'opigno_learning_path.content_steps', [
      'group' => $group
        ->id(),
      'current' => $current_step ? $current_step : 0,
    ], [
      'attributes' => [
        'class' => [
          'btn',
          'btn-success',
          'color-white',
        ],
      ],
    ])
      ->toRenderable();
  }
  $tempstore = \Drupal::service('user.private_tempstore')
    ->get('opigno_group_manager');
  return [
    '#theme' => 'opigno_group_manager',
    '#attached' => [
      'library' => [
        'opigno_group_manager/manage_app',
      ],
    ],
    '#base_path' => $request
      ->getBasePath(),
    '#base_href' => $request
      ->getPathInfo(),
    '#group_id' => $group
      ->id(),
    '#next_link' => isset($next_link) ? render($next_link) : NULL,
    '#user_has_info_card' => $tempstore
      ->get('hide_info_card') ? FALSE : TRUE,
    '#text_add_a_link' => $this
      ->t('add a link')
      ->render(),
    '#text_add_your_first_item' => $this
      ->t('Add your first item')
      ->render(),
    '#text_guided_navigation' => $this
      ->t('Guided navigation')
      ->render(),
    '#text_free_navigation' => $this
      ->t('Free navigation')
      ->render(),
    '#text_if_entity_dropped_under_children' => $this
      ->t('Cannot drop under or at the same level as children, move children before')
      ->render(),
    '#text_cannot_drop_over_or_at_the_same_level' => $this
      ->t('Cannot drop over or at the same level as parent')
      ->render(),
    '#text_click_now_on_the_two_steps_of_your_training' => $this
      ->t('Click now on the two steps of your training to be linked in order to create the link')
      ->render(),
    '#text_status_message' => $this
      ->t('Status message')
      ->render(),
    '#text_conditions' => $this
      ->t('Conditions')
      ->render(),
    '#text_score' => $this
      ->t('Score:')
      ->render(),
    '#text_edit' => $this
      ->t('edit')
      ->render(),
    '#text_delete' => $this
      ->t('delete')
      ->render(),
    '#text_last_step' => $this
      ->t('Last step:')
      ->render(),
    '#text_add' => $this
      ->t('add')
      ->render(),
    '#text_validate' => $this
      ->t('Validate')
      ->render(),
    '#text_cancel' => $this
      ->t('cancel')
      ->render(),
    '#text_delete_link' => $this
      ->t('delete link')
      ->render(),
    '#text_this_action_create_an_orphan' => $this
      ->t('This action create an orphan, confirm:')
      ->render(),
    '#text_confirm' => $this
      ->t('confirm')
      ->render(),
    '#language_prefix' => opigno_group_manager_get_language_prefix(),
  ];
}