ProcessorFormController.php in Purge 8.3
File
modules/purge_ui/src/Controller/ProcessorFormController.php
View source
<?php
namespace Drupal\purge_ui\Controller;
use Drupal\Core\Controller\ControllerBase;
use Drupal\purge\Plugin\Purge\Processor\ProcessorsServiceInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
class ProcessorFormController extends ControllerBase {
protected $purgeProcessors;
public final function __construct(ProcessorsServiceInterface $purge_processors) {
$this->purgeProcessors = $purge_processors;
}
public static function create(ContainerInterface $container) {
return new static($container
->get('purge.processors'));
}
public function addForm() {
if (count($this->purgeProcessors
->getPluginsAvailable())) {
return $this
->formBuilder()
->getForm("Drupal\\purge_ui\\Form\\ProcessorAddForm");
}
throw new NotFoundHttpException();
}
public function configForm($id, $dialog) {
if ($this->purgeProcessors
->isPluginEnabled($id)) {
$definition = $this->purgeProcessors
->getPlugins()[$id];
if (isset($definition['configform']) && !empty($definition['configform'])) {
return $this
->formBuilder()
->getForm($definition['configform'], [
'id' => $id,
'dialog' => $dialog,
]);
}
}
throw new NotFoundHttpException();
}
public function configFormTitle($id) {
if ($this->purgeProcessors
->isPluginEnabled($id)) {
$definition = $this->purgeProcessors
->getPlugins()[$id];
if (isset($definition['configform']) && !empty($definition['configform'])) {
return $this
->t('Configure @label', [
'@label' => $definition['label'],
]);
}
}
return $this
->t('Configure');
}
public function deleteForm($id) {
if ($this->purgeProcessors
->isPluginEnabled($id)) {
return $this
->formBuilder()
->getForm("\\Drupal\\purge_ui\\Form\\ProcessorDeleteForm", $id);
}
throw new NotFoundHttpException();
}
public function deleteFormTitle($id) {
if ($this->purgeProcessors
->isPluginEnabled($id)) {
$label = $this->purgeProcessors
->getPlugins()[$id]['label'];
return $this
->t('Delete @label', [
'@label' => $label,
]);
}
return $this
->t('Delete');
}
public function detailForm($id) {
if ($this->purgeProcessors
->isPluginEnabled($id)) {
return $this
->formBuilder()
->getForm("\\Drupal\\purge_ui\\Form\\PluginDetailsForm", [
'details' => $this->purgeProcessors
->getPlugins()[$id]['description'],
]);
}
throw new NotFoundHttpException();
}
public function detailFormTitle($id) {
return $this->purgeProcessors
->getPlugins()[$id]['label'];
}
}