public function LoginShadowboxController::register in Shadowbox 8
Displays user profile if user is logged in, or register shadowbox form for anonymous users.
1 string reference to 'LoginShadowboxController::register'
- login_shadowbox.routing.yml in login_shadowbox/
login_shadowbox.routing.yml - login_shadowbox/login_shadowbox.routing.yml
File
- login_shadowbox/
lib/ Drupal/ login_shadowbox/ Controller/ LoginShadowboxController.php, line 114 - Contains \Drupal\login_shadowbox\Controller\LoginShadowboxController.
Class
- LoginShadowboxController
- Controller routines for login_shadowbox routes.
Namespace
Drupal\login_shadowbox\ControllerCode
public function register() {
$user = $this
->currentUser();
if ($user
->id()) {
$response = $this
->redirect('user.view', array(
'user' => $user
->id(),
));
}
else {
$path = drupal_get_path('module', 'login_shadowbox');
$css_path = $this
->config('login_shadowbox.settings')
->get('login_shadowbox_css');
// Refistration form begin.
$register_form = '<div id="shadowbox_register" class="shadowbox_login_wrapper">';
$register_form .= '<button class="shadowbox_login_close_button">x</button>';
if ($this
->config('user.settings')
->get('register') != USER_REGISTER_ADMINISTRATORS_ONLY) {
$entity = $this->entityManager
->getStorage('user')
->create();
$form = $this->entityFormBuilders
->getForm($entity, 'register');
$form['#attached'] = array(
'css' => array(
$css_path,
array(
'group' => 'CSS_DEFAULT',
),
),
'js' => array(
$path . '/scripts/login_shadowbox_messages.js',
),
);
$register_form .= drupal_render($form);
$register_form .= '</div>';
$register = array(
'#theme' => 'login_shadowbox_page',
'#title' => t('Create new account'),
'#content' => $register_form,
'#css' => drupal_get_css(),
'#js' => drupal_get_js(),
);
exit(drupal_render($register));
}
}
return NULL;
}