GroupDeleteConfirm.php in Paragraphs Browser 8
File
src/Form/GroupDeleteConfirm.php
View source
<?php
namespace Drupal\paragraphs_browser\Form;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\paragraphs_browser\BrowserTypeInterface;
class GroupDeleteConfirm extends FormBase {
protected $entity;
public function getFormId() {
return 'paragraphs_browser_group_delete_confirm';
}
public function buildForm(array $form, FormStateInterface $form_state, BrowserTypeInterface $paragraphs_browser_type = null, $group_machine_name = '') {
$this->entity = $paragraphs_browser_type;
$form['id'] = array(
'#type' => 'hidden',
'#value' => $group_machine_name,
);
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => $this
->t('Confirm Deletion'),
'#button_type' => 'primary',
'#submit' => array(
'::submitForm',
'::save',
),
);
return $form;
}
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->entity
->groupManager()
->removeGroup($form_state
->getValue('id'));
$form_state
->setRedirectUrl($this->entity
->toUrl('groups-form'));
}
public function save(array $form, FormStateInterface $form_state) {
$this->entity
->save();
}
protected function copyFormValuesToEntity(EntityInterface $entity, array $form, FormStateInterface $form_state) {
}
}