VarbaseQuickLinks.php in Varbase Total Control Dashboard 8.6
File
src/Plugin/Block/VarbaseQuickLinks.php
View source
<?php
namespace Drupal\varbase_total_control\Plugin\Block;
use Drupal\Core\Url;
use Drupal\Core\Link;
use Drupal\Core\Block\BlockBase;
use Drupal\Core\Block\BlockPluginInterface;
use Drupal\Core\Render\RendererInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
class VarbaseQuickLinks extends BlockBase implements BlockPluginInterface, ContainerFactoryPluginInterface {
protected $renderer;
public function __construct(array $configuration, $plugin_id, $plugin_definition, RendererInterface $renderer) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->renderer = $renderer;
}
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('renderer'));
}
public function build() {
$links = [];
$links[] = Link::fromTextAndUrl($this
->t('Manage menus'), new Url('entity.menu.collection'));
$links[] = Link::fromTextAndUrl($this
->t('Manage taxonomy'), new Url('entity.taxonomy_vocabulary.collection'));
$links[] = Link::fromTextAndUrl($this
->t('Manage users'), new Url('entity.user.collection'));
$body_data = [
'#theme' => 'item_list',
'#list_type' => 'ul',
'#items' => $links,
];
$markup_data = $this->renderer
->render($body_data);
return [
'#type' => 'markup',
'#markup' => $markup_data,
];
}
}