class SwitchToLiveForm
Same name and namespace in other branches
- 11.x core/modules/workspaces/src/Form/SwitchToLiveForm.php \Drupal\workspaces\Form\SwitchToLiveForm
Provides a form that switches to the live version of the site.
Hierarchy
- class \Drupal\Core\Form\FormBase extends \Drupal\Core\Form\FormInterface, \Drupal\Core\DependencyInjection\ContainerInjectionInterface uses \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Logger\LoggerChannelTrait, \Drupal\Core\Messenger\MessengerTrait, \Drupal\Core\Routing\RedirectDestinationTrait, \Drupal\Core\StringTranslation\StringTranslationTrait
- class \Drupal\Core\Form\ConfirmFormBase extends \Drupal\Core\Form\ConfirmFormInterface implements \Drupal\Core\Form\FormBase
- class \Drupal\workspaces\Form\SwitchToLiveForm extends \Drupal\workspaces\Form\WorkspaceFormInterface, \Drupal\Core\DependencyInjection\ContainerInjectionInterface implements \Drupal\Core\Form\ConfirmFormBase
- class \Drupal\Core\Form\ConfirmFormBase extends \Drupal\Core\Form\ConfirmFormInterface implements \Drupal\Core\Form\FormBase
Expanded class hierarchy of SwitchToLiveForm
1 string reference to 'SwitchToLiveForm'
- workspaces.routing.yml in core/
modules/ workspaces/ workspaces.routing.yml - core/modules/workspaces/workspaces.routing.yml
File
-
core/
modules/ workspaces/ src/ Form/ SwitchToLiveForm.php, line 15
Namespace
Drupal\workspaces\FormView source
class SwitchToLiveForm extends ConfirmFormBase implements WorkspaceFormInterface, ContainerInjectionInterface {
/**
* The workspace manager.
*
* @var \Drupal\workspaces\WorkspaceManagerInterface
*/
protected $workspaceManager;
/**
* Constructs a new SwitchToLiveForm.
*
* @param \Drupal\workspaces\WorkspaceManagerInterface $workspace_manager
* The workspace manager.
*/
public function __construct(WorkspaceManagerInterface $workspace_manager) {
$this->workspaceManager = $workspace_manager;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static($container->get('workspaces.manager'));
}
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'switch_to_live_form';
}
/**
* {@inheritdoc}
*/
public function getQuestion() {
return $this->t('Would you like to switch to the live version of the site?');
}
/**
* {@inheritdoc}
*/
public function getDescription() {
return $this->t('Switch to the live version of the site.');
}
/**
* {@inheritdoc}
*/
public function getCancelUrl() {
return new Url('<current>');
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->workspaceManager
->switchToLive();
$this->messenger()
->addMessage($this->t('You are now viewing the live version of the site.'));
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.