commit 60e761ad93ba44775a3940f7d466d9a2e79b517d (HEAD, 8.0.x) Author: Tim Plunkett Date: Thu Oct 9 16:06:20 2014 -0400 use entities diff --git a/core/modules/help/help.routing.yml b/core/modules/help/help.routing.yml index c2fa1fb..c5f1330 100644 --- a/core/modules/help/help.routing.yml +++ b/core/modules/help/help.routing.yml @@ -15,7 +15,7 @@ help.page: _permission: 'access administration pages' help.topic_view: - path: 'admin/help-topic/{id}' + path: 'admin/help-topic/{help}' defaults: _content: '\Drupal\help\Controller\HelpController::helpEntityView' _title: 'Help' diff --git a/core/modules/help/src/Controller/HelpController.php b/core/modules/help/src/Controller/HelpController.php index f312224..ec4bd47 100644 --- a/core/modules/help/src/Controller/HelpController.php +++ b/core/modules/help/src/Controller/HelpController.php @@ -7,13 +7,13 @@ namespace Drupal\help\Controller; -use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Controller\ControllerBase; use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Url; use Drupal\Component\Utility\String; use Drupal\help\Entity\Help; +use Drupal\help\HelpInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; @@ -30,13 +30,6 @@ class HelpController extends ControllerBase { protected $routeMatch; /** - * The config factory. - * - * @var \Drupal\Core\Config\ConfigFactoryInterface - */ - protected $configFactory; - - /** * The help entity storage. * * @var \Drupal\Core\Entity\EntityStorageInterface @@ -48,14 +41,11 @@ class HelpController extends ControllerBase { * * @param \Drupal\Core\Routing\RouteMatchInterface $route_match * The current route match. - * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory - * The config factory. * @param \Drupal\Core\Entity\EntityStorageInterface $help_storage * The entity storage for help topic entities. */ - public function __construct(RouteMatchInterface $route_match, ConfigFactoryInterface $config_factory, EntityStorageInterface $help_storage) { + public function __construct(RouteMatchInterface $route_match, EntityStorageInterface $help_storage) { $this->routeMatch = $route_match; - $this->configFactory = $config_factory; $this->helpStorage = $help_storage; } @@ -65,7 +55,6 @@ public function __construct(RouteMatchInterface $route_match, ConfigFactoryInter public static function create(ContainerInterface $container) { return new static( $container->get('current_route_match'), - $container->get('config.factory'), $container->get('entity.manager')->getStorage('help') ); } @@ -215,20 +204,16 @@ public function helpPage($name) { /** * Renders a help topic page from a configured help entity. * - * @param string $id - * The ID of the help entity to display. + * @param \Drupal\help\HelpInterface $help + * The help entity to display. * * @return array * A render array for the help topic page. - * - * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException */ - public function helpEntityView($id) { - $config = $this->configFactory->get('help.help.' . $id); - + public function helpEntityView(HelpInterface $help) { $build = array(); - $build['#title'] = String::checkPlain($config->get('label')); + $build['#title'] = String::checkPlain($help->get('label')); // When you get a config object, if it doesn't find the config it // returns a new empty config object. So check and see if we found a @@ -237,18 +222,18 @@ public function helpEntityView($id) { throw new NotFoundHttpException(); } - $body = $config->get('body'); + $body = $help->get('body'); $build['body'] = array( '#type' => 'processed_text', '#text' => $body['value'], '#format' => $body['format'], ); - $related = $config->get('related'); + $related = $help->get('related'); $links = array(); - foreach($related as $other_id) { - if ($other_id != $id) { - $topic = $this->configFactory->get('help.help.' . $other_id); + foreach ($related as $other_id) { + if ($other_id != $help->id()) { + $topic = $this->helpStorage->load($other_id); // This could be an empty new config object. Only display topics // with titles, and silently omit others. if ($title = $topic->get('label')) { @@ -274,4 +259,5 @@ public function helpEntityView($id) { return $build; } + }