TotalControlDashboard.php in Total Control Admin Dashboard 3.0.x
File
src/Plugin/Block/TotalControlDashboard.php
View source
<?php
namespace Drupal\total_control\Plugin\Block;
use Drupal\Core\Block\BlockBase;
use Drupal\Core\Block\BlockPluginInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
class TotalControlDashboard extends BlockBase implements BlockPluginInterface, ContainerFactoryPluginInterface {
protected $moduleHandler;
public function __construct(array $configuration, $plugin_id, $plugin_definition, ModuleHandlerInterface $module_handler) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->moduleHandler = $module_handler;
}
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('module_handler'));
}
public function build() {
if ($this->moduleHandler
->moduleExists('page_manager_ui')) {
$welcome_message_text = $this
->t('Welcome to your administrative dashboard.');
$edit_this_panel_text = $this
->t('Edit this panel');
$to_do_more_text = $this
->t('to add more blocks here, or configure those provided by default.');
$markup_data = '<p>' . $welcome_message_text . ' ' . '<a href="/admin/structure/page_manager/manage/total_control_dashboard/page_variant__total_control_dashboard-http_status_code-0__content?js=nojs">' . $edit_this_panel_text . '</a> ' . $to_do_more_text . '</p>';
return [
'#type' => 'markup',
'#markup' => $markup_data,
];
}
else {
$welcome_to_dashboard_text = $this
->t('Welcome to your administrative dashboard.');
$you_have_to_enable_text = $this
->t('You have to enable');
$page_manager_ui_text = $this
->t('Page Manager UI');
$to_edit_text = $this
->t('module to edit this panel.');
$markup_data = '<p>' . $welcome_to_dashboard_text . ' ' . $you_have_to_enable_text . ' <strong>' . $page_manager_ui_text . '</strong> ' . $to_edit_text . '</p>';
return [
'#type' => 'markup',
'#markup' => $markup_data,
];
}
}
}