ModalHelpController.php in Modal 8.3
File
src/Controller/ModalHelpController.php
View source
<?php
namespace Drupal\modal_page\Controller;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Extension\ExtensionList;
use Drupal\Core\Routing\RouteMatchInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
class ModalHelpController extends ControllerBase {
protected $routeMatch;
protected $extensionListModule;
public function __construct(RouteMatchInterface $route_match, ExtensionList $extension_list_module) {
$this->routeMatch = $route_match;
$this->extensionListModule = $extension_list_module;
}
public static function create(ContainerInterface $container) {
return new static($container
->get('current_route_match'), $container
->get('extension.list.module'));
}
public function index() {
$build = [];
$name = 'modal_page';
$project_name = $this
->moduleHandler()
->getName($name);
$build['#title'] = 'Modal Page Help';
$temp = $this
->moduleHandler()
->invoke($name, 'help', [
"help.page.{$name}",
$this->routeMatch,
]);
if (!is_array($temp)) {
$temp = [
'#markup' => $temp,
];
}
$build['top'] = $temp;
$admin_tasks = system_get_module_admin_tasks($name, $this->extensionListModule
->getExtensionInfo($name));
if (!empty($admin_tasks)) {
$links = [];
foreach ($admin_tasks as $task) {
$link['url'] = $task['url'];
$link['title'] = $task['title'];
if ($link['url']
->getRouteName() === 'modal_page.settings') {
$link['title'] = 'Modal Settings';
}
$links[] = $link;
}
$build['links'] = [
'#theme' => 'links__help',
'#heading' => [
'level' => 'h3',
'text' => $this
->t('@project_name administration pages', [
'@project_name' => $project_name,
]),
],
'#links' => $links,
];
}
return $build;
}
}