Delete.php in SimpleAds 8
File
src/Form/Groups/Delete.php
View source
<?php
namespace Drupal\simpleads\Form\Groups;
use Drupal\Core\Form\ConfirmFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
use Drupal\simpleads\Groups;
class Delete extends ConfirmFormBase {
protected $group;
public function getFormId() {
return 'simpleads_campaign_delete_form';
}
public function getQuestion() {
return t('Are you sure you would like to delete <em>%name</em> group?', [
'%name' => $this->group
->getGroupName(),
]);
}
public function getCancelUrl() {
return new Url('simpleads.groups');
}
public function getDescription() {
return t('Are you sure you would like to continue? Please make sure you are not using this group in any of your ads. This operation cannot be undone.');
}
public function getConfirmText() {
return $this
->t('Delete Group');
}
public function getCancelText() {
return $this
->t('Cancel');
}
public function buildForm(array $form, FormStateInterface $form_state, $id = NULL) {
$this->group = (new Groups())
->setId($id)
->load();
return parent::buildForm($form, $form_state);
}
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->group
->delete();
$form_state
->setRedirect('simpleads.groups');
}
}
Classes
Name |
Description |
Delete |
Delete advertisement form. |