Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function form(array $form, FormStateInterface $form_state)
 {
     $form['label'] = array('#type' => 'textfield', '#title' => $this->t('Label'), '#description' => $this->t('The label for this search page.'), '#default_value' => $this->entity->label(), '#maxlength' => '255');
     $form['id'] = array('#type' => 'machine_name', '#default_value' => $this->entity->id(), '#disabled' => !$this->entity->isNew(), '#maxlength' => 64, '#machine_name' => array('exists' => array($this, 'exists')));
     $form['path'] = array('#type' => 'textfield', '#title' => $this->t('Path'), '#field_prefix' => 'search/', '#default_value' => $this->entity->getPath(), '#maxlength' => '255', '#required' => TRUE);
     $form['plugin'] = array('#type' => 'value', '#value' => $this->entity->get('plugin'));
     if ($this->plugin instanceof PluginFormInterface) {
         $form += $this->plugin->buildConfigurationForm($form, $form_state);
     }
     return parent::form($form, $form_state);
 }
Exemplo n.º 2
0
 /**
  * Performs an operation on the search page entity.
  *
  * @param \Drupal\search\SearchPageInterface $search_page
  *   The search page entity.
  * @param string $op
  *   The operation to perform, usually 'enable' or 'disable'.
  *
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  *   A redirect back to the search settings page.
  */
 public function performOperation(SearchPageInterface $search_page, $op)
 {
     $search_page->{$op}()->save();
     if ($op == 'enable') {
         drupal_set_message($this->t('The %label search page has been enabled.', array('%label' => $search_page->label())));
     } elseif ($op == 'disable') {
         drupal_set_message($this->t('The %label search page has been disabled.', array('%label' => $search_page->label())));
     }
     return $this->redirect('search.settings');
 }
Exemplo n.º 3
0
 /**
  * Performs an operation on the search page entity.
  *
  * @param \Drupal\search\SearchPageInterface $search_page
  *   The search page entity.
  * @param string $op
  *   The operation to perform, usually 'enable' or 'disable'.
  *
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  *   A redirect back to the search settings page.
  */
 public function performOperation(SearchPageInterface $search_page, $op)
 {
     $search_page->{$op}()->save();
     if ($op == 'enable') {
         drupal_set_message($this->t('The %label search page has been enabled.', array('%label' => $search_page->label())));
     } elseif ($op == 'disable') {
         drupal_set_message($this->t('The %label search page has been disabled.', array('%label' => $search_page->label())));
     }
     $url = $search_page->urlInfo('collection');
     return $this->redirect($url->getRouteName(), $url->getRouteParameters(), $url->getOptions());
 }