public function MenuBlockKernelViewSubscriber::onView in Menu Block 8
Alters the block library modal.
Parameters
\Symfony\Component\HttpKernel\Event\GetResponseEvent $event: The event to process.
File
- src/
EventSubscriber/ MenuBlockKernelViewSubscriber.php, line 41
Class
- MenuBlockKernelViewSubscriber
- Alters the block library modal.
Namespace
Drupal\menu_block\EventSubscriberCode
public function onView(GetResponseEvent $event) {
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);
break;
}
}