AuthLoginNoticeForm.php in Open Social 8.5
File
modules/custom/social_auth_extra/src/Form/AuthLoginNoticeForm.php
View source
<?php
namespace Drupal\social_auth_extra\Form;
use Drupal\Core\Form\ConfirmFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
class AuthLoginNoticeForm extends ConfirmFormBase {
protected $socialNetwork;
public function getConfirmText() {
return $this
->t('Create new account');
}
public function getFormId() {
return $this->socialNetwork['id'] . '_auth_login_notice_form';
}
public function getQuestion() {
return $this
->t('Log in');
}
public function getDescription() {
return $this
->t('There is no account connected to this @network account. You can create new account.', [
'@network' => $this->socialNetwork['social_network'],
]);
}
public function getCancelUrl() {
return Url::fromRoute('user.login');
}
public function submitForm(array &$form, FormStateInterface $form_state) {
$form_state
->setRedirect($this->socialNetwork['id'] . '.user_register');
}
public function buildForm(array $form, FormStateInterface $form_state, $network = NULL) {
$network_manager = \Drupal::service('plugin.network.manager');
$definitions = $network_manager
->getDefinitions();
foreach ($definitions as $definition) {
$instance = $network_manager
->createInstance($definition['id']);
if ($network == $instance
->getSocialNetworkKey()) {
$this->socialNetwork = $definition;
break;
}
}
return parent::buildForm($form, $form_state);
}
}