connection = $connection; } /** * {@inheritdoc} */ public static function create(ContainerInterface $container) { return new static( $container->get('database') ); } /** * {@inheritdoc} */ public function getFormId() { return '{{ form_id }}'; } /** * {@inheritdoc} */ public function getQuestion() { return $this->t('Are you sure you want to delete all examples?'); } /** * {@inheritdoc} */ public function getCancelUrl() { return new Url('system.admin'); } /** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { $this->connection->delete('examples')->execute(); drupal_set_message($this->t('The examples have been deleted.')); $form_state->setRedirectUrl($this->getCancelUrl()); } }