ContextDelete.php in Chaos Tool Suite (ctools) 8.3
File
src/Form/ContextDelete.php
View source
<?php
namespace Drupal\ctools\Form;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Form\ConfirmFormBase;
use Drupal\Core\TempStore\SharedTempStoreFactory;
use Symfony\Component\DependencyInjection\ContainerInterface;
abstract class ContextDelete extends ConfirmFormBase {
protected $tempstore;
protected $tempstore_id;
protected $machine_name;
protected $context_id;
public static function create(ContainerInterface $container) {
return new static($container
->get('tempstore.shared'));
}
public function __construct(SharedTempStoreFactory $tempstore) {
$this->tempstore = $tempstore;
}
public function getFormId() {
return 'ctools_context_delete_form';
}
public function getConfirmText() {
return $this
->t('Delete');
}
public function buildForm(array $form, FormStateInterface $form_state, $tempstore_id = NULL, $machine_name = NULL, $context_id = NULL) {
$this->tempstore_id = $tempstore_id;
$this->machine_name = $machine_name;
$this->context_id = $context_id;
return parent::buildForm($form, $form_state);
}
public function submitForm(array &$form, FormStateInterface $form_state) {
$form_state
->setRedirectUrl($this
->getCancelUrl());
}
protected function getTempstore() {
return $this->tempstore
->get($this->tempstore_id)
->get($this->machine_name);
}
protected function setTempstore($cached_values) {
$this->tempstore
->get($this->tempstore_id)
->set($this->machine_name, $cached_values);
}
}
Classes
Name |
Description |
ContextDelete |
Provides a form for deleting an contexts and relationships. |