AssetInjectorDisableForm.php in Asset Injector 8.2
File
src/Form/AssetInjectorDisableForm.php
View source
<?php
namespace Drupal\asset_injector\Form;
use Drupal;
use Drupal\Core\Entity\EntityConfirmFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
class AssetInjectorDisableForm extends EntityConfirmFormBase {
public function getQuestion() {
return $this
->t('Disable @type: %label?', [
'@type' => $this->entity
->getEntityType()
->getLabel(),
'%label' => $this->entity
->label(),
]);
}
public function getDescription() {
return $this
->t('Disable @type: %label?', [
'@type' => $this->entity
->getEntityType()
->getLabel(),
'%label' => $this->entity
->label(),
]);
}
public function getCancelUrl() {
$type = $this->entity
->getEntityType()
->get('id');
return new Url("entity.{$type}.collection");
}
public function submitForm(array &$form, FormStateInterface $form_state) {
$entity = $this->entity;
$entity
->disable()
->save();
Drupal::logger('asset_injector')
->notice('%type asset %id disabled', [
'%type' => $entity
->get('entityTypeId'),
'%id' => $entity->id,
]);
parent::submitForm($form, $form_state);
$form_state
->setRedirectUrl($this
->getCancelUrl());
}
}