Move into nested docroot

This commit is contained in:
Rob Davies 2017-02-13 15:31:17 +00:00
parent 83a0d3a149
commit c8b70abde9
13405 changed files with 0 additions and 0 deletions

View file

@ -0,0 +1,6 @@
name: 'Search Date Query Alter'
type: module
description: 'Test module that adds date conditions to node searches.'
package: Testing
version: VERSION
core: 8.x

View file

@ -0,0 +1,18 @@
<?php
/**
* @file
* Adds date conditions to node searches.
*/
use Drupal\Core\Database\Query\AlterableInterface;
/**
* Implements hook_query_TAG_alter(): tag search_$type with $type node_search.
*/
function search_date_query_alter_query_search_node_search_alter(AlterableInterface $query) {
// Start date Sat, 19 Mar 2016 00:00:00 GMT.
$query->condition('n.created', 1458345600, '>=');
// End date Sun, 20 Mar 2016 00:00:00 GMT.
$query->condition('n.created', 1458432000, '<');
}

View file

@ -0,0 +1,6 @@
name: 'Search Embedded Form'
type: module
description: 'Support module for Search module testing of embedded forms.'
package: Testing
version: VERSION
core: 8.x

View file

@ -0,0 +1,18 @@
<?php
/**
* @file
* Test module implementing a form that can be embedded in search results.
*
* A sample use of an embedded form is an e-commerce site where each search
* result may include an embedded form with buttons like "Add to cart" for each
* individual product (node) listed in the search results.
*/
/**
* Adds the test form to search results.
*/
function search_embedded_form_preprocess_search_result(&$variables) {
$form = \Drupal::formBuilder()->getForm('Drupal\search_embedded_form\Form\SearchEmbeddedForm');
$variables['snippet'] = array_merge($variables['snippet'], $form);
}

View file

@ -0,0 +1,7 @@
search_embedded_form.test_embedded_form:
path: '/search_embedded_form'
defaults:
_title: 'Search_Embed_Form'
_form: '\Drupal\search_embedded_form\Form\SearchEmbeddedForm'
requirements:
_permission: 'search content'

View file

@ -0,0 +1,54 @@
<?php
namespace Drupal\search_embedded_form\Form;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
/**
* Form controller for search_embedded_form form.
*/
class SearchEmbeddedForm extends FormBase {
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'search_embedded_form';
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$count = \Drupal::state()->get('search_embedded_form.submit_count');
$form['name'] = array(
'#type' => 'textfield',
'#title' => $this->t('Your name'),
'#maxlength' => 255,
'#default_value' => '',
'#required' => TRUE,
'#description' => $this->t('Times form has been submitted: %count', array('%count' => $count)),
);
$form['actions'] = array('#type' => 'actions');
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => $this->t('Send away'),
);
return $form;
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$state = \Drupal::state();
$submit_count = (int) $state->get('search_embedded_form.submit_count');
$state->set('search_embedded_form.submit_count', $submit_count + 1);
drupal_set_message($this->t('Test form was submitted'));
}
}

View file

@ -0,0 +1,7 @@
id: dummy_search_type
label: 'Dummy search type'
status: true
langcode: en
path: dummy_path
plugin: search_extra_type_search
configuration: { }

View file

@ -0,0 +1,18 @@
# Schema for the configuration files of the Search Extra Type module.
search_extra_type.settings:
type: mapping
label: 'Test search type settings'
mapping:
boost:
type: string
label: 'String'
# Plugin \Drupal\search_extra_type\Plugin\Search\SearchExtraTypeSearch
search.plugin.search_extra_type_search:
type: mapping
label: 'Extra type settings'
mapping:
boost:
type: string
label: 'Boost method'

View file

@ -0,0 +1,9 @@
name: 'Test Search Type'
type: module
description: 'Support module for Search module testing.'
package: Testing
version: VERSION
core: 8.x
dependencies:
- test_page_test

View file

@ -0,0 +1,128 @@
<?php
namespace Drupal\search_extra_type\Plugin\Search;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Routing\UrlGeneratorTrait;
use Drupal\Core\Url;
use Drupal\search\Plugin\ConfigurableSearchPluginBase;
/**
* Executes a dummy keyword search.
*
* @SearchPlugin(
* id = "search_extra_type_search",
* title = @Translation("Dummy search type")
* )
*/
class SearchExtraTypeSearch extends ConfigurableSearchPluginBase {
use UrlGeneratorTrait;
/**
* {@inheritdoc}
*/
public function setSearch($keywords, array $parameters, array $attributes) {
if (empty($parameters['search_conditions'])) {
$parameters['search_conditions'] = '';
}
parent::setSearch($keywords, $parameters, $attributes);
}
/**
* Verifies if the given parameters are valid enough to execute a search for.
*
* @return bool
* TRUE if there are keywords or search conditions in the query.
*/
public function isSearchExecutable() {
return (bool) ($this->keywords || !empty($this->searchParameters['search_conditions']));
}
/**
* Execute the search.
*
* This is a dummy search, so when search "executes", we just return a dummy
* result containing the keywords and a list of conditions.
*
* @return array
* A structured list of search results
*/
public function execute() {
$results = array();
if (!$this->isSearchExecutable()) {
return $results;
}
return array(
array(
'link' => Url::fromRoute('test_page_test.test_page')->toString(),
'type' => 'Dummy result type',
'title' => 'Dummy title',
'snippet' => SafeMarkup::format("Dummy search snippet to display. Keywords: @keywords\n\nConditions: @search_parameters", ['@keywords' => $this->keywords, '@search_parameters' => print_r($this->searchParameters, TRUE)]),
),
);
}
/**
* {@inheritdoc}
*/
public function buildResults() {
$results = $this->execute();
$output['prefix']['#markup'] = '<h2>Test page text is here</h2> <ol class="search-results">';
foreach ($results as $entry) {
$output[] = array(
'#theme' => 'search_result',
'#result' => $entry,
'#plugin_id' => 'search_extra_type_search',
);
}
$pager = array(
'#type' => 'pager',
);
$output['suffix']['#markup'] = '</ol>' . drupal_render($pager);
return $output;
}
/**
* {@inheritdoc}
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
// Output form for defining rank factor weights.
$form['extra_type_settings'] = array(
'#type' => 'fieldset',
'#title' => t('Extra type settings'),
'#tree' => TRUE,
);
$form['extra_type_settings']['boost'] = array(
'#type' => 'select',
'#title' => t('Boost method'),
'#options' => array(
'bi' => t('Bistromathic'),
'ii' => t('Infinite Improbability'),
),
'#default_value' => $this->configuration['boost'],
);
return $form;
}
/**
* {@inheritdoc}
*/
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
$this->configuration['boost'] = $form_state->getValue(array('extra_type_settings', 'boost'));
}
/**
* {@inheritdoc}
*/
public function defaultConfiguration() {
return array(
'boost' => 'bi',
);
}
}

View file

@ -0,0 +1,6 @@
name: 'Test search entity langcode'
type: module
description: 'Support module for search module testing.'
package: Testing
version: VERSION
core: 8.x

View file

@ -0,0 +1,40 @@
<?php
/**
* @file
* Test module setting up two tests, one for checking if the entity $langcode is
* being passed on and another one sets up the alternate verb forms for the
* stemming test.
*/
/**
* Implements hook_search_preprocess().
*/
function search_langcode_test_search_preprocess($text, $langcode = NULL) {
if (isset($langcode) && $langcode == 'en') {
// Add the alternate verb forms for the word "testing".
if ($text == 'we are testing') {
$text .= ' test tested';
}
// Prints the langcode for testPreprocessLangcode() and adds some
// extra text.
else {
drupal_set_message('Langcode Preprocess Test: ' . $langcode);
$text .= 'Additional text';
}
}
// Prints the langcode for testPreprocessLangcode().
elseif (isset($langcode)) {
drupal_set_message('Langcode Preprocess Test: ' . $langcode);
// Preprocessing for the excerpt test.
if ($langcode == 'ex') {
$text = str_replace('finding', 'find', $text);
$text = str_replace('finds', 'find', $text);
$text = str_replace('dic', ' dependency injection container', $text);
$text = str_replace('hypertext markup language', 'html', $text);
}
}
return $text;
}

View file

@ -0,0 +1,6 @@
name: 'Test Search Query Alter'
type: module
description: 'Support module for Search module testing.'
package: Testing
version: VERSION
core: 8.x

View file

@ -0,0 +1,16 @@
<?php
/**
* @file
* Test module that alters search queries.
*/
use Drupal\Core\Database\Query\AlterableInterface;
/**
* Implements hook_query_TAG_alter(): tag search_$type with $type node_search.
*/
function search_query_alter_query_search_node_search_alter(AlterableInterface $query) {
// For testing purposes, restrict the query to node type 'article' only.
$query->condition('n.type', 'article');
}