BlockListController.php in Drupal 10
File
core/modules/block/src/Controller/BlockListController.php
View source
<?php
namespace Drupal\block\Controller;
use Drupal\Core\Entity\Controller\EntityListController;
use Drupal\Core\Extension\ThemeHandlerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
class BlockListController extends EntityListController {
protected $themeHandler;
public function __construct(ThemeHandlerInterface $theme_handler) {
$this->themeHandler = $theme_handler;
}
public static function create(ContainerInterface $container) {
return new static($container
->get('theme_handler'));
}
public function listing($theme = NULL, Request $request = NULL) {
$theme = $theme ?: $this
->config('system.theme')
->get('default');
if (!$this->themeHandler
->hasUi($theme)) {
throw new NotFoundHttpException();
}
return $this
->entityTypeManager()
->getListBuilder('block')
->render($theme, $request);
}
}