View source
<?php
namespace Drupal\devel\Controller;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Layout\LayoutPluginManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
class LayoutInfoController extends ControllerBase {
protected $layoutPluginManager;
public function __construct(LayoutPluginManagerInterface $pluginManagerLayout) {
$this->layoutPluginManager = $pluginManagerLayout;
}
public static function create(ContainerInterface $container) {
return new static($container
->get('plugin.manager.core.layout'));
}
public function layoutInfoPage() {
$definedLayouts = [];
$layouts = $this->layoutPluginManager
->getDefinitions();
foreach ($layouts as $layout) {
$image = NULL;
if ($layout
->getIconPath() != NULL) {
$image = [
'data' => [
'#theme' => 'image',
'#uri' => $layout
->getIconPath(),
'#alt' => $layout
->getLabel(),
'#height' => '65',
],
];
}
$definedLayouts[] = [
$image,
$layout
->getLabel(),
$layout
->getDescription(),
$layout
->getCategory(),
implode(', ', $layout
->getRegionLabels()),
$layout
->getProvider(),
];
}
return [
'#theme' => 'table',
'#header' => [
$this
->t('Icon'),
$this
->t('Label'),
$this
->t('Description'),
$this
->t('Category'),
$this
->t('Regions'),
$this
->t('Provider'),
],
'#rows' => $definedLayouts,
'#empty' => $this
->t('No layouts available.'),
'#attributes' => [
'class' => [
'devel-layout-list',
],
],
];
}
}