BlockPermissionsBlockLibraryController.php in Block permissions 8
File
src/Controller/BlockPermissionsBlockLibraryController.php
View source
<?php
namespace Drupal\block_permissions\Controller;
use Drupal\block\Controller\BlockLibraryController;
use Symfony\Component\HttpFoundation\Request;
class BlockPermissionsBlockLibraryController extends BlockLibraryController {
public function listBlocks(Request $request, $theme) {
$build = parent::listBlocks($request, $theme);
foreach ($build['blocks']['#rows'] as $key => $row) {
if (!empty($row['operations']['data']['#links']['add']['url'])) {
$url = $row['operations']['data']['#links']['add']['url'];
if (!$url
->access()) {
unset($build['blocks']['#rows'][$key]);
}
}
}
return $build;
}
}