class DblogClearLogConfirmForm
Same name and namespace in other branches
- 10 core/modules/dblog/src/Form/DblogClearLogConfirmForm.php \Drupal\dblog\Form\DblogClearLogConfirmForm
- 11.x core/modules/dblog/src/Form/DblogClearLogConfirmForm.php \Drupal\dblog\Form\DblogClearLogConfirmForm
- 8.9.x core/modules/dblog/src/Form/DblogClearLogConfirmForm.php \Drupal\dblog\Form\DblogClearLogConfirmForm
Provides a confirmation form before clearing out the logs.
@internal
Hierarchy
- class \Drupal\Core\Form\FormBase implements \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 implements \Drupal\Core\Form\ConfirmFormInterface extends \Drupal\Core\Form\FormBase
- class \Drupal\dblog\Form\DblogClearLogConfirmForm extends \Drupal\Core\Form\ConfirmFormBase
- class \Drupal\Core\Form\ConfirmFormBase implements \Drupal\Core\Form\ConfirmFormInterface extends \Drupal\Core\Form\FormBase
Expanded class hierarchy of DblogClearLogConfirmForm
1 string reference to 'DblogClearLogConfirmForm'
- dblog.routing.yml in core/
modules/ dblog/ dblog.routing.yml - core/modules/dblog/dblog.routing.yml
File
-
core/
modules/ dblog/ src/ Form/ DblogClearLogConfirmForm.php, line 16
Namespace
Drupal\dblog\FormView source
class DblogClearLogConfirmForm extends ConfirmFormBase {
/**
* The database connection.
*
* @var \Drupal\Core\Database\Connection
*/
protected $connection;
/**
* Constructs a new DblogClearLogConfirmForm.
*
* @param \Drupal\Core\Database\Connection $connection
* The database connection.
*/
public function __construct(Connection $connection) {
$this->connection = $connection;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static($container->get('database'));
}
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'dblog_confirm';
}
/**
* {@inheritdoc}
*/
public function getQuestion() {
return $this->t('Are you sure you want to delete the recent logs?');
}
/**
* {@inheritdoc}
*/
public function getCancelUrl() {
return new Url('dblog.overview');
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->getRequest()
->getSession()
->remove('dblog_overview_filter');
$this->connection
->truncate('watchdog')
->execute();
$this->messenger()
->addStatus($this->t('Database log cleared.'));
$form_state->setRedirectUrl($this->getCancelUrl());
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.