Commit 04537cef authored by JohnAlbin's avatar JohnAlbin

Issue #2782503 by JohnAlbin: Suppress menu blocks in Context UI provided by System module

parent 2d172bf6
......@@ -39,19 +39,23 @@ class MenuBlockKernelViewSubscriber implements EventSubscriberInterface {
* The event to process.
*/
public function onView(GetResponseEvent $event) {
if ($this->currentRouteMatch->getRouteName() === 'block.admin_library') {
// Grab the render array result before it is rendered by the
// main_content_view_subscriber.
$result = $event->getControllerResult();
foreach ($result['blocks']['#rows'] as $key => $row) {
// Remove rows for any block provided by the system_menu_block plugin.
$plugin_id = $row['operations']['data']['#links']['add']['url']->getRouteParameters()['plugin_id'];
if (strpos($plugin_id, 'system_menu_block:') === 0) {
unset($result['blocks']['#rows'][$key]);
switch ($this->currentRouteMatch->getRouteName()) {
case 'block.admin_library':
case 'context.reaction.blocks.library':
// Grab the render array result before it is rendered by the
// main_content_view_subscriber.
$result = $event->getControllerResult();
foreach ($result['blocks']['#rows'] as $key => $row) {
// Remove rows for any block provided by the system_menu_block plugin.
$routeParameters = $row['operations']['data']['#links']['add']['url']->getRouteParameters();
$plugin_id = !empty($routeParameters['plugin_id']) ? $routeParameters['plugin_id'] : $routeParameters['block_id'];
if (strpos($plugin_id, 'system_menu_block:') === 0) {
unset($result['blocks']['#rows'][$key]);
}
}
}
// Override the original render array.
$event->setControllerResult($result);
// Override the original render array.
$event->setControllerResult($result);
break;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment