Browse Source

added dependancy on the message module so we can log search requests

d9
ppound 3 years ago
parent
commit
ae2f7960ac
  1. 1
      roblib_search.info.yml
  2. 17
      roblib_search.module
  3. 8
      src/Form/RoblibSearchForm.php

1
roblib_search.info.yml

@ -7,3 +7,4 @@ package: Roblib Search
dependancies: dependancies:
- apachesolr_access - apachesolr_access
- views_ui - views_ui
- message

17
roblib_search.module

@ -45,23 +45,6 @@ function roblib_search_block_info() {
return $blocks; return $blocks;
} }
/**
* Implements hook_theme().
*/
/*function roblib_search_theme() {
$path = drupal_get_path('module', 'roblib_search');
$file = 'theme.inc';
return array(
'roblib_search_other_sources' => array(
'path' => $path . '/theme',
'file' => $file,
'template' => 'roblib-search-other-sources',
'variables' => array('results' => NULL),
)
);
}*/
/** /**
* Implements hook_theme(). * Implements hook_theme().
*/ */

8
src/Form/RoblibSearchForm.php

@ -6,6 +6,8 @@ use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
use Drupal\Component\Utility\Html; use Drupal\Component\Utility\Html;
use Drupal\Core\Url; use Drupal\Core\Url;
use Drupal\message\Entity\Message;
/** /**
* Config form for module * Config form for module
@ -66,7 +68,11 @@ class RoblibSearchForm extends FormBase{
public function submitForm(array &$form, FormStateInterface $form_state) { public function submitForm(array &$form, FormStateInterface $form_state) {
$search_string = $form_state->getValue('roblib_search_simple_search_query'); $search_string = $form_state->getValue('roblib_search_simple_search_query');
$search_string = Html::escape($search_string); $search_string = Html::escape($search_string);
//roblib_search_log_query($search_string); $message = Message::create(['template' => 'roblib_search_message_template',
'uid' => \Drupal::currentUser()->id()]);
$message->set('field_ip_address', \Drupal::request()->getClientIp());
$message->set('field_search_string', $search_string);
$message->save();
$url = Url::fromUserInput('/roblib_search/' . $search_string); $url = Url::fromUserInput('/roblib_search/' . $search_string);
$form_state->setRedirectUrl($url); $form_state->setRedirectUrl($url);
} }

Loading…
Cancel
Save