Loading block_class.links.task.yml +6 −0 Original line number Diff line number Diff line Loading @@ -10,3 +10,9 @@ block_class.bulk_operations: route_name: block_class.bulk_operations base_route: block_class.settings weight: 2 block_class.help: title: Help route_name: block_class.help base_route: block_class.settings weight: 3 No newline at end of file block_class.routing.yml +8 −0 Original line number Diff line number Diff line Loading @@ -20,3 +20,11 @@ block_class.confirm_bulk_operation: _title: 'Confirm Deletion' requirements: _permission: 'administer block classes' block_class.help: path: '/admin/block-class/help' defaults: _controller: '\Drupal\block_class\Controller\BlockClassController::index' _title: 'Block Class Help' requirements: _permission: 'administer block classes' No newline at end of file src/Controller/BlockClassController.php 0 → 100644 +113 −0 Original line number Diff line number Diff line <?php namespace Drupal\block_class\Controller; use Drupal\Core\Controller\ControllerBase; use Drupal\Core\Extension\ExtensionList; use Drupal\Core\Routing\RouteMatchInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Drupal\Core\Config\ConfigFactoryInterface; /** * Controller routines for help routes. */ class BlockClassController extends ControllerBase { /** * The current route match. * * @var \Drupal\Core\Routing\RouteMatchInterface */ protected $routeMatch; /** * The extension list module. * * @var \Drupal\Core\Extension\ExtensionList */ protected $extensionListModule; /** * The config factory. * * @var \Drupal\Core\Config\ConfigFactoryInterface */ protected $configFactory; /** * Creates a new HelpController. */ public function __construct(RouteMatchInterface $route_match, ExtensionList $extension_list_module, ConfigFactoryInterface $config_factory) { $this->routeMatch = $route_match; $this->extensionListModule = $extension_list_module; $this->configFactory = $config_factory; } /** * {@inheritdoc} */ public static function create(ContainerInterface $container) { return new static( $container->get('current_route_match'), $container->get('extension.list.module'), $container->get('config.factory') ); } /** * {@inheritdoc} */ public function index() { $build = []; $projectMachineName = 'block_class'; $projectName = $this->moduleHandler()->getName($projectMachineName); $build['#title'] = 'Block Class Help'; $helperMarkup = $this->moduleHandler()->invoke($projectMachineName, 'help', [ "help.page.$projectMachineName", $this->routeMatch, ]); if (!is_array($helperMarkup)) { $helperMarkup = ['#markup' => $helperMarkup]; } $build['top'] = $helperMarkup; // Only print list of administration pages if the project in question has // any such pages associated with it. $adminTasks = system_get_module_admin_tasks($projectMachineName, $this->extensionListModule->getExtensionInfo($projectMachineName)); if (empty($adminTasks)) { return $build; } $links = []; foreach ($adminTasks as $adminTask) { $link['url'] = $adminTask['url']; $link['title'] = $adminTask['title']; if ($link['url']->getRouteName() === 'block_class.settings') { $link['title'] = 'Block Class Settings'; } $links[] = $link; } $build['links'] = [ '#theme' => 'links__help', '#heading' => [ 'level' => 'h3', 'text' => $this->t('@project_name administration pages', ['@project_name' => $projectName]), ], '#links' => $links, ]; return $build; } } Loading
block_class.links.task.yml +6 −0 Original line number Diff line number Diff line Loading @@ -10,3 +10,9 @@ block_class.bulk_operations: route_name: block_class.bulk_operations base_route: block_class.settings weight: 2 block_class.help: title: Help route_name: block_class.help base_route: block_class.settings weight: 3 No newline at end of file
block_class.routing.yml +8 −0 Original line number Diff line number Diff line Loading @@ -20,3 +20,11 @@ block_class.confirm_bulk_operation: _title: 'Confirm Deletion' requirements: _permission: 'administer block classes' block_class.help: path: '/admin/block-class/help' defaults: _controller: '\Drupal\block_class\Controller\BlockClassController::index' _title: 'Block Class Help' requirements: _permission: 'administer block classes' No newline at end of file
src/Controller/BlockClassController.php 0 → 100644 +113 −0 Original line number Diff line number Diff line <?php namespace Drupal\block_class\Controller; use Drupal\Core\Controller\ControllerBase; use Drupal\Core\Extension\ExtensionList; use Drupal\Core\Routing\RouteMatchInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Drupal\Core\Config\ConfigFactoryInterface; /** * Controller routines for help routes. */ class BlockClassController extends ControllerBase { /** * The current route match. * * @var \Drupal\Core\Routing\RouteMatchInterface */ protected $routeMatch; /** * The extension list module. * * @var \Drupal\Core\Extension\ExtensionList */ protected $extensionListModule; /** * The config factory. * * @var \Drupal\Core\Config\ConfigFactoryInterface */ protected $configFactory; /** * Creates a new HelpController. */ public function __construct(RouteMatchInterface $route_match, ExtensionList $extension_list_module, ConfigFactoryInterface $config_factory) { $this->routeMatch = $route_match; $this->extensionListModule = $extension_list_module; $this->configFactory = $config_factory; } /** * {@inheritdoc} */ public static function create(ContainerInterface $container) { return new static( $container->get('current_route_match'), $container->get('extension.list.module'), $container->get('config.factory') ); } /** * {@inheritdoc} */ public function index() { $build = []; $projectMachineName = 'block_class'; $projectName = $this->moduleHandler()->getName($projectMachineName); $build['#title'] = 'Block Class Help'; $helperMarkup = $this->moduleHandler()->invoke($projectMachineName, 'help', [ "help.page.$projectMachineName", $this->routeMatch, ]); if (!is_array($helperMarkup)) { $helperMarkup = ['#markup' => $helperMarkup]; } $build['top'] = $helperMarkup; // Only print list of administration pages if the project in question has // any such pages associated with it. $adminTasks = system_get_module_admin_tasks($projectMachineName, $this->extensionListModule->getExtensionInfo($projectMachineName)); if (empty($adminTasks)) { return $build; } $links = []; foreach ($adminTasks as $adminTask) { $link['url'] = $adminTask['url']; $link['title'] = $adminTask['title']; if ($link['url']->getRouteName() === 'block_class.settings') { $link['title'] = 'Block Class Settings'; } $links[] = $link; } $build['links'] = [ '#theme' => 'links__help', '#heading' => [ 'level' => 'h3', 'text' => $this->t('@project_name administration pages', ['@project_name' => $projectName]), ], '#links' => $links, ]; return $build; } }