<?php
namespace Drupal\your_module\Controller;
use Drupal;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Url;
class YourModuleController extends ControllerBase {
protected $database;
function content() {
// Render array to return
$mainRenderArray = [];
// admin_page style (half width)
$mainRenderArray[] = [
'#theme' => 'admin_page',
'#blocks' => [
// Array of admin_block
[
'title' => $this->t('A block, on the left'),
'position' => 'left',
'content' => [
'#theme' => 'admin_block_content',
'#content' => [
[
'title' => 'Do something',
'url' => Url::fromRoute('your_module.some.example.route'),
'description' => $this->t('This will link to a route.')
],
[
'title' => 'Navigate to a nice blog',
'url' => Url::fromUri('https://blog.dakwamine.fr'),
'description' => $this->t('This will link to a URI, external in this case.')
],
[
'title' => 'Go to contents page',
'url' => Url::fromUri('internal:/admin/content'),
'description' => $this->t('Also works for internal URI.')
]
]
]
],
[
'title' => $this->t('Another block, on the right'),
'position' => 'right',
'content' => [
'#theme' => 'admin_block_content',
'#content' => [
[
'title' => 'Another link to a route',
'url' => Url::fromRoute('your_module.another.route'),
'description' => $this->t('Yup.')
],
[
'title' => 'Website example link',
'url' => Url::fromUri('https://website.example'),
'description' => $this->t('Goes on website.example.')
],
]
]
]
],
];
// admin_block style (full width)
$mainRenderArray[] = [
'#theme' => 'admin_block',
'#block' => [
'title' => $this->t('Full width block'),
'content' => [
'#theme' => 'admin_block_content',
'#content' => [
[
'title' => 'Another link',
'url' => Url::fromUri('internal:/admin/people'),
'description' => $this->t('A link to the people page.')
],
[
'title' => 'Another link again',
'url' => Url::fromUri('https://website.example'),
'description' => $this->t('Goes on website.example.')
],
]
],
],
];
return $mainRenderArray;
}
}