diff --git a/core/modules/search/lib/Drupal/search/Access/SearchCheck.php b/core/modules/search/lib/Drupal/search/Access/SearchCheck.php index 04bbc1c..702d3ef 100644 --- a/core/modules/search/lib/Drupal/search/Access/SearchCheck.php +++ b/core/modules/search/lib/Drupal/search/Access/SearchCheck.php @@ -7,7 +7,6 @@ namespace Drupal\search\Access; - use Drupal\Core\Access\AccessCheckInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Routing\Route; diff --git a/core/modules/search/lib/Drupal/search/Routing/SearchController.php b/core/modules/search/lib/Drupal/search/Controller/SearchController.php similarity index 75% rename from core/modules/search/lib/Drupal/search/Routing/SearchController.php rename to core/modules/search/lib/Drupal/search/Controller/SearchController.php index bbe6391..13f3240 100644 --- a/core/modules/search/lib/Drupal/search/Routing/SearchController.php +++ b/core/modules/search/lib/Drupal/search/Controller/SearchController.php @@ -2,19 +2,51 @@ /** * @file - * Contains \Drupal\search\Routing\SearchController. + * Contains \Drupal\search\Controller\SearchController. */ -namespace Drupal\search\Routing; +namespace Drupal\search\Controller; +use Drupal\Core\ControllerInterface; +use Drupal\Core\Extension\ModuleHandlerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Request; -class SearchController { +/** + * Returns responses for search module routes. + */ +class SearchController implements ControllerInterface { + + /** + * The module handler. + * + * @var \Drupal\Core\Extension\ModuleHandlerInterface + */ + protected $moduleHandler; + + /** + * Creates a new SearchController. + * + * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler + * The module handler. + */ + public function __construct(ModuleHandlerInterface $module_handler) { + $this->moduleHandler = $module_handler; + } + + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container) { + return new static( + $container->get('module_handler') + ); + } /** - * Page callback: Presents the search form and/or search results. + * Presents the search form and/or search results. * * @param string $module * Search module to use for the search. @@ -82,7 +114,7 @@ public function searchView($module, $keys, Request $request) { } // @todo Refactor this once search form is converted to form interface. - \Drupal::moduleHandler()->loadInclude('search', 'inc', 'search.pages'); + $this->moduleHandler->loadInclude('search', 'inc', 'search.pages'); // The form may be altered based on whether the search was run. $build['search_form'] = drupal_get_form('search_form', NULL, $keys, $info['module']); diff --git a/core/modules/search/search.routing.yml b/core/modules/search/search.routing.yml index 620df25..1df5873 100644 --- a/core/modules/search/search.routing.yml +++ b/core/modules/search/search.routing.yml @@ -9,7 +9,7 @@ search_view: pattern: '/search/{module}/{keys}' method: [GET,POST] defaults: - _content: 'Drupal\search\Routing\SearchController::searchView' + _content: 'Drupal\search\Controller\SearchController::searchView' module: ~ keys: '' requirements: