class DeleteForm

Builds the form to delete a path alias.

Hierarchy

Expanded class hierarchy of DeleteForm

1 string reference to 'DeleteForm'
path.routing.yml in drupal/core/modules/path/path.routing.yml
drupal/core/modules/path/path.routing.yml

File

drupal/core/modules/path/lib/Drupal/path/Form/DeleteForm.php, line 18
Contains \Drupal\path\Form\DeleteForm.

Namespace

Drupal\path\Form
View source
class DeleteForm extends ConfirmFormBase implements ControllerInterface {

  /**
   * The path crud service.
   *
   * @var Path $path
   */
  protected $path;

  /**
   * The path alias being deleted.
   *
   * @var array $pathAlias
   */
  protected $pathAlias;

  /**
   * Constructs a \Drupal\Core\Path\Path object.
   *
   * @param \Drupal\Core\Path\Path $path
   *   The path crud service.
   */
  public function __construct(Path $path) {
    $this->path = $path;
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container) {
    return new static($container
      ->get('path.crud'));
  }

  /**
   * Implements \Drupal\Core\Form\FormInterface::getFormID().
   */
  public function getFormID() {
    return 'path_alias_delete';
  }

  /**
   * Implements \Drupal\Core\Form\ConfirmFormBase::getQuestion().
   */
  protected function getQuestion() {
    return t('Are you sure you want to delete path alias %title?', array(
      '%title' => $this->pathAlias['alias'],
    ));
  }

  /**
   * Implements \Drupal\Core\Form\ConfirmFormBase::getCancelPath().
   */
  protected function getCancelPath() {
    return 'admin/config/search/path';
  }

  /**
   * Overrides \Drupal\Core\Form\ConfirmFormBase::buildForm().
   */
  public function buildForm(array $form, array &$form_state, $pid = NULL) {
    $this->pathAlias = $this->path
      ->load(array(
      'pid' => $pid,
    ));
    return parent::buildForm($form, $form_state);
  }

  /**
   * Implements \Drupal\Core\Form\FormInterface::submitForm().
   */
  public function submitForm(array &$form, array &$form_state) {
    $this->path
      ->delete(array(
      'pid' => $this->pathAlias['pid'],
    ));
    $form_state['redirect'] = 'admin/config/search/path';
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ConfirmFormBase::getCancelText protected function Returns a caption for the link which cancels the action. 2
ConfirmFormBase::getConfirmText protected function Returns a caption for the button that confirms the action. 27
ConfirmFormBase::getDescription protected function Returns additional text to display as a description. 10
ConfirmFormBase::getFormName protected function Returns the internal name used to refer to the confirmation item.
ConfirmFormBase::validateForm public function Implements \Drupal\Core\Form\FormInterface::validateForm(). Overrides FormInterface::validateForm 1
DeleteForm::$path protected property The path crud service.
DeleteForm::$pathAlias protected property The path alias being deleted.
DeleteForm::buildForm public function Overrides \Drupal\Core\Form\ConfirmFormBase::buildForm(). Overrides ConfirmFormBase::buildForm
DeleteForm::create public static function Instantiates a new instance of this controller. Overrides ControllerInterface::create
DeleteForm::getCancelPath protected function Implements \Drupal\Core\Form\ConfirmFormBase::getCancelPath(). Overrides ConfirmFormBase::getCancelPath
DeleteForm::getFormID public function Implements \Drupal\Core\Form\FormInterface::getFormID(). Overrides FormInterface::getFormID
DeleteForm::getQuestion protected function Implements \Drupal\Core\Form\ConfirmFormBase::getQuestion(). Overrides ConfirmFormBase::getQuestion
DeleteForm::submitForm public function Implements \Drupal\Core\Form\FormInterface::submitForm(). Overrides FormInterface::submitForm
DeleteForm::__construct public function Constructs a \Drupal\Core\Path\Path object.