class TfaSetup in Two-factor Authentication (TFA) 8
Same name in this branch
- 8 src/TfaSetup.php \Drupal\tfa\TfaSetup
- 8 src/Annotation/TfaSetup.php \Drupal\tfa\Annotation\TfaSetup
TFA Setup.
Hierarchy
- class \Drupal\tfa\TfaSetup
Expanded class hierarchy of TfaSetup
1 file declares its use of TfaSetup
- BasicSetup.php in src/
Form/ BasicSetup.php
File
- src/
TfaSetup.php, line 11
Namespace
Drupal\tfaView source
class TfaSetup {
/**
* Current setup plugin.
*
* @var \Drupal\tfa\Plugin\TfaSetupInterface
*/
protected $setupPlugin;
/**
* TFA Setup constructor.
*
* @param \Drupal\tfa\Plugin\TfaSetupInterface $plugin
* Plugins to instantiate.
*/
public function __construct(TfaSetupInterface $plugin) {
$this->setupPlugin = $plugin;
}
/**
* Run any begin setup processes.
*/
public function begin() {
// Invoke begin method on setup plugin.
if (method_exists($this->setupPlugin, 'begin')) {
$this->setupPlugin
->begin();
}
}
/**
* Get plugin form.
*
* @param array $form
* An associative array containing the structure of the form.
* @param \Drupal\Core\Form\FormStateInterface $form_state
* The current state of the form.
* @param int $reset
* Reset the data or not.
*
* @return array
* Form API array.
*/
public function getForm(array $form, FormStateInterface &$form_state, $reset = 0) {
return $this->setupPlugin
->getSetupForm($form, $form_state, $reset);
}
/**
* Validate form.
*
* @param array $form
* An associative array containing the structure of the form.
* @param \Drupal\Core\Form\FormStateInterface $form_state
* The current state of the form.
*
* @return bool
* TRUE if setup completed otherwise FALSE.
*/
public function validateForm(array $form, FormStateInterface &$form_state) {
return $this->setupPlugin
->validateSetupForm($form, $form_state);
}
/**
* Return process error messages.
*
* @return string[]
* An array containing the setup errors.
*/
public function getErrorMessages() {
return $this->setupPlugin
->getErrorMessages();
}
/**
* Submit the setup form.
*
* @param array $form
* An associative array containing the structure of the form.
* @param \Drupal\Core\Form\FormStateInterface $form_state
* The current state of the form.
*
* @return bool
* TRUE if no errors occur when saving the data.
*/
public function submitForm(array $form, FormStateInterface &$form_state) {
return $this->setupPlugin
->submitSetupForm($form, $form_state);
}
/**
* Returns a list of messages for plugin step.
*
* @return string[]
* An array containing messages to be used during plugin setup.
*/
public function getSetupMessages() {
return $this->setupPlugin
->getSetupMessages();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
TfaSetup:: |
protected | property | Current setup plugin. | |
TfaSetup:: |
public | function | Run any begin setup processes. | |
TfaSetup:: |
public | function | Return process error messages. | |
TfaSetup:: |
public | function | Get plugin form. | |
TfaSetup:: |
public | function | Returns a list of messages for plugin step. | |
TfaSetup:: |
public | function | Submit the setup form. | |
TfaSetup:: |
public | function | Validate form. | |
TfaSetup:: |
public | function | TFA Setup constructor. |