示例#1
0
 /**
  * {@inheritdoc}
  */
 public function getDerivativeDefinitions($base_plugin_definition)
 {
     $this->derivatives = array();
     if ($default = $this->searchPageRepository->getDefaultSearchPage()) {
         $active_search_pages = $this->searchPageRepository->getActiveSearchPages();
         foreach ($this->searchPageRepository->sortSearchPages($active_search_pages) as $entity_id => $entity) {
             $this->derivatives[$entity_id] = array('title' => $entity->label(), 'route_name' => 'search.view_' . $entity_id, 'base_route' => 'search.plugins:' . $default, 'weight' => $entity->getWeight());
         }
     }
     return $this->derivatives;
 }
 /**
  * Returns an array of route objects.
  *
  * @return \Symfony\Component\Routing\Route[]
  *   An array of route objects.
  */
 public function routes()
 {
     $routes = array();
     // @todo Decide if /search should continue to redirect to /search/$default,
     //   or just perform the appropriate search.
     if ($default_page = $this->searchPageRepository->getDefaultSearchPage()) {
         $routes['search.view'] = new Route('/search', array('_content' => 'Drupal\\search\\Controller\\SearchController::redirectSearchPage', '_title' => 'Search', 'entity' => $default_page), array('_entity_access' => 'entity.view', '_permission' => 'search content'), array('parameters' => array('entity' => array('type' => 'entity:search_page'))));
     }
     $active_pages = $this->searchPageRepository->getActiveSearchPages();
     foreach ($active_pages as $entity_id => $entity) {
         $routes["search.view_{$entity_id}"] = new Route('/search/' . $entity->getPath(), array('_content' => 'Drupal\\search\\Controller\\SearchController::view', '_title' => 'Search', 'entity' => $entity_id), array('_entity_access' => 'entity.view', '_permission' => 'search content'), array('parameters' => array('entity' => array('type' => 'entity:search_page'))));
     }
     return $routes;
 }
示例#3
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, array &$form_state)
 {
     // Set up the form to submit using GET to the correct search page.
     $entity_id = $this->searchPageRepository->getDefaultSearchPage();
     if (!$entity_id) {
         $form['message'] = array('#markup' => $this->t('Search is currently disabled'));
         return $form;
     }
     $route = 'search.view_' . $entity_id;
     $form['#action'] = $this->url($route);
     $form['#token'] = FALSE;
     $form['#method'] = 'get';
     $form['keys'] = array('#type' => 'search', '#title' => $this->t('Search'), '#title_display' => 'invisible', '#size' => 15, '#default_value' => '', '#attributes' => array('title' => $this->t('Enter the terms you wish to search for.')));
     $form['actions'] = array('#type' => 'actions');
     $form['actions']['submit'] = array('#type' => 'submit', '#value' => $this->t('Search'), '#name' => '');
     return $form;
 }
示例#4
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     // Set up the form to submit using GET to the correct search page.
     $entity_id = $this->searchPageRepository->getDefaultSearchPage();
     if (!$entity_id) {
         $form['message'] = array('#markup' => $this->t('Search is currently disabled'));
         return $form;
     }
     $route = 'search.view_' . $entity_id;
     $form['#action'] = $this->url($route);
     $form['#method'] = 'get';
     $form['keys'] = array('#type' => 'search', '#title' => $this->t('Search'), '#title_display' => 'invisible', '#size' => 15, '#default_value' => '', '#attributes' => array('title' => $this->t('Enter the terms you wish to search for.')));
     $form['actions'] = array('#type' => 'actions');
     $form['actions']['submit'] = array('#type' => 'submit', '#value' => $this->t('Search'), '#name' => '');
     // SearchPageRepository::getDefaultSearchPage() depends on search.settings.
     $this->renderer->addCacheableDependency($form, $this->configFactory->get('search.settings'));
     return $form;
 }