public function MultipleRegistrationController::index in Multiple Registration 8
Same name and namespace in other branches
- 8.2 src/Controller/MultipleRegistrationController.php \Drupal\multiple_registration\Controller\MultipleRegistrationController::index()
- 3.x src/Controller/MultipleRegistrationController.php \Drupal\multiple_registration\Controller\MultipleRegistrationController::index()
Page with registration pages list.
Return value
array Returns index.
Throws
\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
\Drupal\Component\Plugin\Exception\PluginNotFoundException
1 string reference to 'MultipleRegistrationController::index'
File
- src/
Controller/ MultipleRegistrationController.php, line 93
Class
- MultipleRegistrationController
- Class MultipleRegistrationController.
Namespace
Drupal\multiple_registration\ControllerCode
public function index() {
$regPages = $this->availableUserRolesService
->getRegistrationPages();
if ($regPages) {
foreach ($regPages as $rid => $role) {
$row = [];
$row[] = $role['role_name'];
$path_alias = $this->aliasManager
->getAliasByPath($role['url']);
$row[] = $path_alias;
$isHiddenLabel = $role['hidden'] == 1 ? $this
->t("Yes") : $this
->t('No');
$row[] = $isHiddenLabel;
$edit_url = Url::fromRoute("multiple_registration.create_registration_page_form", [
'rid' => $rid,
], [
'attributes' => [
'class' => 'use-ajax',
'data-accepts' => 'application/vnd.drupal-modal',
'data-dialog-type' => 'modal',
'data-dialog-options' => '{"width": "50%"}',
],
]);
$row[] = Link::fromTextAndUrl($this
->t('Edit'), $edit_url);
$remove_url = Url::fromRoute("multiple_registration.delete_registration_page_form", [
'rid' => $rid,
], [
'attributes' => [
'class' => 'use-ajax',
'data-accepts' => 'application/vnd.drupal-modal',
'data-dialog-type' => 'modal',
'data-dialog-options' => '{"width": "50%"}',
],
]);
$row[] = Link::fromTextAndUrl($this
->t('Remove'), $remove_url);
$rows[] = [
'data' => $row,
];
}
$header = [
$this
->t('Role'),
$this
->t('Registration page path'),
$this
->t('Hidden'),
[
'data' => $this
->t('Operations'),
'colspan' => 2,
],
];
$output = [
'#theme' => 'table',
'#header' => $header,
'#rows' => $rows,
'#attributes' => [
'id' => 'user-roles-reg-pages',
],
'#attached' => [
'library' => [
'core/drupal.dialog.ajax',
],
],
];
}
else {
$add_reg_pages_link = Link::fromTextAndUrl($this
->t('here'), Url::fromRoute('entity.user_role.collection'));
$output = [
'#markup' => $this
->t('There are no additional registration pages created yet. You can add new pages %here', [
'%here' => $add_reg_pages_link,
]),
];
}
$common_settings_url = Url::fromRoute("multiple_registration.common_settings_page_form", [], [
'attributes' => [
'class' => 'use-ajax',
'data-accepts' => 'application/vnd.drupal-modal',
'data-dialog-type' => 'modal',
'data-dialog-options' => '{"width": "50%"}',
],
]);
$output['#suffix'] = '<p>' . Link::fromTextAndUrl($this
->t('Common settings'), $common_settings_url)
->toString() . '</p>';
$output['#suffix'] .= '<p>' . Link::fromTextAndUrl($this
->t('Go to Roles managing page'), Url::fromRoute('entity.user_role.collection'))
->toString() . '</p>';
return $output;
}