3 namespace Drupal\block\Controller;
5 use Drupal\Core\Entity\Controller\EntityListController;
6 use Drupal\Core\Extension\ThemeHandlerInterface;
7 use Symfony\Component\DependencyInjection\ContainerInterface;
8 use Symfony\Component\HttpFoundation\Request;
9 use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
12 * Defines a controller to list blocks.
14 class BlockListController extends EntityListController {
19 * @var \Drupal\Core\Extension\ThemeHandlerInterface
21 protected $themeHandler;
24 * Constructs the BlockListController.
26 * @param \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler
29 public function __construct(ThemeHandlerInterface $theme_handler) {
30 $this->themeHandler = $theme_handler;
36 public static function create(ContainerInterface $container) {
38 $container->get('theme_handler')
43 * Shows the block administration page.
45 * @param string|null $theme
46 * Theme key of block list.
47 * @param \Symfony\Component\HttpFoundation\Request $request
48 * The current request.
51 * A render array as expected by drupal_render().
53 public function listing($theme = NULL, Request $request = NULL) {
54 $theme = $theme ?: $this->config('system.theme')->get('default');
55 if (!$this->themeHandler->hasUi($theme)) {
56 throw new NotFoundHttpException();
59 return $this->entityManager()->getListBuilder('block')->render($theme, $request);