class BlockListController
Same name and namespace in other branches
- 11.x core/modules/block/src/Controller/BlockListController.php \Drupal\block\Controller\BlockListController
Defines a controller to list blocks.
Hierarchy
- class \Drupal\Core\Controller\ControllerBase extends \Drupal\Core\DependencyInjection\ContainerInjectionInterface uses \Drupal\Core\Logger\LoggerChannelTrait, \Drupal\Core\Messenger\MessengerTrait, \Drupal\Core\Routing\RedirectDestinationTrait, \Drupal\Core\StringTranslation\StringTranslationTrait
- class \Drupal\Core\Entity\Controller\EntityListController implements \Drupal\Core\Controller\ControllerBase
- class \Drupal\block\Controller\BlockListController implements \Drupal\Core\Entity\Controller\EntityListController
- class \Drupal\Core\Entity\Controller\EntityListController implements \Drupal\Core\Controller\ControllerBase
Expanded class hierarchy of BlockListController
File
-
core/
modules/ block/ src/ Controller/ BlockListController.php, line 14
Namespace
Drupal\block\ControllerView source
class BlockListController extends EntityListController {
/**
* The theme handler.
*
* @var \Drupal\Core\Extension\ThemeHandlerInterface
*/
protected $themeHandler;
/**
* Constructs the BlockListController.
*
* @param \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler
* The theme handler.
*/
public function __construct(ThemeHandlerInterface $theme_handler) {
$this->themeHandler = $theme_handler;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static($container->get('theme_handler'));
}
/**
* Shows the block administration page.
*
* @param string|null $theme
* Theme key of block list.
* @param \Symfony\Component\HttpFoundation\Request $request
* The current request.
*
* @return array
* A render array as expected by
* \Drupal\Core\Render\RendererInterface::render().
*/
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);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.