diff --git a/core/lib/Drupal/Core/Entity/EntityListController.php b/core/lib/Drupal/Core/Entity/EntityListController.php index 7bf78c2..64c1c43 100644 --- a/core/lib/Drupal/Core/Entity/EntityListController.php +++ b/core/lib/Drupal/Core/Entity/EntityListController.php @@ -55,13 +55,6 @@ class EntityListController implements EntityListControllerInterface, EntityContr protected $translationManager; /** - * The URL generator. - * - * @var \Drupal\Core\Routing\UrlGeneratorInterface - */ - protected $urlGenerator; - - /** * {@inheritdoc} */ public static function createInstance(ContainerInterface $container, $entity_type, array $entity_info) { @@ -268,30 +261,4 @@ protected function getTitle() { return; } - /** - * Generates a URL or path for a specific route based on the given parameters. - * - * @see \Drupal\Core\Routing\UrlGeneratorInterface::generateFromRoute() for - * details on the arguments, usage, and possible exceptions. - * - * @return string - * The generated URL for the given route. - */ - public function url($route_name, $route_parameters = array(), $options = array()) { - return $this->urlGenerator()->generateFromRoute($route_name, $route_parameters, $options); - } - - /** - * Gets the URL generator. - * - * @return \Drupal\Core\Routing\UrlGeneratorInterface - * The URL generator. - */ - protected function urlGenerator() { - if (!$this->urlGenerator) { - $this->urlGenerator = \Drupal::urlGenerator(); - } - return $this->urlGenerator; - } - } diff --git a/core/modules/node/lib/Drupal/node/Plugin/Search/NodeSearch.php b/core/modules/node/lib/Drupal/node/Plugin/Search/NodeSearch.php index 67f0ab9..393de7d 100644 --- a/core/modules/node/lib/Drupal/node/Plugin/Search/NodeSearch.php +++ b/core/modules/node/lib/Drupal/node/Plugin/Search/NodeSearch.php @@ -77,7 +77,7 @@ class NodeSearch extends ConfigurableSearchPluginBase implements AccessibleInter protected $account; /** - * An array of additional rankings from other modules. + * An array of additional rankings from hook_ranking(). * * @var array */ @@ -523,10 +523,10 @@ public function searchFormSubmit(array &$form, array &$form_state) { } /** - * Gathers additional rankings from other modules. + * Gathers additional rankings from hook_ranking(). * * @return array - * An array of ranking information from other modules. + * An array of ranking information. */ protected function getRankings() { if (!$this->rankings) { diff --git a/core/modules/search/lib/Drupal/search/Controller/SearchController.php b/core/modules/search/lib/Drupal/search/Controller/SearchController.php index f0b5a81..07f5399 100644 --- a/core/modules/search/lib/Drupal/search/Controller/SearchController.php +++ b/core/modules/search/lib/Drupal/search/Controller/SearchController.php @@ -94,15 +94,17 @@ public function view(Request $request, SearchPageInterface $entity, $keys = '') } /** - * Redirects the generic search page to the default search page. + * Redirects to a search page. + * + * This is used to redirect from /search to the default search page. * * @param \Drupal\search\SearchPageInterface $entity * The search page entity. * * @return \Symfony\Component\HttpFoundation\RedirectResponse - * A redirect to the default search page. + * A redirect to the search page. */ - public function viewDefaultSearch(SearchPageInterface $entity) { + public function redirectSearchPage(SearchPageInterface $entity) { return $this->redirect('search.view_' . $entity->id()); } @@ -113,7 +115,7 @@ public function viewDefaultSearch(SearchPageInterface $entity) { * The search page entity. * * @return string - * The title for the search edit form. + * The title for the search page edit form. */ public function editTitle(SearchPageInterface $search_page) { return $this->t('Edit @label search', array('@label' => $search_page->label())); diff --git a/core/modules/search/lib/Drupal/search/Entity/SearchPage.php b/core/modules/search/lib/Drupal/search/Entity/SearchPage.php index c2583a9..d0b87ec 100644 --- a/core/modules/search/lib/Drupal/search/Entity/SearchPage.php +++ b/core/modules/search/lib/Drupal/search/Entity/SearchPage.php @@ -82,11 +82,17 @@ class SearchPage extends ConfigEntityBase implements SearchPageInterface { protected $plugin; /** + * The path this search page will appear upon. + * + * This value is appended to 'search/' when building the path. + * * @var string */ protected $path; /** + * The title of the search page. + * * @var string */ protected $title; diff --git a/core/modules/search/lib/Drupal/search/Form/SearchPageAddForm.php b/core/modules/search/lib/Drupal/search/Form/SearchPageAddForm.php index c119bba..6d25909 100644 --- a/core/modules/search/lib/Drupal/search/Form/SearchPageAddForm.php +++ b/core/modules/search/lib/Drupal/search/Form/SearchPageAddForm.php @@ -38,6 +38,8 @@ protected function actions(array $form, array &$form_state) { public function save(array $form, array &$form_state) { parent::save($form, $form_state); + drupal_set_message($this->t('The search page has been added.')); + $search_settings = $this->config('search.settings'); // If there is no default search page, make the added search the default. if (!$search_settings->get('default_page')) { diff --git a/core/modules/search/lib/Drupal/search/Form/SearchPageEditForm.php b/core/modules/search/lib/Drupal/search/Form/SearchPageEditForm.php index ddf1ad7..37a15ac 100644 --- a/core/modules/search/lib/Drupal/search/Form/SearchPageEditForm.php +++ b/core/modules/search/lib/Drupal/search/Form/SearchPageEditForm.php @@ -21,4 +21,13 @@ protected function actions(array $form, array &$form_state) { return $actions; } + /** + * {@inheritdoc} + */ + public function save(array $form, array &$form_state) { + parent::save($form, $form_state); + + drupal_set_message($this->t('The search page has been updated.')); + } + } diff --git a/core/modules/search/lib/Drupal/search/Form/SearchPageForm.php b/core/modules/search/lib/Drupal/search/Form/SearchPageForm.php index 2345df2..710d931 100644 --- a/core/modules/search/lib/Drupal/search/Form/SearchPageForm.php +++ b/core/modules/search/lib/Drupal/search/Form/SearchPageForm.php @@ -16,6 +16,8 @@ class SearchPageForm extends EntityFormController { /** + * {@inheritdoc} + * * @var \Drupal\search\SearchPageInterface */ protected $entity; diff --git a/core/modules/search/lib/Drupal/search/Form/SearchPageFormBase.php b/core/modules/search/lib/Drupal/search/Form/SearchPageFormBase.php index 34bc307..d189b52 100644 --- a/core/modules/search/lib/Drupal/search/Form/SearchPageFormBase.php +++ b/core/modules/search/lib/Drupal/search/Form/SearchPageFormBase.php @@ -79,7 +79,7 @@ public function form(array $form, array &$form_state) { $form['label'] = array( '#type' => 'textfield', '#title' => $this->t('Label'), - '#description' => $this->t('The administrative label for this search'), + '#description' => $this->t('The administrative label for this search page'), '#default_value' => $this->entity->label(), '#maxlength' => '255', ); @@ -181,7 +181,6 @@ public function submit(array $form, array &$form_state) { */ public function save(array $form, array &$form_state) { $this->entity->save(); - drupal_set_message($this->t('The search has been successfully saved.')); $form_state['redirect_route']['route_name'] = 'search.settings'; } diff --git a/core/modules/search/lib/Drupal/search/Plugin/Derivative/SearchLocalTask.php b/core/modules/search/lib/Drupal/search/Plugin/Derivative/SearchLocalTask.php index 632df51..716226c 100644 --- a/core/modules/search/lib/Drupal/search/Plugin/Derivative/SearchLocalTask.php +++ b/core/modules/search/lib/Drupal/search/Plugin/Derivative/SearchLocalTask.php @@ -14,7 +14,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface; /** - * Provides local tasks for each search plugin. + * Provides local tasks for each search page. */ class SearchLocalTask extends DerivativeBase implements ContainerDerivativeInterface { diff --git a/core/modules/search/lib/Drupal/search/Routing/SearchRouteSubscriber.php b/core/modules/search/lib/Drupal/search/Routing/SearchRouteSubscriber.php index 5e83030..fa8d439 100644 --- a/core/modules/search/lib/Drupal/search/Routing/SearchRouteSubscriber.php +++ b/core/modules/search/lib/Drupal/search/Routing/SearchRouteSubscriber.php @@ -43,7 +43,7 @@ protected function routes(RouteCollection $collection) { // or just perform the appropriate search. if ($default_page = $this->searchStorage->getDefaultSearchPage()) { $defaults = array( - '_content' => 'Drupal\search\Controller\SearchController::viewDefaultSearch', + '_content' => 'Drupal\search\Controller\SearchController::redirectSearchPage', '_title' => 'Search', 'entity' => $default_page, ); diff --git a/core/modules/search/lib/Drupal/search/SearchPageListController.php b/core/modules/search/lib/Drupal/search/SearchPageListController.php index 2f6c3a9..7bb1093 100644 --- a/core/modules/search/lib/Drupal/search/SearchPageListController.php +++ b/core/modules/search/lib/Drupal/search/SearchPageListController.php @@ -133,9 +133,17 @@ public function buildRow(EntityInterface $entity) { /** @var $entity \Drupal\search\SearchPageInterface */ $row['label'] = $this->getLabel($entity); $definition = $entity->getPlugin()->getPluginDefinition(); - // Hardcode the path instead of the route so that disabled search paths are - // still displayed. $row['url'] = 'search/' . $entity->getPath(); + // If the search page is active, link to it. + if ($entity->status()) { + $row['url'] = array( + 'data' => array( + '#type' => 'link', + '#title' => $row['url'], + '#route_name' => 'search.view_' . $entity->id(), + ), + ); + } $row['plugin'] = $definition['title']; $row['status'] = $entity->status() ? $this->t('Enabled') : $this->t('Disabled'); return $row + parent::buildRow($entity); @@ -184,7 +192,7 @@ public function buildForm(array $form, array &$form_state) { '#title' => $this->t('Number of items to index per cron run'), '#default_value' => $search_settings->get('index.cron_limit'), '#options' => $items, - '#description' => $this->t('The maximum number of items indexed in each pass of a cron maintenance task. If necessary, reduce the number of items to prevent timeouts and memory errors while indexing.', array('@cron' => $this->url('system.status'))), + '#description' => $this->t('The maximum number of items indexed in each pass of a cron maintenance task. If necessary, reduce the number of items to prevent timeouts and memory errors while indexing.', array('@cron' => url('admin/reports/status'))), ); // Indexing settings: $form['indexing_settings'] = array( diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchConfigSettingsFormTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchConfigSettingsFormTest.php index 4b97532..066888b 100644 --- a/core/modules/search/lib/Drupal/search/Tests/SearchConfigSettingsFormTest.php +++ b/core/modules/search/lib/Drupal/search/Tests/SearchConfigSettingsFormTest.php @@ -125,7 +125,7 @@ function testSearchModuleSettingsPage() { $this->drupalPostForm(NULL, $edit, t('Save search page')); // Ensure that the modifications took effect. - $this->assertText(t('The search has been successfully saved.')); + $this->assertText(t('The search page has been updated.')); $this->drupalGet('admin/config/search/settings/manage/dummy_search_type'); $this->assertTrue($this->xpath('//select[@id="edit-extra-type-settings-boost"]//option[@value="ii" and @selected="selected"]'), 'Module specific settings can be changed'); } @@ -243,6 +243,7 @@ public function testMultipleSearchPages() { $first['path'] = strtolower($this->randomName(8)); $this->drupalPostForm(NULL, $first, t('Add search page')); $this->assertDefaultSearch($first_id, 'The default page matches the only search page.'); + $this->assertText(t('The search page has been added.')); // Add a second search page. $edit = array();