public function MultipleRegistrationController::index in Multiple Registration 3.x
Same name and namespace in other branches
- 8.2 src/Controller/MultipleRegistrationController.php \Drupal\multiple_registration\Controller\MultipleRegistrationController::index()
- 8 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 175
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;
if ($role['hidden'] === 1) {
$isHiddenLabel = $this
->t('Yes');
}
else {
$isHiddenLabel = $this
->t('No');
}
$row[] = $isHiddenLabel;
$row[] = $role['form_mode_register'];
$row[] = $role['form_mode_edit'];
$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%"}',
],
]);
$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[] = [
'data' => [
'#type' => 'dropbutton',
'#links' => [
'edit' => [
'title' => $this
->t('Edit'),
'url' => $edit_url,
],
'remove' => [
'title' => $this
->t('Remove'),
'url' => $remove_url,
],
],
],
];
$rows[] = [
'data' => $row,
];
}
$header = [
$this
->t('Role'),
$this
->t('Registration page path'),
$this
->t('Hidden'),
$this
->t('Register form mode'),
$this
->t('Edit form mode'),
[
'data' => $this
->t('Operations'),
],
];
$output = [
'#theme' => 'table',
'#header' => $header,
'#rows' => $rows,
'#attributes' => [
'id' => 'user-roles-reg-pages',
],
'#attached' => [
'library' => [
'core/drupal.dialog.ajax',
],
],
'#empty' => $this
->t('No custom Role registration pages defined'),
];
}
else {
$add_reg_pages_link = Link::fromTextAndUrl($this
->t('here'), Url::fromRoute('entity.user_role.collection'))
->toString();
$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%"}',
],
]);
$access_settings_url = Url::fromRoute('multiple_registration.access_settings_page_form', [], [
'attributes' => [
'class' => 'use-ajax',
'data-accepts' => 'application/vnd.drupal-modal',
'data-dialog-type' => 'modal',
'data-dialog-options' => '{"width": "50%"}',
],
]);
// Adding reminder for configuring multiple registration pages access.
$access_settings_reminder = Markup::create("Don't forget to configure " . Link::fromTextAndUrl($this
->t('Multiple Registration pages access settings'), $access_settings_url)
->toString() . ' before start using this module.');
$this
->messenger()
->addWarning($access_settings_reminder);
// Adding multiple registration setting links.
$output['#suffix'] = '<p>' . Link::fromTextAndUrl($this
->t('Common settings'), $common_settings_url)
->toString() . '</p>';
$output['#suffix'] .= '<p>' . Link::fromTextAndUrl($this
->t('Multiple Registration pages access settings'), $access_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;
}