Skip to content
Snippets Groups Projects
Commit 2c9a7c16 authored by Martin Giessing's avatar Martin Giessing
Browse files

Issue #3441986 by erik_petra, LupusGr3y: Can't disable transform block

parent cd98905b
Branches
Tags
No related merge requests found
......@@ -2,6 +2,7 @@
namespace Drupal\transform_api\Controller;
use Drupal\block\BlockInterface;
use Drupal\Component\Serialization\Json;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\EventSubscriber\MainContentViewSubscriber;
......@@ -9,6 +10,7 @@ use Drupal\Core\Menu\LocalActionManagerInterface;
use Drupal\Core\Plugin\Context\LazyContextRepository;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Url;
use Drupal\transform_api\TransformBlockInterface;
use Drupal\transform_api\TransformBlockManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request;
......@@ -226,4 +228,21 @@ class BlockController extends ControllerBase {
return $this->entityFormBuilder()->getForm($entity);
}
/**
* Calls a method on a transform block and reloads the listing page.
*
* @param \Drupal\transform_api\TransformBlockInterface $transform_block
* The transform block being acted upon.
* @param string $op
* The operation to perform, e.g., 'enable' or 'disable'.
*
* @return \Symfony\Component\HttpFoundation\RedirectResponse
* A redirect back to the listing page.
*/
public function performOperation(TransformBlockInterface $transform_block, $op) {
$transform_block->$op()->save();
$this->messenger()->addStatus($this->t('The block settings have been updated.'));
return $this->redirect('transform_api.transform_block.admin_display');
}
}
......@@ -103,19 +103,19 @@ entity.transform_block.edit_form:
entity.transform_block.enable:
path: '/admin/structure/block/transform/manage/{transform_block}/enable'
defaults:
_controller: '\Drupal\block\Controller\BlockController::performOperation'
_controller: '\Drupal\transform_api\Controller\BlockController::performOperation'
op: enable
requirements:
_entity_access: 'transform_block.enable'
_permission: 'administer transform blocks'
_csrf_token: 'TRUE'
entity.transform_block.disable:
path: '/admin/structure/block/transform/manage/{transform_block}/disable'
defaults:
_controller: '\Drupal\block\Controller\BlockController::performOperation'
_controller: '\Drupal\transform_api\Controller\BlockController::performOperation'
op: disable
requirements:
_entity_access: 'transform_block.disable'
_permission: 'administer transform blocks'
_csrf_token: 'TRUE'
transform_api.transform_block.admin_display:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment