diff --git a/core_search_facets/src/FacetsQuery.php b/core_search_facets/src/FacetsQuery.php
index a34c0550c3b95c05f7d4faf690437e1451ab75a8..9eb134746a01c3955e436c71514a71f1aed50ff4 100644
--- a/core_search_facets/src/FacetsQuery.php
+++ b/core_search_facets/src/FacetsQuery.php
@@ -80,8 +80,8 @@ class FacetsQuery extends SearchQuery {
// For complex search queries, add the LIKE conditions.
/*if (!$this->simple) {
- $this->join('search_dataset', 'd', 'i.sid = d.sid AND i.type = d.type');
- $this->condition($this->conditions);
+ $this->join('search_dataset', 'd', 'i.sid = d.sid AND i.type = d.type');
+ $this->condition($this->conditions);
}*/
// Add conditions to query.
diff --git a/core_search_facets/src/Plugin/Search/NodeSearchFacets.php b/core_search_facets/src/Plugin/Search/NodeSearchFacets.php
index ab5687c659fa347dd12a609795b06dd636085075..3b499abab401b2af508d3f61eda07828674bfb1f 100644
--- a/core_search_facets/src/Plugin/Search/NodeSearchFacets.php
+++ b/core_search_facets/src/Plugin/Search/NodeSearchFacets.php
@@ -9,15 +9,17 @@ namespace Drupal\core_search_facets\Plugin\Search;
use Drupal\Core\Config\Config;
use Drupal\Core\Database\Driver\mysql\Connection;
-use Drupal\Core\Entity\EntityManagerInterface;
+use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Language\LanguageInterface;
use Drupal\Core\Language\LanguageManagerInterface;
use Drupal\Core\Session\AccountInterface;
+use Drupal\facets\FacetSource\FacetSourcePluginManager;
use Drupal\node\Plugin\Search\NodeSearch;
use Drupal\Core\Render\RendererInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
+use Symfony\Component\HttpFoundation\RequestStack;
/**
* Handles searching for node entities using the Search module index.
@@ -34,13 +36,13 @@ class NodeSearchFacets extends NodeSearch {
$plugin_id,
$plugin_definition,
Connection $database,
- EntityManagerInterface $entity_manager,
+ EntityTypeManagerInterface $entity_manager,
ModuleHandlerInterface $module_handler,
Config $search_settings,
LanguageManagerInterface $language_manager,
RendererInterface $renderer,
- $facet_source_plugin_manager,
- $request_stack,
+ FacetSourcePluginManager $facet_source_plugin_manager,
+ RequestStack $request_stack,
AccountInterface $account = NULL) {
parent::__construct($configuration, $plugin_id, $plugin_definition, $database, $entity_manager, $module_handler, $search_settings, $language_manager, $renderer, $account);
@@ -60,7 +62,7 @@ class NodeSearchFacets extends NodeSearch {
$plugin_id,
$plugin_definition,
$container->get('database'),
- $container->get('entity.manager'),
+ $container->get('entity_type.manager'),
$container->get('module_handler'),
$container->get('config.factory')->get('search.settings'),
$container->get('language_manager'),
@@ -96,6 +98,7 @@ class NodeSearchFacets extends NodeSearch {
'#access' => $this->account && $this->account->hasPermission('use advanced search'),
'#open' => $used_advanced,
);
+
$form['advanced']['keywords-fieldset'] = array(
'#type' => 'fieldset',
'#title' => t('Keywords'),
diff --git a/core_search_facets/src/Plugin/facets/facet_source/CoreNodeSearchFacetSource.php b/core_search_facets/src/Plugin/facets/facet_source/CoreNodeSearchFacetSource.php
index 92bd17b5a3f78918e859383f2c38487d8620f27c..0fd5dcc18b573e07c4fc152b2f0bf8950f97d1a5 100644
--- a/core_search_facets/src/Plugin/facets/facet_source/CoreNodeSearchFacetSource.php
+++ b/core_search_facets/src/Plugin/facets/facet_source/CoreNodeSearchFacetSource.php
@@ -13,10 +13,11 @@ use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\core_search_facets\Plugin\CoreSearchFacetSourceInterface;
use Drupal\facets\FacetInterface;
use Drupal\facets\FacetSource\FacetSourcePluginBase;
-use Drupal\facets\FacetSource\FacetSourcePluginInterface;
+use Drupal\facets\QueryType\QueryTypePluginManager;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\search\SearchPageInterface;
+use Drupal\search\SearchPluginManager;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\RequestStack;
@@ -54,6 +55,11 @@ class CoreNodeSearchFacetSource extends FacetSourcePluginBase implements CoreSea
*/
protected $configFactory;
+ /**
+ * The plugin manager for core search plugins.
+ *
+ * @var \Drupal\search\SearchPluginManager
+ */
protected $searchManager;
/**
@@ -64,7 +70,7 @@ class CoreNodeSearchFacetSource extends FacetSourcePluginBase implements CoreSea
/**
* {@inheritdoc}
*/
- public function __construct(array $configuration, $plugin_id, array $plugin_definition, $query_type_plugin_manager, $search_manager, RequestStack $request_stack) {
+ public function __construct(array $configuration, $plugin_id, array $plugin_definition, QueryTypePluginManager $query_type_plugin_manager, SearchPluginManager $search_manager, RequestStack $request_stack) {
parent::__construct($configuration, $plugin_id, $plugin_definition, $query_type_plugin_manager);
$this->searchManager = $search_manager;
$this->setSearchKeys($request_stack->getMasterRequest()->query->get('keys'));
@@ -112,7 +118,6 @@ class CoreNodeSearchFacetSource extends FacetSourcePluginBase implements CoreSea
// Get the Facet Specific Query Type so we can process the results
// using the build() function of the query type.
- /** @var \Drupal\facets\Entity\Facet $facet **/
$query_type = $this->queryTypePluginManager->createInstance($facet->getQueryType(), $configuration);
$query_type->build();
}
@@ -143,7 +148,7 @@ class CoreNodeSearchFacetSource extends FacetSourcePluginBase implements CoreSea
* @return array
* An array of query types.
*/
- public function getQueryTypesForFieldType($field_type) {
+ protected function getQueryTypesForFieldType($field_type) {
$query_types = [];
switch ($field_type) {
case 'type':
@@ -204,10 +209,13 @@ class CoreNodeSearchFacetSource extends FacetSourcePluginBase implements CoreSea
// Get the current field instances and detect if the field type is allowed.
$fields = FieldConfig::loadMultiple();
+ /** @var \Drupal\Field\FieldConfigInterface $field */
foreach ($fields as $field) {
// Verify if the target type is allowed for entity reference fields,
// otherwise verify the field type(i.e. integer, float...).
- if (in_array($field->getFieldStorageDefinition()->getSetting('target_type'), $allowed_field_types) || in_array($field->getFieldStorageDefinition()->getType(), $allowed_field_types)) {
+ $target_is_allowed = in_array($field->getFieldStorageDefinition()->getSetting('target_type'), $allowed_field_types);
+ $field_is_allowed = in_array($field->getFieldStorageDefinition()->getType(), $allowed_field_types);
+ if ($target_is_allowed || $field_is_allowed) {
/** @var \Drupal\field\Entity\FieldConfig $field */
if (!array_key_exists($field->getName(), $facet_fields)) {
$facet_fields[$field->getName()] = $this->t('@label', ['@label' => $field->getLabel()]);
@@ -222,6 +230,7 @@ class CoreNodeSearchFacetSource extends FacetSourcePluginBase implements CoreSea
* Getter for default node fields.
*
* @return array
+ * An array containing the default fields enabled on a node.
*/
protected function getDefaultFields() {
return [
@@ -235,14 +244,14 @@ class CoreNodeSearchFacetSource extends FacetSourcePluginBase implements CoreSea
* {@inheritdoc}
*/
public function getFacetQueryExtender() {
- if (!$this->facetQueryExtender) {
- $this->facetQueryExtender = db_select('search_index', 'i', array('target' => 'replica'))->extend('Drupal\core_search_facets\FacetsQuery');
- $this->facetQueryExtender->join('node_field_data', 'n', 'n.nid = i.sid');
- $this->facetQueryExtender
+ if (!$this->facetQueryExtender) {
+ $this->facetQueryExtender = db_select('search_index', 'i', array('target' => 'replica'))->extend('Drupal\core_search_facets\FacetsQuery');
+ $this->facetQueryExtender->join('node_field_data', 'n', 'n.nid = i.sid');
+ $this->facetQueryExtender
// ->condition('n.status', 1).
->addTag('node_access')
->searchExpression($this->keys, 'node_search');
- }
+ }
return $this->facetQueryExtender;
}
@@ -254,10 +263,10 @@ class CoreNodeSearchFacetSource extends FacetSourcePluginBase implements CoreSea
$field_name = $facet->getFieldIdentifier();
$default_fields = $this->getDefaultFields();
if (array_key_exists($facet->getFieldIdentifier(), $default_fields)) {
- // We add the language code of the indexed item to the result of the query.
- // So in this case we need to use the search_index table alias (i) for the
- // langcode field. Otherwise we will have same nid for multiple languages
- // as result. For more details see NodeSearch::findResults().
+ // We add the language code of the indexed item to the result of the
+ // query. So in this case we need to use the search_index table alias (i)
+ // for the langcode field. Otherwise we will have same nid for multiple
+ // languages as result. For more details see NodeSearch::findResults().
// @TODO review if I can refactor this.
$table_alias = $facet->getFieldIdentifier() == 'langcode' ? 'i' : 'n';
$query_info = [
diff --git a/core_search_facets/src/Plugin/facets/facet_source/CoreNodeSearchFacetSourceDeriver.php b/core_search_facets/src/Plugin/facets/facet_source/CoreNodeSearchFacetSourceDeriver.php
index f1ba3cdfba6679f16102d87bd081b3300ba2dd06..e14b48739665e06ec784dfd5329e42c23bf3de5c 100644
--- a/core_search_facets/src/Plugin/facets/facet_source/CoreNodeSearchFacetSourceDeriver.php
+++ b/core_search_facets/src/Plugin/facets/facet_source/CoreNodeSearchFacetSourceDeriver.php
@@ -8,7 +8,9 @@
namespace Drupal\core_search_facets\Plugin\facets\facet_source;
use Drupal\Component\Plugin\PluginBase;
+use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\facets\FacetSource\FacetSourceDeriverBase;
+use Drupal\search\SearchPluginManager;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
@@ -18,12 +20,24 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
*/
class CoreNodeSearchFacetSourceDeriver extends FacetSourceDeriverBase {
+ /**
+ * The plugin manager for core search plugins.
+ *
+ * @var \Drupal\search\SearchPluginManager
+ */
protected $searchManager;
/**
- * Create an instance of the deriver.
+ * Creates an instance of the deriver.
+ *
+ * @param string $base_plugin_id
+ * The plugin ID.
+ * @param \Drupal\search\SearchPluginManager $search_manager
+ * The plugin manager for core search plugins.
+ * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
+ * The entity manager.
*/
- public function __construct(ContainerInterface $container, $base_plugin_id, $search_manager, $entity_type_manager) {
+ public function __construct($base_plugin_id, SearchPluginManager $search_manager, EntityTypeManagerInterface $entity_type_manager) {
$this->searchManager = $search_manager;
$this->entityTypeManager = $entity_type_manager;
}
@@ -33,11 +47,10 @@ class CoreNodeSearchFacetSourceDeriver extends FacetSourceDeriverBase {
*/
public static function create(ContainerInterface $container, $base_plugin_id) {
return new static(
- $container,
$base_plugin_id,
$container->get('plugin.manager.search'),
$container->get('entity_type.manager')
- );
+ );
}
/**
diff --git a/core_search_facets/src/Plugin/facets/query_type/CoreNodeSearchString.php b/core_search_facets/src/Plugin/facets/query_type/CoreNodeSearchString.php
index 74a896f4d957e8c8f0ee14f0e94ae225224f0c01..783455092c77e914711341397eb7cbe8c9d09936 100644
--- a/core_search_facets/src/Plugin/facets/query_type/CoreNodeSearchString.php
+++ b/core_search_facets/src/Plugin/facets/query_type/CoreNodeSearchString.php
@@ -21,7 +21,7 @@ use Drupal\facets\Result\Result;
class CoreNodeSearchString extends QueryTypePluginBase {
/**
- * Holds the backend's native query object.
+ * The backend's native query object.
*
* @var \Drupal\search_api\Query\QueryInterface
*/
@@ -31,7 +31,6 @@ class CoreNodeSearchString extends QueryTypePluginBase {
* {@inheritdoc}
*/
public function execute() {
-
/** @var \Drupal\core_search_facets\Plugin\CoreSearchFacetSourceInterface $facet_source */
$facet_source = $this->facet->getFacetSource();
$query_info = $facet_source->getQueryInfo($this->facet);
diff --git a/core_search_facets/src/Tests/HooksTest.php b/core_search_facets/src/Tests/HooksTest.php
index b3dac67b30363af2ddeacd6e42c086bbbd1d2c61..dfc31c938e34fa45299594b4525dc83c2a6d5cc5 100644
--- a/core_search_facets/src/Tests/HooksTest.php
+++ b/core_search_facets/src/Tests/HooksTest.php
@@ -9,7 +9,6 @@ namespace Drupal\core_search_facets\Tests;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
-use Drupal\field_ui\Tests\FieldUiTestTrait;
/**
* Tests integration of hooks.
@@ -25,7 +24,7 @@ class HooksTest extends WebTestBase {
'node',
'search',
'core_search_facets_test_hooks',
- 'field'
+ 'field',
];
/**
@@ -49,7 +48,7 @@ class HooksTest extends WebTestBase {
'field_name' => 'float',
'entity_type' => 'node',
'bundle' => 'page',
- 'label' => 'Float Field Label'
+ 'label' => 'Float Field Label',
]
)->save();
@@ -62,7 +61,6 @@ class HooksTest extends WebTestBase {
*/
public function testHooks() {
// Verify that hook_facets_core_allowed_field_types was triggered.
-
$facet_add_page = 'admin/config/search/facets/add-facet';
$this->drupalGet($facet_add_page);
$this->assertResponse(200);
diff --git a/core_search_facets/src/Tests/IntegrationTest.php b/core_search_facets/src/Tests/IntegrationTest.php
index c69edff984db30bc85a732a88d859c853e6cf1eb..6209476cb0701894bb5a1b0839d844c4ba75c41e 100644
--- a/core_search_facets/src/Tests/IntegrationTest.php
+++ b/core_search_facets/src/Tests/IntegrationTest.php
@@ -35,8 +35,9 @@ class IntegrationTest extends CoreSearchFacetsWebTestBase {
\Drupal::service('plugin.manager.search')->createInstance('node_search')->updateIndex();
search_update_totals();
- // Remove the facet blocks each time we run a new test.
- unset($this->blocks);
+ // Make absolutely sure the ::$blocks variable doesn't pass information
+ // along between tests.
+ $this->blocks = NULL;
}
/**
diff --git a/core_search_facets/src/Tests/WebTestBase.php b/core_search_facets/src/Tests/WebTestBase.php
index f9ffb0c09d25fcc093e0714494e5cc3bea5f09e2..e68b66d05b5ea584d41d46503ae385fddd2cd784 100644
--- a/core_search_facets/src/Tests/WebTestBase.php
+++ b/core_search_facets/src/Tests/WebTestBase.php
@@ -93,10 +93,6 @@ abstract class WebTestBase extends SimpletestWebTestBase {
'administer blocks',
'search content',
]);
-
- $this->unauthorizedUser = $this->drupalCreateUser(['access administration pages']);
- $this->anonymousUser = $this->drupalCreateUser();
-
}
}
diff --git a/facets.module b/facets.module
index ceda0c85930174c7b2039a33cf6253e4d86ac762..2e89c4a675503cfc7967e5592fb53703390a3e38 100644
--- a/facets.module
+++ b/facets.module
@@ -7,12 +7,10 @@
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\search_api\Query\QueryInterface;
-use Drupal\facets\FacetInterface;
/**
* Implements hook_help().
*/
-
function facets_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
// Main module help for the facets module.
diff --git a/src/Annotation/FacetsFacetSource.php b/src/Annotation/FacetsFacetSource.php
index 7389e311a746468f4de0b41cd7df04fdb0c5d317..550313dc89f8cf3f0fb24824c00e9a1ea6874c01 100644
--- a/src/Annotation/FacetsFacetSource.php
+++ b/src/Annotation/FacetsFacetSource.php
@@ -2,7 +2,7 @@
/**
* @file
- * Contains \Drupal\facets\Annotation\FacetsFacet.
+ * Contains \Drupal\facets\Annotation\FacetsFacetSource.
*/
namespace Drupal\facets\Annotation;
@@ -29,7 +29,7 @@ class FacetsFacetSource extends Plugin {
public $id;
/**
- * The human-readable name of the facet soruce plugin.
+ * The human-readable name of the facet source plugin.
*
* @ingroup plugin_translatable
*
diff --git a/src/Entity/Facet.php b/src/Entity/Facet.php
index a75a505c294944d475f5aad58c45435c936aec16..c28d7e357f1a831f26c0d004ed2fac5a4de31ce9 100644
--- a/src/Entity/Facet.php
+++ b/src/Entity/Facet.php
@@ -167,6 +167,11 @@ class Facet extends ConfigEntityBase implements FacetInterface {
*/
protected $unfiltered_results = [];
+ /**
+ * An array of active values.
+ *
+ * @var string[]
+ */
protected $active_values = [];
/**
@@ -239,7 +244,7 @@ class Facet extends ConfigEntityBase implements FacetInterface {
}
/**
- * Gets the widget plugin manager.
+ * Returns the widget plugin manager.
*
* @return \Drupal\facets\Widget\WidgetPluginManager
* The widget plugin manager.
@@ -250,13 +255,6 @@ class Facet extends ConfigEntityBase implements FacetInterface {
return $this->widget_plugin_manager ?: $container->get('plugin.manager.facets.widget');
}
- /**
- * {@inheritdoc}
- */
- public function id() {
- return $this->id;
- }
-
/**
* {@inheritdoc}
*/
@@ -320,7 +318,7 @@ class Facet extends ConfigEntityBase implements FacetInterface {
\Drupal::logger('facets')
->warning('Processor @id specifies a non-existing @class.', array(
'@id' => $name,
- '@class' => $processor_definition['class']
+ '@class' => $processor_definition['class'],
));
}
}
@@ -568,7 +566,7 @@ class Facet extends ConfigEntityBase implements FacetInterface {
\Drupal::logger('facets')
->warning('Facet Source @id specifies a non-existing @class.', [
'@id' => $name,
- '@class' => $facet_source_definition['class']
+ '@class' => $facet_source_definition['class'],
]);
}
}
@@ -674,7 +672,7 @@ class Facet extends ConfigEntityBase implements FacetInterface {
/**
* {@inheritdoc}
*/
- public function setEmptyBehavior($empty_behavior) {
+ public function setEmptyBehavior(array $empty_behavior) {
$this->empty_behavior = $empty_behavior;
}
diff --git a/src/Entity/FacetSource.php b/src/Entity/FacetSource.php
index 9aa4733775ab572d8a74817d4b9427abfcd6a0a7..5768a6ad90911d5f0dd6dc6fee2d7df05fc202bc 100644
--- a/src/Entity/FacetSource.php
+++ b/src/Entity/FacetSource.php
@@ -9,7 +9,6 @@ namespace Drupal\facets\Entity;
use Drupal\Core\Config\Entity\ConfigEntityBase;
use Drupal\facets\FacetSourceInterface;
-use Drupal\facets\UrlProcessor\UrlProcessorInterface;
/**
* Defines the facet source configuration entity.
@@ -76,13 +75,6 @@ class FacetSource extends ConfigEntityBase implements FacetSourceInterface {
*/
protected $url_processor = 'query_string';
- /**
- * {@inheritdoc}
- */
- public function id() {
- return $this->id;
- }
-
/**
* {@inheritdoc}
*/
diff --git a/src/FacetInterface.php b/src/FacetInterface.php
index 02cd6b1499cd025ed9dfa4e667d7f532c17023e6..6a92d90c90884925c4fdb671802f9f051f4503f6 100644
--- a/src/FacetInterface.php
+++ b/src/FacetInterface.php
@@ -33,7 +33,7 @@ interface FacetInterface extends ConfigEntityInterface {
public function getWidget();
/**
- * Get field identifier.
+ * Returns field identifier.
*
* @return string
* The field identifier of this facet.
@@ -41,7 +41,7 @@ interface FacetInterface extends ConfigEntityInterface {
public function getFieldIdentifier();
/**
- * Set field identifier.
+ * Sets field identifier.
*
* @param string $field_identifier
* The field identifier of this facet.
@@ -52,7 +52,7 @@ interface FacetInterface extends ConfigEntityInterface {
public function setFieldIdentifier($field_identifier);
/**
- * Get the field alias used to identify the facet in the url.
+ * Returns the field alias used to identify the facet in the url.
*
* @return string
* The field alias for the facet.
@@ -60,7 +60,7 @@ interface FacetInterface extends ConfigEntityInterface {
public function getFieldAlias();
/**
- * Get the field name of the facet as used in the index.
+ * Returns the field name of the facet as used in the index.
*
* @TODO: Check if fieldIdentifier can be used as well!
*
@@ -70,9 +70,10 @@ interface FacetInterface extends ConfigEntityInterface {
public function getName();
/**
- * Gets the name of the facet for use in the URL.
+ * Returns the name of the facet for use in the URL.
*
* @return string
+ * The name of the facet for use in the URL.
*/
public function getUrlAlias();
@@ -80,6 +81,7 @@ interface FacetInterface extends ConfigEntityInterface {
* Sets the name of the facet for use in the URL.
*
* @param string $url_alias
+ * The name of the facet for use in the URL.
*/
public function setUrlAlias($url_alias);
@@ -92,7 +94,7 @@ interface FacetInterface extends ConfigEntityInterface {
public function setActiveItem($value);
/**
- * Get all the active items in the facet.
+ * Returns all the active items in the facet.
*
* @return mixed
* An array containing all active items.
@@ -111,7 +113,7 @@ interface FacetInterface extends ConfigEntityInterface {
public function isActiveValue($value);
/**
- * Get the result for the facet.
+ * Returns the result for the facet.
*
* @return \Drupal\facets\Result\ResultInterface[] $results
* The results of the facet.
@@ -133,20 +135,21 @@ interface FacetInterface extends ConfigEntityInterface {
* facet results when using the OR query operator. They are not results value
* objects like those in ::$results.
*
- * @param array
+ * @param array $all_results
* Unfiltered results.
*/
public function setUnfilteredResults(array $all_results = []);
/**
- * Gets an array of unfiltered results.
+ * Returns an array of unfiltered results.
*
* @return array
+ * Unfiltered results.
*/
public function getUnfilteredResults();
/**
- * Get the query type instance.
+ * Returns the query type instance.
*
* @return string
* The query type plugin being used.
@@ -154,7 +157,7 @@ interface FacetInterface extends ConfigEntityInterface {
public function getQueryType();
/**
- * Get the query operator.
+ * Returns the query operator.
*
* @return string
* The query operator being used.
@@ -162,7 +165,7 @@ interface FacetInterface extends ConfigEntityInterface {
public function getQueryOperator();
/**
- * Get the plugin name for the url processor.
+ * Returns the plugin name for the url processor.
*
* @return string
* The id of the url processor.
@@ -185,7 +188,7 @@ interface FacetInterface extends ConfigEntityInterface {
/**
* Sets the query operator.
*
- * @param string
+ * @param string $operator
* The query operator being used.
*/
public function setQueryOperator($operator);
@@ -215,7 +218,7 @@ interface FacetInterface extends ConfigEntityInterface {
public function getFacetSourceConfig();
/**
- * Load the facet sources for this facet.
+ * Loads the facet sources for this facet.
*
* @param bool|TRUE $only_enabled
* Only return enabled facet sources.
@@ -282,60 +285,67 @@ interface FacetInterface extends ConfigEntityInterface {
public function getOnlyVisibleWhenFacetSourceIsVisible();
/**
- * Enabled a processor for this facet.
+ * Adds a processor for this facet.
*
* @param array $processor
+ * An array definition for a processor.
*/
public function addProcessor(array $processor);
/**
- * Disable a processor for this facet.
+ * Removes a processor for this facet.
*
* @param string $processor_id
+ * The plugin id of the processor.
*/
public function removeProcessor($processor_id);
/**
- * Define the no-results behavior.
+ * Defines the no-results behavior.
*
* @param array $behavior
+ * The definition of the behavior.
*/
- public function setEmptyBehavior($behavior);
+ public function setEmptyBehavior(array $behavior);
/**
- * Return the defined no-results behavior or NULL if none defined.
+ * Returns the defined no-results behavior or NULL if none defined.
*
* @return array|NULL
+ * The behavior definition or NULL.
*/
public function getEmptyBehavior();
/**
- * Return the configuration of the selected widget.
+ * Returns the configuration of the selected widget.
*
* @return array
+ * The configuration settings for the widget.
*/
public function getWidgetConfigs();
/**
- * Set the configuration for the widget of this facet.
+ * Sets the configuration for the widget of this facet.
*
* @param array $widget_config
+ * The configuration settings for the widget.
*/
public function setWidgetConfigs(array $widget_config);
/**
- * Get any additional configuration for this facet, no defined above.
+ * Returns any additional configuration for this facet, not defined above.
*
* @return array
+ * An array of additional configuration for the facet.
*/
public function getFacetConfigs();
/**
- * Define any additional configuration for this facet not defined above.
+ * Defines any additional configuration for this facet not defined above.
*
* @param array $facet_config
+ * An array of additional configuration for the facet.
*/
public function setFacetConfigs(array $facet_config);
-
}
diff --git a/src/FacetListBuilder.php b/src/FacetListBuilder.php
index fb4bd7cb6557055f1842443aae700a7ae5470d5c..abfa1c14d3424f04400d4eb6755ecac1c38f5b89 100644
--- a/src/FacetListBuilder.php
+++ b/src/FacetListBuilder.php
@@ -120,7 +120,7 @@ class FacetListBuilder extends ConfigEntityListBuilder {
}
/**
- * {@inheritdoc}
+ * Builds an array of facet sources for display in the overview.
*/
public function buildFacetSourceRow(array $facet_source = []) {
return array(
diff --git a/src/FacetManager/DefaultFacetManager.php b/src/FacetManager/DefaultFacetManager.php
index 0221c12b549c41a0e593b0228d7052ea28be0d8f..9eaf544d66059e629a7c90b0d69183ee0a0887ff 100644
--- a/src/FacetManager/DefaultFacetManager.php
+++ b/src/FacetManager/DefaultFacetManager.php
@@ -108,15 +108,11 @@ class DefaultFacetManager {
protected $facetSourceId;
/**
- * Set the search id.
+ * The entity storage for facets.
*
- * @param string $facet_source_id
- * The id of the facet source.
+ * @var \Drupal\Core\Entity\EntityStorageInterface|object
*/
- public function setFacetSourceId($facet_source_id) {
- $this->facetSourceId = $facet_source_id;
- }
-
+ protected $facetStorage;
/**
* Constructs a new instance of the DefaultFacetManager.
*
@@ -136,13 +132,23 @@ class DefaultFacetManager {
$this->widgetPluginManager = $widget_plugin_manager;
$this->facetSourcePluginManager = $facet_source_manager;
$this->processorPluginManager = $processor_plugin_manager;
- $this->facet_storage = $entity_type_manager->getStorage('facets_facet');
+ $this->facetStorage = $entity_type_manager->getStorage('facets_facet');
// Immediately initialize the facets. This can be done directly because the
// only thing needed is the url.
$this->initFacets();
}
+ /**
+ * Sets the search id.
+ *
+ * @param string $facet_source_id
+ * The id of the facet source.
+ */
+ public function setFacetSourceId($facet_source_id) {
+ $this->facetSourceId = $facet_source_id;
+ }
+
/**
* Allows the backend to add facet queries to its native query object.
*
@@ -178,11 +184,11 @@ class DefaultFacetManager {
* An array of enabled facets.
*/
public function getEnabledFacets() {
- return $this->facet_storage->loadMultiple();
+ return $this->facetStorage->loadMultiple();
}
/**
- * Get the ID of the facet source.
+ * Returns the ID of the facet source.
*
* @return string
* The id of the facet source.
@@ -209,7 +215,7 @@ class DefaultFacetManager {
}
/**
- * Initialize enabled facets.
+ * Initializes enabled facets.
*
* In this method all pre-query processors get called and their contents are
* executed.
@@ -235,7 +241,7 @@ class DefaultFacetManager {
}
/**
- * Build a facet and returns it's render array.
+ * Builds a facet and returns it as a renderable array.
*
* This method delegates to the relevant plugins to render a facet, it calls
* out to a widget plugin to do the actual rendering when results are found.
@@ -336,6 +342,7 @@ class DefaultFacetManager {
*
* @param string $facet_id
* The id of the facet.
+ *
* @return \Drupal\facets\FacetInterface|NULL
* The updated facet if it exists, NULL otherwise.
*/
diff --git a/src/FacetSource/FacetSourceDeriverBase.php b/src/FacetSource/FacetSourceDeriverBase.php
index 379760690560699279633d13d3c2c8804ba0507a..392c7c42ada03b4b37f54e91dadc47ffa584cb54 100644
--- a/src/FacetSource/FacetSourceDeriverBase.php
+++ b/src/FacetSource/FacetSourceDeriverBase.php
@@ -82,7 +82,6 @@ abstract class FacetSourceDeriverBase implements ContainerDeriverInterface {
return isset($derivatives[$derivative_id]) ? $derivatives[$derivative_id] : NULL;
}
-
/**
* Compares two plugin definitions according to their labels.
*
diff --git a/src/FacetSource/FacetSourcePluginBase.php b/src/FacetSource/FacetSourcePluginBase.php
index 8cf6b8e1392d1feddf088160649eae65072a6c31..27acfd6122967acfd2cc1224c46002b0aaeb0674 100644
--- a/src/FacetSource/FacetSourcePluginBase.php
+++ b/src/FacetSource/FacetSourcePluginBase.php
@@ -7,10 +7,8 @@
namespace Drupal\facets\FacetSource;
-use Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException;
use Drupal\Component\Plugin\PluginBase;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
-use Drupal\facets\Exception\InvalidProcessorException;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Facets\FacetInterface;
use Drupal\Core\Form\FormStateInterface;
diff --git a/src/FacetSource/FacetSourcePluginInterface.php b/src/FacetSource/FacetSourcePluginInterface.php
index 91a519f01a677d8633073e62631b9ab720ecd132..4dff1295a7cc3a572345b82f7a4444edff34e508 100644
--- a/src/FacetSource/FacetSourcePluginInterface.php
+++ b/src/FacetSource/FacetSourcePluginInterface.php
@@ -22,7 +22,7 @@ use Drupal\facets\FacetInterface;
interface FacetSourcePluginInterface extends PluginFormInterface {
/**
- * Fill in facet data in to the configured facets.
+ * Fills the facet entities with results from the facet source.
*
* @param \Drupal\facets\FacetInterface[] $facets
* The configured facets.
@@ -30,7 +30,7 @@ interface FacetSourcePluginInterface extends PluginFormInterface {
public function fillFacetsWithResults($facets);
/**
- * Get the allowed query types for a given facet for the facet source.
+ * Returns the allowed query types for a given facet for the facet source.
*
* @param \Drupal\facets\FacetInterface $facet
* The facet we should get query types for.
@@ -86,7 +86,7 @@ interface FacetSourcePluginInterface extends PluginFormInterface {
public function setSearchKeys($keys);
/**
- * Gets the search keys, or query text, submitted by the user.
+ * Returns the search keys, or query text, submitted by the user.
*
* @return string
* The search keys, or query text, submitted by the user.
diff --git a/src/FacetSource/FacetSourcePluginManager.php b/src/FacetSource/FacetSourcePluginManager.php
index 1b628746ac32798cdcb67be3b1293dcb77cda77e..8c0c0a5bfaa5f3b7fdae95855b20c043e17b9436 100644
--- a/src/FacetSource/FacetSourcePluginManager.php
+++ b/src/FacetSource/FacetSourcePluginManager.php
@@ -21,15 +21,7 @@ use Drupal\Core\Plugin\DefaultPluginManager;
class FacetSourcePluginManager extends DefaultPluginManager {
/**
- * Constructs a FacetSourcePluginManager object.
- *
- * @param \Traversable $namespaces
- * An object that implements \Traversable which contains the root paths
- * keyed by the corresponding namespace to look for plugin implementations.
- * @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend
- * Cache backend instance to use.
- * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
- * The module handler.
+ * {@inheritdoc}
*/
public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler) {
parent::__construct('Plugin/facets/facet_source', $namespaces, $module_handler, 'Drupal\facets\FacetSource\FacetSourcePluginInterface', 'Drupal\facets\Annotation\FacetsFacetSource');
diff --git a/src/FacetSourceInterface.php b/src/FacetSourceInterface.php
index 8c6e909b607facdefe12470896fdaee3d16b84b6..fd465728ecd065ffd8f79093744977a3d98ec3f9 100644
--- a/src/FacetSourceInterface.php
+++ b/src/FacetSourceInterface.php
@@ -23,7 +23,7 @@ interface FacetSourceInterface extends ConfigEntityInterface {
public function getName();
/**
- * Gets the filter key for this facet source.
+ * Returns the filter key for this facet source.
*
* @return string
* The filter key.
@@ -39,7 +39,7 @@ interface FacetSourceInterface extends ConfigEntityInterface {
public function setFilterKey($filter_key);
/**
- * Set the processor name to be used.
+ * Sets the processor name to be used.
*
* @param string $processor_name
* Plugin name of the url processor.
diff --git a/src/Form/FacetDisplayForm.php b/src/Form/FacetDisplayForm.php
index 170feca59263ab34576e76e527b184cf93e51a47..5f93de46b9dff9b70bff8eca0d3d5cb8f69843e9 100644
--- a/src/Form/FacetDisplayForm.php
+++ b/src/Form/FacetDisplayForm.php
@@ -326,7 +326,6 @@ class FacetDisplayForm extends EntityForm {
'#default_value' => $facet->getOnlyVisibleWhenFacetSourceIsVisible(),
];
- // Behavior for empty facets.
$empty_behavior_config = $facet->getEmptyBehavior();
$form['facet_settings']['empty_behavior'] = [
'#type' => 'radios',
@@ -352,7 +351,6 @@ class FacetDisplayForm extends EntityForm {
'#default_value' => isset($empty_behavior_config['text_format']) ? $empty_behavior_config['text'] : '',
];
- // Query operator.
$form['facet_settings']['query_operator'] = [
'#type' => 'radios',
'#title' => $this->t('Operator'),
@@ -544,7 +542,7 @@ class FacetDisplayForm extends EntityForm {
}
/**
- * Form submission handler for the widget subform.
+ * Handles form submissions for the widget subform.
*/
public function submitAjaxWidgetConfigForm($form, FormStateInterface $form_state) {
$form_state->setRebuild();
diff --git a/src/Form/FacetForm.php b/src/Form/FacetForm.php
index d19739c53fd0b63a95dda08ecd0a10c611c77e1c..6ddc99693261fdebe1c384c7b340ee5c8a45e61b 100644
--- a/src/Form/FacetForm.php
+++ b/src/Form/FacetForm.php
@@ -22,7 +22,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
class FacetForm extends EntityForm {
/**
- * The facet storage controller.
+ * The facet storage.
*
* @var \Drupal\Core\Entity\EntityStorageInterface
*/
@@ -74,22 +74,6 @@ class FacetForm extends EntityForm {
return new static($entity_type_manager, $facet_source_plugin_manager, $processor_plugin_manager);
}
- /**
- * Gets the form entity.
- *
- * The form entity which has been used for populating form element defaults.
- * This method is defined on the \Drupal\Core\Entity\EntityFormInterface and
- * has the same contents there, we only extend to add the correct return type,
- * this makes IDE's smarter about the other places where we use
- * $this->getEntity().
- *
- * @return \Drupal\facets\FacetInterface
- * The current form facet entity.
- */
- public function getEntity() {
- return $this->entity;
- }
-
/**
* Retrieves the facet storage controller.
*
@@ -234,7 +218,7 @@ class FacetForm extends EntityForm {
}
/**
- * Form submission handler for the facet source subform.
+ * Handles form submissions for the facet source subform.
*/
public function submitAjaxFacetSourceConfigForm($form, FormStateInterface $form_state) {
$form_state->setRebuild();
@@ -270,13 +254,6 @@ class FacetForm extends EntityForm {
}
}
- /**
- * {@inheritdoc}
- */
- public function validateForm(array &$form, FormStateInterface $form_state) {
- parent::validateForm($form, $form_state);
- }
-
/**
* {@inheritdoc}
*/
diff --git a/src/Form/FacetSourceEditForm.php b/src/Form/FacetSourceEditForm.php
index 45b14cc0900fe2f28ddcba27bd56c913433832b7..b2a0933426dcbd5c5f675bcb422c9ee604cbec6e 100644
--- a/src/Form/FacetSourceEditForm.php
+++ b/src/Form/FacetSourceEditForm.php
@@ -44,6 +44,11 @@ class FacetSourceEditForm extends EntityForm {
/**
* Constructs a FacetSourceEditForm.
+ *
+ * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
+ * The entity type manager.
+ * @param \Drupal\facets\UrlProcessor\UrlProcessorPluginManager $url_processor_plugin_manager
+ * The url processor plugin manager.
*/
public function __construct(EntityTypeManagerInterface $entity_type_manager, UrlProcessorPluginManager $url_processor_plugin_manager) {
$facet_source_storage = $entity_type_manager->getStorage('facets_facet_source');
@@ -61,7 +66,6 @@ class FacetSourceEditForm extends EntityForm {
$this->setEntity($facet_source);
}
else {
-
// We didn't have a facet source config entity yet for this facet source
// plugin, so we create it on the fly.
$facet_source = new FacetSource(
@@ -93,7 +97,6 @@ class FacetSourceEditForm extends EntityForm {
/** @var \Drupal\facets\FacetSourceInterface $facet_source */
$facet_source = $this->getEntity();
- // Filter key setting.
$form['filter_key'] = [
'#type' => 'textfield',
'#title' => $this->t('Filter key'),
@@ -118,7 +121,7 @@ class FacetSourceEditForm extends EntityForm {
'#options' => $url_processors,
'#default_value' => $facet_source->getUrlProcessorName(),
'#description' => $this->t(
- 'The URL Processor defines the url structure used for this facet source.') . '
- ' . implode('
- ', $url_processors_description),
+ 'The URL Processor defines the url structure used for this facet source.') . '
- ' . implode('
- ', $url_processors_description),
];
// The parent's form build method will add a save button.
diff --git a/src/Plugin/Block/FacetBlock.php b/src/Plugin/Block/FacetBlock.php
index 9830129c36a759017c298108a24eb80ceb4f809f..fc1415097e6bb02edba8ad03cca1d278f85c1349 100644
--- a/src/Plugin/Block/FacetBlock.php
+++ b/src/Plugin/Block/FacetBlock.php
@@ -49,7 +49,7 @@ class FacetBlock extends BlockBase implements ContainerFactoryPluginInterface {
* The plugin implementation definition.
* @param \Drupal\facets\FacetManager\DefaultFacetManager $facet_manager
* The facet manager.
- * @param \Drupal\Core\Entity\EntityStorageInterface
+ * @param \Drupal\Core\Entity\EntityStorageInterface $facet_storage
* The entity storage used for facets.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, DefaultFacetManager $facet_manager, EntityStorageInterface $facet_storage) {
@@ -128,9 +128,9 @@ class FacetBlock extends BlockBase implements ContainerFactoryPluginInterface {
// impossible to improve this significantly.
//
// Note: when using Drupal core's Search module instead of the contributed
- // Search API module, the above limitations do not apply, but for now
- // it is not considered worth the effort to optimize this just for
- // Drupal core's Search.
+ // Search API module, the above limitations do not apply, but for now it is
+ // not considered worth the effort to optimize this just for Drupal core's
+ // Search.
return 0;
}
diff --git a/src/Plugin/Block/FacetBlockDeriver.php b/src/Plugin/Block/FacetBlockDeriver.php
index 6dffef226179a928269429c02536aa4f329bd353..93050239f7f66d46b2b5434fa2e82fffdf2d7f61 100644
--- a/src/Plugin/Block/FacetBlockDeriver.php
+++ b/src/Plugin/Block/FacetBlockDeriver.php
@@ -37,8 +37,8 @@ class FacetBlockDeriver implements ContainerDeriverInterface {
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, $base_plugin_id) {
- $deriver = new static;
- $deriver->facetStorage = \Drupal::getContainer()->get('entity_type.manager')->getStorage('facets_facet');
+ $deriver = new static($container, $base_plugin_id);
+ $deriver->facetStorage = $container->get('entity_type.manager')->getStorage('facets_facet');
return $deriver;
}
diff --git a/src/Plugin/Condition/OtherFacet.php b/src/Plugin/Condition/OtherFacet.php
index b7064669c71bfef3a81da246035aa4ed7b3e1003..893e7c14eef154fa6d9854c8bdbcc9aabf3ecd4a 100644
--- a/src/Plugin/Condition/OtherFacet.php
+++ b/src/Plugin/Condition/OtherFacet.php
@@ -80,7 +80,7 @@ class OtherFacet extends ConditionPluginBase implements ContainerFactoryPluginIn
* @param mixed $plugin_definition
* The plugin implementation definition.
*/
- public function __construct(EntityStorageInterface $entity_storage, BlockManager $block_manager, AccountProxyInterface $current_user, DefaultFacetManager $facet_manager,array $configuration, $plugin_id, $plugin_definition) {
+ public function __construct(EntityStorageInterface $entity_storage, BlockManager $block_manager, AccountProxyInterface $current_user, DefaultFacetManager $facet_manager, array $configuration, $plugin_id, $plugin_definition) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->facetStorage = $entity_storage;
$this->blockManager = $block_manager;
diff --git a/src/Plugin/facets/facet_source/SearchApiBaseFacetSource.php b/src/Plugin/facets/facet_source/SearchApiBaseFacetSource.php
index 882600f191a4941f3f867d86a71aef6f2613bb4c..1bef6c5fdecabf80bfda7a9d22d5299859efc6ea 100644
--- a/src/Plugin/facets/facet_source/SearchApiBaseFacetSource.php
+++ b/src/Plugin/facets/facet_source/SearchApiBaseFacetSource.php
@@ -83,7 +83,7 @@ abstract class SearchApiBaseFacetSource extends FacetSourcePluginBase {
*/
public function getFields() {
$indexed_fields = [];
- $fields = $this->index->getFields(TRUE);
+ $fields = $this->index->getFields();
foreach ($fields as $field) {
$indexed_fields[$field->getFieldIdentifier()] = $field->getLabel();
}
@@ -102,12 +102,13 @@ abstract class SearchApiBaseFacetSource extends FacetSourcePluginBase {
// Get the Search API Backend.
$backend = $server->getBackend();
- $fields = $this->index->getFields(TRUE);
+ $fields = $this->index->getFields();
foreach ($fields as $field) {
if ($field->getFieldIdentifier() == $field_id) {
return $this->getQueryTypesForDataType($backend, $field->getType());
}
}
+
throw new InvalidQueryTypeException($this->t("No available query types were found for facet @facet", ['@facet' => $facet->getName()]));
}
diff --git a/src/Plugin/facets/processor/UrlProcessorHandler.php b/src/Plugin/facets/processor/UrlProcessorHandler.php
index 5a78e009ce0ee4910468970b72ea705dff0b317c..8779a8f515c09131440b7e52cd6d2318c98cc9d2 100644
--- a/src/Plugin/facets/processor/UrlProcessorHandler.php
+++ b/src/Plugin/facets/processor/UrlProcessorHandler.php
@@ -17,7 +17,8 @@ use Drupal\facets\Processor\ProcessorPluginBase;
* The URL processor handler triggers the actual url processor.
*
* The URL processor handler allows managing the weight of the actual URL
- * processor per Facet. This handler will trigger the actual
+ * processor per Facet. This handler will trigger the actual.
+ *
* @FacetsUrlProcessor, which can be configured on the Facet source.
*
* @FacetsProcessor(
@@ -31,9 +32,13 @@ use Drupal\facets\Processor\ProcessorPluginBase;
* locked = true
* )
*/
-class UrlProcessorHandler extends ProcessorPluginBase implements BuildProcessorInterface, PreQueryProcessorInterface{
+class UrlProcessorHandler extends ProcessorPluginBase implements BuildProcessorInterface, PreQueryProcessorInterface {
- /** @var \Drupal\facets\UrlProcessor\UrlProcessorInterface */
+ /**
+ * The actual url processor used for handing urls.
+ *
+ * @var \Drupal\facets\UrlProcessor\UrlProcessorInterface
+ */
protected $processor;
/**
@@ -55,7 +60,7 @@ class UrlProcessorHandler extends ProcessorPluginBase implements BuildProcessorI
$url_processor_name = $fs->getUrlProcessorName();
$manager = \Drupal::getContainer()->get('plugin.manager.facets.url_processor');
- $this->processor= $manager->createInstance($url_processor_name, ['facet' => $facet]);
+ $this->processor = $manager->createInstance($url_processor_name, ['facet' => $facet]);
}
/**
diff --git a/src/Plugin/facets/query_type/SearchApiString.php b/src/Plugin/facets/query_type/SearchApiString.php
index eb2a4848f41e531a70d268590a045f6a07b0e4b3..c2a45a200a5b5d94e06d171fc32aefe233a526b1 100644
--- a/src/Plugin/facets/query_type/SearchApiString.php
+++ b/src/Plugin/facets/query_type/SearchApiString.php
@@ -29,7 +29,7 @@ use Drupal\facets\Result\Result;
class SearchApiString extends QueryTypePluginBase {
/**
- * Holds the backend's native query object.
+ * The backend's native query object.
*
* @var \Drupal\search_api\Query\QueryInterface
*/
@@ -65,7 +65,6 @@ class SearchApiString extends QueryTypePluginBase {
->execute()
->getExtraData('search_api_facets');
-
// Set the options for the actual query.
$options = &$query->getOptions();
$options['search_api_facets'][$field_identifier] = array(
diff --git a/src/Plugin/facets/url_processor/QueryString.php b/src/Plugin/facets/url_processor/QueryString.php
index 9be51c022ad30ec13d33b4066536f532c05eb8d0..ce36f542c8856c403c8b9cbd9ea0268c05586a49 100644
--- a/src/Plugin/facets/url_processor/QueryString.php
+++ b/src/Plugin/facets/url_processor/QueryString.php
@@ -33,7 +33,7 @@ class QueryString extends UrlProcessorPluginBase {
*
* @var string
*/
- protected $url_alias;
+ protected $urlAlias;
/**
* An array of active filters.
@@ -55,21 +55,20 @@ class QueryString extends UrlProcessorPluginBase {
* {@inheritdoc}
*/
public function buildUrls(FacetInterface $facet, array $results) {
- // Create links for all the values.
- // First get the current list of get parameters.
- $get_params = $this->request->query;
-
- // Set the url alias from the the facet object.
- $this->url_alias = $facet->getUrlAlias();
-
// No results are found for this facet, so don't try to create urls.
if (empty($results)) {
return [];
}
+ // First get the current list of get parameters.
+ $get_params = $this->request->query;
+
+ // Set the url alias from the the facet object.
+ $this->urlAlias = $facet->getUrlAlias();
+
/** @var \Drupal\facets\Result\ResultInterface $result */
foreach ($results as &$result) {
- $filter_string = $this->url_alias . self::SEPARATOR . $result->getRawValue();
+ $filter_string = $this->urlAlias . self::SEPARATOR . $result->getRawValue();
$result_get_params = clone $get_params;
$filter_params = $result_get_params->get($this->filterKey, [], TRUE);
@@ -105,18 +104,18 @@ class QueryString extends UrlProcessorPluginBase {
*/
public function setActiveItems(FacetInterface $facet) {
// Set the url alias from the the facet object.
- $this->url_alias = $facet->getUrlAlias();
+ $this->urlAlias = $facet->getUrlAlias();
// Get the filter key of the facet.
- if (isset($this->activeFilters[$this->url_alias])) {
- foreach ($this->activeFilters[$this->url_alias] as $value) {
+ if (isset($this->activeFilters[$this->urlAlias])) {
+ foreach ($this->activeFilters[$this->urlAlias] as $value) {
$facet->setActiveItem(trim($value, '"'));
}
}
}
/**
- * Initialize the active filters.
+ * Initializes the active filters.
*
* Get all the filters that are active. This method only get's all the
* filters but doesn't assign them to facets. In the processFacet method the
diff --git a/src/Plugin/facets/widget/CheckboxWidget.php b/src/Plugin/facets/widget/CheckboxWidget.php
index a202ccd1e6393d7ace249ec7faf2d147cafa6a45..3f66a75be230b564fba3ee5c8e279456d9c1a51b 100644
--- a/src/Plugin/facets/widget/CheckboxWidget.php
+++ b/src/Plugin/facets/widget/CheckboxWidget.php
@@ -175,4 +175,5 @@ class CheckboxWidget implements WidgetInterface, FormInterface {
$link->setAbsolute();
$form_state->setResponse(new RedirectResponse($link->toString()));
}
+
}
diff --git a/src/Plugin/facets/widget/LinksWidget.php b/src/Plugin/facets/widget/LinksWidget.php
index 67bc5fb07b407e754bb8fa8c66f41cff3458ded2..0ee9a104d9f63ef5f8c3344bb52a0ba9820726f7 100644
--- a/src/Plugin/facets/widget/LinksWidget.php
+++ b/src/Plugin/facets/widget/LinksWidget.php
@@ -68,9 +68,9 @@ class LinksWidget implements WidgetInterface {
'#cache' => [
'contexts' => [
'url.path',
- 'url.query_args'
- ]
- ]
+ 'url.query_args',
+ ],
+ ],
];
return $build;
}
diff --git a/src/Processor/BuildProcessorInterface.php b/src/Processor/BuildProcessorInterface.php
index d494f2776437c3f6b2ec79d97a0f30e09c58ffe0..76c77bd8bc618b78f4a6457ec6fe6aaf6b8ecc7f 100644
--- a/src/Processor/BuildProcessorInterface.php
+++ b/src/Processor/BuildProcessorInterface.php
@@ -16,7 +16,7 @@ use Drupal\facets\FacetInterface;
interface BuildProcessorInterface extends ProcessorInterface {
/**
- * Processor runs before the renderable array is created.
+ * Runs before the renderable array is created.
*
* @param \Drupal\facets\FacetInterface $facet
* The facet being changed.
diff --git a/src/Processor/PostQueryProcessorInterface.php b/src/Processor/PostQueryProcessorInterface.php
index 3a932064104d1d2eb935637bd6857c959bae6d09..a8aea56db19313b533cb46490ff354ebbaecb5c7 100644
--- a/src/Processor/PostQueryProcessorInterface.php
+++ b/src/Processor/PostQueryProcessorInterface.php
@@ -14,7 +14,7 @@ namespace Drupal\facets\Processor;
interface PostQueryProcessorInterface extends ProcessorInterface {
/**
- * Processor runs after the query was executed.
+ * Runs after the query was executed.
*
* Uses the query results and can alter those results, for example a
* ValueCallbackProcessor.
diff --git a/src/Processor/PreQueryProcessorInterface.php b/src/Processor/PreQueryProcessorInterface.php
index 72c854de7307e2b53322d0cdf44a2d2b716a703e..1c1f7934e50bd69770cce7c3df4c22b78f363daf 100644
--- a/src/Processor/PreQueryProcessorInterface.php
+++ b/src/Processor/PreQueryProcessorInterface.php
@@ -15,7 +15,7 @@ use Drupal\facets\FacetInterface;
interface PreQueryProcessorInterface extends ProcessorInterface {
/**
- * Processor runs before the query is executed.
+ * Runs before the query is executed.
*
* Uses the queryType and the facetSource implementation to make sure the
* alteration to the query was added before the query is executed in the
diff --git a/src/Processor/ProcessorPluginBase.php b/src/Processor/ProcessorPluginBase.php
index c5221b0f11aa6405384f5062061a5d7e3156cc4a..48fc2d8b806acf7b44eac821aaa38b72f5014afe 100644
--- a/src/Processor/ProcessorPluginBase.php
+++ b/src/Processor/ProcessorPluginBase.php
@@ -28,8 +28,7 @@ class ProcessorPluginBase extends PluginBase implements ProcessorInterface {
/**
* {@inheritdoc}
*/
- public function validateConfigurationForm(array $form, FormStateInterface $form_state, FacetInterface $facet) {
- }
+ public function validateConfigurationForm(array $form, FormStateInterface $form_state, FacetInterface $facet) {}
/**
* {@inheritdoc}
diff --git a/src/Processor/WidgetOrderPluginBase.php b/src/Processor/WidgetOrderPluginBase.php
index 3014f6497fbb3afd3513ff4f0ab08eca7c52bd2d..3aac26af4795e175d246efc497b4c4f8b49eae1e 100644
--- a/src/Processor/WidgetOrderPluginBase.php
+++ b/src/Processor/WidgetOrderPluginBase.php
@@ -11,7 +11,7 @@ use Drupal\Core\Form\FormStateInterface;
use Drupal\facets\FacetInterface;
/**
- * A base class for plugins that implements most of the boilerplate.
+ * A base class for plugins that implements some boilerplate for a widget order.
*/
abstract class WidgetOrderPluginBase extends ProcessorPluginBase implements WidgetOrderProcessorInterface {
diff --git a/src/Processor/WidgetOrderProcessorInterface.php b/src/Processor/WidgetOrderProcessorInterface.php
index e07c84d98b15e3fd82a84b2ea91470c98d223fdb..fadab5478eee6d58ca2d9a7d830d541398042e53 100644
--- a/src/Processor/WidgetOrderProcessorInterface.php
+++ b/src/Processor/WidgetOrderProcessorInterface.php
@@ -13,7 +13,7 @@ namespace Drupal\facets\Processor;
interface WidgetOrderProcessorInterface extends BuildProcessorInterface {
/**
- * Order results and return the new order of results.
+ * Orders results and return the new order of results.
*
* @param \Drupal\facets\Result\Result[] $results
* An array containing results.
diff --git a/src/QueryType/QueryTypeInterface.php b/src/QueryType/QueryTypeInterface.php
index d43e3ac4fb757d159c41551eec096ae8bef57405..ab735dbf96e0295610283b5eb3a9c27c17769735 100644
--- a/src/QueryType/QueryTypeInterface.php
+++ b/src/QueryType/QueryTypeInterface.php
@@ -12,7 +12,7 @@ namespace Drupal\facets\QueryType;
interface QueryTypeInterface {
/**
- * Add facet info to the query using the backend native query object.
+ * Adds facet info to the query using the backend native query object.
*
* @return array
* Returns an array of unfiltered results
@@ -20,7 +20,7 @@ interface QueryTypeInterface {
public function execute();
/**
- * Build the facet information, so it can be rendered.
+ * Builds the facet information, so it can be rendered.
*/
public function build();
diff --git a/src/QueryType/QueryTypePluginBase.php b/src/QueryType/QueryTypePluginBase.php
index 497a7f27eebd12fbd900ebd5ab39e9f467e77f02..01f0b3357cf0290c1906c24b01bd3b68c9856733 100644
--- a/src/QueryType/QueryTypePluginBase.php
+++ b/src/QueryType/QueryTypePluginBase.php
@@ -28,7 +28,7 @@ abstract class QueryTypePluginBase extends PluginBase implements QueryTypeInterf
}
/**
- * Holds the backend native query object.
+ * The backend native query object.
*
* @var \Drupal\search_api\Query\Query $query
*/
@@ -42,7 +42,7 @@ abstract class QueryTypePluginBase extends PluginBase implements QueryTypeInterf
protected $facet;
/**
- * Holds the results for the facet.
+ * The results for the facet.
*
* @var \Drupal\facets\Result\ResultInterface[]
*/
diff --git a/src/Result/Result.php b/src/Result/Result.php
index f430981f440df6e2b1a2311907b5cd33b20d0553..b748f64d8e8509ef0efed09d975de4d0300f1c1d 100644
--- a/src/Result/Result.php
+++ b/src/Result/Result.php
@@ -45,7 +45,7 @@ class Result implements ResultInterface {
protected $active = FALSE;
/**
- * Construct a new instance of the value object.
+ * Constructs a new result value object.
*
* @param mixed $raw_value
* The raw value.
diff --git a/src/Result/ResultInterface.php b/src/Result/ResultInterface.php
index 658960858e7526984992403b9b9dd5d2da5edec3..bed1d8749fca705a04b2c4c26117c4d45a365ade 100644
--- a/src/Result/ResultInterface.php
+++ b/src/Result/ResultInterface.php
@@ -15,7 +15,7 @@ use Drupal\Core\Url;
interface ResultInterface {
/**
- * Get the raw value as present in the index.
+ * Returns the raw value as present in the index.
*
* @return string
* The raw value of the result.
@@ -23,7 +23,7 @@ interface ResultInterface {
public function getRawValue();
/**
- * Get the display value as present in the index.
+ * Returns the display value as present in the index.
*
* @return string
* The formatted value of the result.
@@ -31,7 +31,7 @@ interface ResultInterface {
public function getDisplayValue();
/**
- * Get the count for the result.
+ * Returns the count for the result.
*
* @return mixed
* The amount of items for the result.
@@ -39,7 +39,7 @@ interface ResultInterface {
public function getCount();
/**
- * Get the url.
+ * Returns the url.
*
* @return \Drupal\Core\Url
* The url of the search page with the facet url appended.
@@ -47,7 +47,7 @@ interface ResultInterface {
public function getUrl();
/**
- * Set the url.
+ * Sets the url.
*
* @param \Drupal\Core\Url $url
* The url of the search page with the facet url appended.
@@ -55,7 +55,7 @@ interface ResultInterface {
public function setUrl(Url $url);
/**
- * Indicate that the value is active (selected).
+ * Indicates that the value is active (selected).
*
* @param bool $active
* A boolean indicating the active state.
@@ -71,7 +71,7 @@ interface ResultInterface {
public function isActive();
/**
- * Override the display value of a result.
+ * Overrides the display value of a result.
*
* @param string $display_value
* Override display value.
diff --git a/src/Tests/ExampleContentTrait.php b/src/Tests/ExampleContentTrait.php
index 0b34cd3e72aa0e1e50c7045d046528bc0dffa381..5bb93f4b0940c44e68229ed16a1a6202775c2890 100644
--- a/src/Tests/ExampleContentTrait.php
+++ b/src/Tests/ExampleContentTrait.php
@@ -8,7 +8,6 @@
namespace Drupal\facets\Tests;
use Drupal\search_api\Entity\Index;
-use Drupal\search_api\Utility;
/**
* Contains helpers to create data that can be used by tests.
@@ -39,42 +38,42 @@ trait ExampleContentTrait {
$entity_test_storage = \Drupal::entityTypeManager()
->getStorage('entity_test');
$this->entities[1] = $entity_test_storage->create(array(
- 'name' => 'foo bar baz',
- 'body' => 'test test',
- 'type' => 'item',
- 'keywords' => array('orange'),
- 'category' => 'item_category'
- ));
+ 'name' => 'foo bar baz',
+ 'body' => 'test test',
+ 'type' => 'item',
+ 'keywords' => array('orange'),
+ 'category' => 'item_category',
+ ));
$this->entities[1]->save();
$this->entities[2] = $entity_test_storage->create(array(
- 'name' => 'foo test',
- 'body' => 'bar test',
- 'type' => 'item',
- 'keywords' => array('orange', 'apple', 'grape'),
- 'category' => 'item_category'
- ));
+ 'name' => 'foo test',
+ 'body' => 'bar test',
+ 'type' => 'item',
+ 'keywords' => array('orange', 'apple', 'grape'),
+ 'category' => 'item_category',
+ ));
$this->entities[2]->save();
$this->entities[3] = $entity_test_storage->create(array(
- 'name' => 'bar',
- 'body' => 'test foobar',
- 'type' => 'item',
- ));
+ 'name' => 'bar',
+ 'body' => 'test foobar',
+ 'type' => 'item',
+ ));
$this->entities[3]->save();
$this->entities[4] = $entity_test_storage->create(array(
- 'name' => 'foo baz',
- 'body' => 'test test test',
- 'type' => 'article',
- 'keywords' => array('apple', 'strawberry', 'grape'),
- 'category' => 'article_category'
- ));
+ 'name' => 'foo baz',
+ 'body' => 'test test test',
+ 'type' => 'article',
+ 'keywords' => array('apple', 'strawberry', 'grape'),
+ 'category' => 'article_category',
+ ));
$this->entities[4]->save();
$this->entities[5] = $entity_test_storage->create(array(
- 'name' => 'bar baz',
- 'body' => 'foo',
- 'type' => 'article',
- 'keywords' => array('orange', 'strawberry', 'grape', 'banana'),
- 'category' => 'article_category'
- ));
+ 'name' => 'bar baz',
+ 'body' => 'foo',
+ 'type' => 'article',
+ 'keywords' => array('orange', 'strawberry', 'grape', 'banana'),
+ 'category' => 'article_category',
+ ));
$this->entities[5]->save();
$count = \Drupal::entityQuery('entity_test')->count()->execute() - $count;
$this->assertEqual($count, 5, "$count items inserted.");
@@ -95,33 +94,4 @@ trait ExampleContentTrait {
return $index->indexItems();
}
- /**
- * Returns the internal field ID for the given entity field name.
- *
- * @param string $field_name
- * The field name.
- *
- * @return string
- * The internal field ID.
- */
- protected function getFieldId($field_name) {
- return Utility::createCombinedId('entity:entity_test', $field_name);
- }
-
- /**
- * Returns the item IDs for the given entity IDs.
- *
- * @param array $entity_ids
- * An array of entity IDs.
- *
- * @return string[]
- * An array of item IDs.
- */
- protected function getItemIds(array $entity_ids) {
- $translate_ids = function ($entity_id) {
- return Utility::createCombinedId('entity:entity_test', $entity_id . ':en');
- };
- return array_map($translate_ids, $entity_ids);
- }
-
}
diff --git a/src/Tests/FacetSourceTest.php b/src/Tests/FacetSourceTest.php
index 9bd8f9cfe5d8a9c50b16a24a6838581e16e8cfb3..bb39811f358a3e0d04b4e1bb0107399a6a736e63 100644
--- a/src/Tests/FacetSourceTest.php
+++ b/src/Tests/FacetSourceTest.php
@@ -29,7 +29,7 @@ class FacetSourceTest extends FacetWebTestBase {
];
/**
- * Test the facet source editing.
+ * Tests the facet source editing.
*/
public function testEditFilterKey() {
// Make sure we're logged in with a user that has sufficient permissions.
@@ -49,7 +49,7 @@ class FacetSourceTest extends FacetWebTestBase {
$this->drupalPostForm(NULL, $edit, $this->t('Save'));
$this->assertResponse(200);
- // Test that saving worked filter_key has the new value
+ // Test that saving worked filter_key has the new value.
$this->assertField('filter_key');
$this->assertField('url_processor');
$this->assertRaw('fq');
diff --git a/src/Tests/IntegrationTest.php b/src/Tests/IntegrationTest.php
index d6ea22dfe2d9339f7e5920dc04569921c7abbc15..20f93b12fd25b3d6674536f5f42e1aefdc431a98 100644
--- a/src/Tests/IntegrationTest.php
+++ b/src/Tests/IntegrationTest.php
@@ -454,7 +454,7 @@ class IntegrationTest extends FacetWebTestBase {
}
/**
- * Helper function: asserts that a facet block does not appear.
+ * Asserts that a facet block does not appear.
*/
protected function assertNoFacetBlocksAppear() {
foreach ($this->blocks as $block) {
@@ -463,7 +463,7 @@ class IntegrationTest extends FacetWebTestBase {
}
/**
- * Helper function: asserts that a facet block appears.
+ * Asserts that a facet block appears.
*/
protected function assertFacetBlocksAppear() {
foreach ($this->blocks as $block) {
@@ -534,7 +534,7 @@ class IntegrationTest extends FacetWebTestBase {
}
/**
- * Get the facet overview page and make sure the overview is empty.
+ * Tests that the facet overview is empty.
*/
protected function checkEmptyOverview() {
$facet_overview = '/admin/config/search/facets';
@@ -608,7 +608,7 @@ class IntegrationTest extends FacetWebTestBase {
* @param string $facet_name
* The name of the facet.
*/
- public function editFacet($facet_name) {
+ protected function editFacet($facet_name) {
$facet_id = $this->convertNameToMachineName($facet_name);
$facet_edit_page = '/admin/config/search/facets/' . $facet_id . '/edit';
@@ -640,7 +640,7 @@ class IntegrationTest extends FacetWebTestBase {
}
/**
- * This deletes an unused facet through the UI.
+ * Deletes a facet through the UI that still has usages.
*
* @param string $facet_name
* The name of the facet.
@@ -661,7 +661,7 @@ class IntegrationTest extends FacetWebTestBase {
}
/**
- * This deletes a facet through the UI.
+ * Deletes a facet through the UI.
*
* @param string $facet_name
* The name of the facet.
diff --git a/src/Tests/UrlIntegrationTest.php b/src/Tests/UrlIntegrationTest.php
index e5ebf985352089f15b2accb54f02990f48ad4e77..63f8da312ffa61a71f7437060d6de1e5e663704d 100644
--- a/src/Tests/UrlIntegrationTest.php
+++ b/src/Tests/UrlIntegrationTest.php
@@ -73,7 +73,7 @@ class UrlIntegrationTest extends FacetWebTestBase {
'settings' => [
'region' => 'footer',
'id' => str_replace('_', '-', $id),
- ]
+ ],
];
$this->drupalPlaceBlock($block_values['plugin_id'], $block_values['settings']);
diff --git a/src/Tests/WidgetIntegrationTest.php b/src/Tests/WidgetIntegrationTest.php
index 142f6d1ad910b8dedc2caf9afefa546b876b586f..34c728e269e2ce15f2530f9956a27fdab16953a0 100644
--- a/src/Tests/WidgetIntegrationTest.php
+++ b/src/Tests/WidgetIntegrationTest.php
@@ -70,7 +70,7 @@ class WidgetIntegrationTest extends FacetWebTestBase {
'settings' => [
'region' => 'footer',
'id' => str_replace('_', '-', $id),
- ]
+ ],
];
$this->drupalPlaceBlock($block_values['plugin_id'], $block_values['settings']);
@@ -80,7 +80,7 @@ class WidgetIntegrationTest extends FacetWebTestBase {
}
/**
- * Test links widget's basic functionality.
+ * Tests links widget's basic functionality.
*/
public function testLinksWidget() {
$id = 'links_widget';
@@ -106,7 +106,7 @@ class WidgetIntegrationTest extends FacetWebTestBase {
'settings' => [
'region' => 'footer',
'id' => str_replace('_', '-', $id),
- ]
+ ],
];
$this->drupalPlaceBlock($block_values['plugin_id'], $block_values['settings']);
@@ -146,7 +146,7 @@ class WidgetIntegrationTest extends FacetWebTestBase {
'settings' => [
'region' => 'footer',
'id' => str_replace('_', '-', $id),
- ]
+ ],
];
$this->drupalPlaceBlock($block_values['plugin_id'], $block_values['settings']);
@@ -159,7 +159,7 @@ class WidgetIntegrationTest extends FacetWebTestBase {
$this->drupalGet($facet_edit_page);
$this->drupalPostForm(NULL, ['widget' => 'links', 'widget_configs[show_numbers]' => TRUE], $this->t('Save'));
- // Go back to the same view and check that links now display the count
+ // Go back to the same view and check that links now display the count.
$this->drupalGet('search-api-test-fulltext');
$this->assertLink('item (3)');
$this->assertLink('article (2)');
diff --git a/src/UrlProcessor/UrlProcessorInterface.php b/src/UrlProcessor/UrlProcessorInterface.php
index 3bc51a193ce9a442a3a5cac61c875aaa9f5757ef..5b56c49fbbd6028fa331015e6b049ecf32eda091 100644
--- a/src/UrlProcessor/UrlProcessorInterface.php
+++ b/src/UrlProcessor/UrlProcessorInterface.php
@@ -42,6 +42,7 @@ interface UrlProcessorInterface {
* remembered when building the facet's urls.
*
* @param \Drupal\facets\FacetInterface $facet
+ * The facet that is edited.
*/
public function setActiveItems(FacetInterface $facet);
diff --git a/src/Widget/WidgetInterface.php b/src/Widget/WidgetInterface.php
index 536ba71364e41da29b6d676852de137793a74dfb..bf3142999fd1a083169de3928e5fe2aa7e18a585 100644
--- a/src/Widget/WidgetInterface.php
+++ b/src/Widget/WidgetInterface.php
@@ -14,7 +14,7 @@ use Drupal\facets\FacetInterface;
interface WidgetInterface {
/**
- * Add facet info to the query using the selected query type.
+ * Adds facet info to the query using the selected query type.
*
* @return mixed
* A boolean
@@ -33,7 +33,7 @@ interface WidgetInterface {
public function build(FacetInterface $facet);
/**
- * Pick the preferred query type for this widget.
+ * Picks the preferred query type for this widget.
*
* @param string[] $query_types
* An array keyed with query type name and it's plugin class to load.
diff --git a/tests/facets_query_processor/src/Plugin/facets/url_processor/DummyQuery.php b/tests/facets_query_processor/src/Plugin/facets/url_processor/DummyQuery.php
index 764e67cd6111a1b37c3fab9271ed673bacd369b2..bc17ce21690e17a7a63231237024ada58fe5c1dd 100644
--- a/tests/facets_query_processor/src/Plugin/facets/url_processor/DummyQuery.php
+++ b/tests/facets_query_processor/src/Plugin/facets/url_processor/DummyQuery.php
@@ -33,7 +33,7 @@ class DummyQuery extends UrlProcessorPluginBase {
*
* @var string
*/
- protected $url_alias;
+ protected $urlAlias;
/**
* An array of active filters.
@@ -60,7 +60,7 @@ class DummyQuery extends UrlProcessorPluginBase {
$get_params = $this->request->query;
// Set the url alias from the the facet object.
- $this->url_alias = $facet->getUrlAlias();
+ $this->urlAlias = $facet->getUrlAlias();
// No results are found for this facet, so don't try to create urls.
if (empty($results)) {
@@ -69,7 +69,7 @@ class DummyQuery extends UrlProcessorPluginBase {
/** @var \Drupal\facets\Result\ResultInterface $result */
foreach ($results as &$result) {
- $filter_string = $this->url_alias . self::SEPARATOR . $result->getRawValue();
+ $filter_string = $this->urlAlias . self::SEPARATOR . $result->getRawValue();
$result_get_params = clone $get_params;
$filter_params = $result_get_params->get($this->filterKey, [], TRUE);
@@ -105,18 +105,18 @@ class DummyQuery extends UrlProcessorPluginBase {
*/
public function setActiveItems(FacetInterface $facet) {
// Set the url alias from the the facet object.
- $this->url_alias = $facet->getUrlAlias();
+ $this->urlAlias = $facet->getUrlAlias();
// Get the filter key of the facet.
- if (isset($this->activeFilters[$this->url_alias])) {
- foreach ($this->activeFilters[$this->url_alias] as $value) {
+ if (isset($this->activeFilters[$this->urlAlias])) {
+ foreach ($this->activeFilters[$this->urlAlias] as $value) {
$facet->setActiveItem(trim($value, '"'));
}
}
}
/**
- * Initialize the active filters.
+ * Initializes the active filters.
*
* Get all the filters that are active. This method only get's all the
* filters but doesn't assign them to facets. In the processFacet method the
diff --git a/tests/src/Unit/FacetSource/FacetSourcePluginManagerTest.php b/tests/src/Unit/FacetSource/FacetSourcePluginManagerTest.php
index 1c76807ebc1745496cc1002b1026a9655ee652f9..ed643d70984f89f56c621d445ac92fc7e9065a19 100644
--- a/tests/src/Unit/FacetSource/FacetSourcePluginManagerTest.php
+++ b/tests/src/Unit/FacetSource/FacetSourcePluginManagerTest.php
@@ -87,7 +87,8 @@ class FacetSourcePluginManagerTest extends UnitTestCase {
*/
public function testConstruct() {
$namespaces = new ArrayObject();
- $this->sut = new FacetSourcePluginManager($namespaces, $this->cache, $this->moduleHandler);
+ $sut = new FacetSourcePluginManager($namespaces, $this->cache, $this->moduleHandler);
+ $this->assertInstanceOf('\Drupal\facets\FacetSource\FacetSourcePluginManager', $sut);
}
/**
diff --git a/tests/src/Unit/Plugin/Condition/OtherFacetTest.php b/tests/src/Unit/Plugin/Condition/OtherFacetTest.php
index dc0860aa0864833f9920272f08add5b22a3e3852..821f0750ad02bfd06d850f6ff8968f3e6857de4e 100644
--- a/tests/src/Unit/Plugin/Condition/OtherFacetTest.php
+++ b/tests/src/Unit/Plugin/Condition/OtherFacetTest.php
@@ -186,4 +186,5 @@ class OtherFacetTest extends UnitTestCase {
$evaluation = $sut->evaluate();
$this->assertFalse($evaluation);
}
+
}
diff --git a/tests/src/Unit/Plugin/processor/ActiveWidgetOrderProcessorTest.php b/tests/src/Unit/Plugin/processor/ActiveWidgetOrderProcessorTest.php
index 185c360a66e45bf31d7712fe1a6febb2f94a3599..5eff654a81fff5f2284704541c096b1dfc5669ce 100644
--- a/tests/src/Unit/Plugin/processor/ActiveWidgetOrderProcessorTest.php
+++ b/tests/src/Unit/Plugin/processor/ActiveWidgetOrderProcessorTest.php
@@ -57,7 +57,7 @@ class ActiveWidgetOrderProcessorTest extends UnitTestCase {
}
/**
- * Test sorting ascending.
+ * Tests sorting ascending.
*/
public function testAscending() {
$sorted_results = $this->processor->sortResults($this->originalResults, 'ASC');
@@ -68,7 +68,7 @@ class ActiveWidgetOrderProcessorTest extends UnitTestCase {
}
/**
- * Test sorting descending.
+ * Tests sorting descending.
*/
public function testDescending() {
$sorted_results = $this->processor->sortResults($this->originalResults, 'DESC');
diff --git a/tests/src/Unit/Plugin/processor/CountLimitProcessorTest.php b/tests/src/Unit/Plugin/processor/CountLimitProcessorTest.php
index 4db2c91952a9d42d9aa65666842837086feefc5a..ed87d3db7682f6aed8add8b340493cb69d3003d4 100644
--- a/tests/src/Unit/Plugin/processor/CountLimitProcessorTest.php
+++ b/tests/src/Unit/Plugin/processor/CountLimitProcessorTest.php
@@ -73,7 +73,7 @@ class CountLimitProcessorTest extends UnitTestCase {
}
/**
- * Test no filtering happens.
+ * Tests no filtering happens.
*/
public function testNoFilter() {
$facet = new Facet([], 'facet');
@@ -94,7 +94,7 @@ class CountLimitProcessorTest extends UnitTestCase {
}
/**
- * Test no filtering happens.
+ * Tests no filtering happens.
*/
public function testMinEqualsValue() {
$facet = new Facet([], 'facet');
@@ -116,7 +116,7 @@ class CountLimitProcessorTest extends UnitTestCase {
}
/**
- * Test between minimum and maximum values.
+ * Tests between minimum and maximum values.
*/
public function testBetweenMinAndMaxValue() {
$facet = new Facet([], 'facet');
@@ -142,7 +142,7 @@ class CountLimitProcessorTest extends UnitTestCase {
}
/**
- * Test maximum values.
+ * Tests maximum values.
*/
public function testMaxValue() {
$facet = new Facet([], 'facet');
@@ -172,7 +172,7 @@ class CountLimitProcessorTest extends UnitTestCase {
}
/**
- * Test filtering of results.
+ * Tests filtering of results.
*/
public function testFilterResults() {
$facet = new Facet([], 'facet');
diff --git a/tests/src/Unit/Plugin/processor/CountWidgetOrderProcessorTest.php b/tests/src/Unit/Plugin/processor/CountWidgetOrderProcessorTest.php
index 1e86337d635a22b3e156fddbe80e037b18e75b9a..5c2346fb2e091c8d0df76513a29bd9c692b1f85c 100644
--- a/tests/src/Unit/Plugin/processor/CountWidgetOrderProcessorTest.php
+++ b/tests/src/Unit/Plugin/processor/CountWidgetOrderProcessorTest.php
@@ -48,7 +48,7 @@ class CountWidgetOrderProcessorTest extends UnitTestCase {
}
/**
- * Test sorting ascending.
+ * Tests sorting ascending.
*/
public function testAscending() {
@@ -63,7 +63,7 @@ class CountWidgetOrderProcessorTest extends UnitTestCase {
}
/**
- * Test sorting descending.
+ * Tests sorting descending.
*/
public function testDescending() {
diff --git a/tests/src/Unit/Plugin/processor/DisplayValueWidgetOrderProcessorTest.php b/tests/src/Unit/Plugin/processor/DisplayValueWidgetOrderProcessorTest.php
index 606e52d41dc47eba5c232d006349156276ecc84a..81ee397b065e8a01857b4341f6a22f39fb69a04c 100644
--- a/tests/src/Unit/Plugin/processor/DisplayValueWidgetOrderProcessorTest.php
+++ b/tests/src/Unit/Plugin/processor/DisplayValueWidgetOrderProcessorTest.php
@@ -52,7 +52,7 @@ class DisplayValueWidgetOrderProcessorTest extends UnitTestCase {
}
/**
- * Test sorting ascending.
+ * Tests sorting ascending.
*/
public function testAscending() {
$sorted_results = $this->processor->sortResults($this->originalResults, 'ASC');
@@ -71,7 +71,7 @@ class DisplayValueWidgetOrderProcessorTest extends UnitTestCase {
}
/**
- * Test sorting descending.
+ * Tests sorting descending.
*/
public function testDescending() {
$sorted_results = $this->processor->sortResults($this->originalResults, 'DESC');
@@ -90,7 +90,7 @@ class DisplayValueWidgetOrderProcessorTest extends UnitTestCase {
}
/**
- * Test that sorting uses the display value.
+ * Tests that sorting uses the display value.
*/
public function testUseActualDisplayValue() {
$original = [
diff --git a/tests/src/Unit/Plugin/processor/ExcludeSpecifiedItemsProcessorTest.php b/tests/src/Unit/Plugin/processor/ExcludeSpecifiedItemsProcessorTest.php
index 71870f95405406c64598c1e6acddda7cf3d84e85..ff33e6d1c573dcc90d698dfe3a03f5b53745be44 100644
--- a/tests/src/Unit/Plugin/processor/ExcludeSpecifiedItemsProcessorTest.php
+++ b/tests/src/Unit/Plugin/processor/ExcludeSpecifiedItemsProcessorTest.php
@@ -78,7 +78,7 @@ class ExcludeSpecifiedItemsProcessorTest extends UnitTestCase {
}
/**
- * Test no filtering happens.
+ * Tests no filtering happens.
*/
public function testNoFilter() {
$facet = new Facet([], 'facet');
@@ -101,7 +101,7 @@ class ExcludeSpecifiedItemsProcessorTest extends UnitTestCase {
}
/**
- * Test filtering happens for string filter.
+ * Tests filtering happens for string filter.
*/
public function testStringFilter() {
$facet = new Facet([], 'facet');
@@ -128,7 +128,7 @@ class ExcludeSpecifiedItemsProcessorTest extends UnitTestCase {
}
/**
- * Test filtering happens for regex filter.
+ * Tests filtering happens for regex filter.
*
* @dataProvider provideRegexTests
*/
@@ -157,7 +157,7 @@ class ExcludeSpecifiedItemsProcessorTest extends UnitTestCase {
}
/**
- * Provide multiple data sets for ::testRegexFilter.
+ * Provides multiple data sets for ::testRegexFilter.
*/
public function provideRegexTests() {
return [
diff --git a/tests/src/Unit/Plugin/processor/HideNonNarrowingResultProcessorTest.php b/tests/src/Unit/Plugin/processor/HideNonNarrowingResultProcessorTest.php
index f1bdba79fb40da64b87b2b0d74b3226348ce0b21..64be36f181f152242563c212af876a74cbdde37a 100644
--- a/tests/src/Unit/Plugin/processor/HideNonNarrowingResultProcessorTest.php
+++ b/tests/src/Unit/Plugin/processor/HideNonNarrowingResultProcessorTest.php
@@ -48,9 +48,8 @@ class HideNonNarrowingResultProcessorTest extends UnitTestCase {
$this->processor = new HideNonNarrowingResultProcessor([], 'hide_non_narrowing_result_processor', []);
}
-
/**
- * Test filtering of results.
+ * Tests filtering of results.
*/
public function testNoFilterResults() {
@@ -70,7 +69,7 @@ class HideNonNarrowingResultProcessorTest extends UnitTestCase {
}
/**
- * Test filtering of results.
+ * Tests filtering of results.
*/
public function testFilterResults() {
diff --git a/tests/src/Unit/Plugin/processor/RawValueWidgetOrderProcessorTest.php b/tests/src/Unit/Plugin/processor/RawValueWidgetOrderProcessorTest.php
index c8bff42fd0c67ced18458d438268a5de133c8e99..5a6182775308b20d127ee0815eca5501fed5425b 100644
--- a/tests/src/Unit/Plugin/processor/RawValueWidgetOrderProcessorTest.php
+++ b/tests/src/Unit/Plugin/processor/RawValueWidgetOrderProcessorTest.php
@@ -52,7 +52,7 @@ class RawValueWidgetOrderProcessorTest extends UnitTestCase {
}
/**
- * Test sorting ascending.
+ * Tests sorting ascending.
*/
public function testAscending() {
$sorted_results = $this->processor->sortResults($this->originalResults, 'ASC');
@@ -71,7 +71,7 @@ class RawValueWidgetOrderProcessorTest extends UnitTestCase {
}
/**
- * Test sorting descending.
+ * Tests sorting descending.
*/
public function testDescending() {
$sorted_results = $this->processor->sortResults($this->originalResults, 'DESC');
diff --git a/tests/src/Unit/Plugin/processor/UidToUserNameCallbackProcessorTest.php b/tests/src/Unit/Plugin/processor/UidToUserNameCallbackProcessorTest.php
index 14aca50e39e91da0cf6146b651272aa996e5c1c7..d5393c85e9f6b705298e61055f09bb1f870240bf 100644
--- a/tests/src/Unit/Plugin/processor/UidToUserNameCallbackProcessorTest.php
+++ b/tests/src/Unit/Plugin/processor/UidToUserNameCallbackProcessorTest.php
@@ -38,9 +38,8 @@ class UidToUserNameCallbackProcessorTest extends UnitTestCase {
$this->createMocks();
}
-
/**
- * Test that results were correctly changed.
+ * Tests that results were correctly changed.
*/
public function testResultsChanged() {
$original_results = [
diff --git a/tests/src/Unit/Plugin/processor/UrlProcessorHandlerTest.php b/tests/src/Unit/Plugin/processor/UrlProcessorHandlerTest.php
index c411be8b9f00ce9fe34a7d69124c2a777962438c..13cdc5bf416a7ede7cb7c48d864aafafd8663c82 100644
--- a/tests/src/Unit/Plugin/processor/UrlProcessorHandlerTest.php
+++ b/tests/src/Unit/Plugin/processor/UrlProcessorHandlerTest.php
@@ -36,7 +36,7 @@ class UrlProcessorHandlerTest extends UnitTestCase {
}
/**
- * Test that the build method is correctly called.
+ * Tests that the build method is correctly called.
*/
public function testBuild() {
$facet = new Facet(['id' => '_test'], 'facets_facet');
@@ -48,7 +48,7 @@ class UrlProcessorHandlerTest extends UnitTestCase {
}
/**
- * Helper function to create a correct container.
+ * Sets up a container.
*/
protected function createContainer() {
$url_processor = $this->getMockBuilder('\Drupal\facets\UrlProcessor\UrlProcessorInterface')
diff --git a/tests/src/Unit/Plugin/query_type/SearchApiStringTest.php b/tests/src/Unit/Plugin/query_type/SearchApiStringTest.php
index 58d5966895ee5b9903f23c5a21573591e4768f5a..1005ecd53cb4e27312c49378483a6158855ab25a 100644
--- a/tests/src/Unit/Plugin/query_type/SearchApiStringTest.php
+++ b/tests/src/Unit/Plugin/query_type/SearchApiStringTest.php
@@ -20,7 +20,7 @@ use Drupal\Tests\UnitTestCase;
class SearchApiStringTest extends UnitTestCase {
/**
- * Test string query type without executing the query.
+ * Tests string query type without executing the query.
*/
public function testQueryType() {
$query = new SearchApiQuery([], 'search_api_query', []);
@@ -60,7 +60,7 @@ class SearchApiStringTest extends UnitTestCase {
}
/**
- * Test string query type without results.
+ * Tests string query type without results.
*/
public function testEmptyResults() {
$query = new SearchApiQuery([], 'search_api_query', []);
diff --git a/tests/src/Unit/Plugin/url_processor/QueryStringTest.php b/tests/src/Unit/Plugin/url_processor/QueryStringTest.php
index 7f306538055070fe271e0ae00bae57bb3a7ce6cc..eabebc7915316b92bb742265b7e5aba361146b54 100644
--- a/tests/src/Unit/Plugin/url_processor/QueryStringTest.php
+++ b/tests/src/Unit/Plugin/url_processor/QueryStringTest.php
@@ -63,7 +63,7 @@ class QueryStringTest extends UnitTestCase {
}
/**
- * Basic test with one active item.
+ * Tests with one active item.
*/
public function testSetSingleActiveItem() {
$facet = new Facet([], 'facet');
@@ -81,7 +81,7 @@ class QueryStringTest extends UnitTestCase {
}
/**
- * Basic test with multiple active items.
+ * Tests with multiple active items.
*/
public function testSetMultipleActiveItems() {
$facet = new Facet([], 'facet');
@@ -99,7 +99,7 @@ class QueryStringTest extends UnitTestCase {
}
/**
- * Basic test with an empty build.
+ * Tests with an empty build.
*/
public function testEmptyBuild() {
$facet = new Facet([], 'facet');
@@ -115,7 +115,7 @@ class QueryStringTest extends UnitTestCase {
}
/**
- * Test with default build.
+ * Test swith default build.
*/
public function testBuild() {
$facet = new Facet([], 'facet');
@@ -137,7 +137,7 @@ class QueryStringTest extends UnitTestCase {
}
/**
- * Test with an active item already from url.
+ * Tests with an active item already from url.
*/
public function testBuildWithActiveItem() {
$facet = new Facet([], 'facet');
@@ -167,7 +167,7 @@ class QueryStringTest extends UnitTestCase {
}
/**
- * Test that the facet source configuration filter key override works.
+ * Tests that the facet source configuration filter key override works.
*/
public function testFacetSourceFilterKeyOverride() {
$facet_source = new FacetSource(['filter_key' => 'ab'], 'facets_facet_source');
@@ -208,7 +208,7 @@ class QueryStringTest extends UnitTestCase {
}
/**
- * Set the container for use in unit tests.
+ * Sets up a container.
*/
protected function setContainer() {
$router = $this->getMockBuilder('Drupal\Tests\Core\Routing\TestRouterInterface')
diff --git a/tests/src/Unit/Plugin/widget/CheckboxWidgetTest.php b/tests/src/Unit/Plugin/widget/CheckboxWidgetTest.php
index 187dddd4d7a86fe256b02ab35312b049e0c10e4a..372f436983bcbb79b6b081e649572642440963f3 100644
--- a/tests/src/Unit/Plugin/widget/CheckboxWidgetTest.php
+++ b/tests/src/Unit/Plugin/widget/CheckboxWidgetTest.php
@@ -71,17 +71,17 @@ class CheckboxWidgetTest extends UnitTestCase {
}
/**
- * Test widget with default settings.
+ * Tests widget with default settings.
*/
public function testDefaultSettings() {
$facet = new Facet([], 'facet');
$facet->setResults($this->originalResults);
$facet->setFieldIdentifier('test_field');
- $formState = new FormState();
- $formState->addBuildInfo('args', [$facet]);
+ $form_state = new FormState();
+ $form_state->addBuildInfo('args', [$facet]);
$form = [];
- $built_form = $this->widget->buildForm($form, $formState);
+ $built_form = $this->widget->buildForm($form, $form_state);
$this->assertInternalType('array', $built_form);
$this->assertCount(4, $built_form['test_field']['#options']);
@@ -91,7 +91,7 @@ class CheckboxWidgetTest extends UnitTestCase {
'llama' => 'Llama',
'badger' => 'Badger',
'duck' => 'Duck',
- 'alpaca' => 'Alpaca'
+ 'alpaca' => 'Alpaca',
];
foreach ($expected_links as $index => $value) {
$this->assertEquals($value, $built_form['test_field']['#options'][$index]);
@@ -99,7 +99,7 @@ class CheckboxWidgetTest extends UnitTestCase {
}
/**
- * Test widget, make sure hiding and showing numbers works.
+ * Tests widget, make sure hiding and showing numbers works.
*/
public function testHideNumbers() {
$original_results = $this->originalResults;
@@ -110,10 +110,10 @@ class CheckboxWidgetTest extends UnitTestCase {
$facet->setFieldIdentifier('test__field');
$facet->setWidgetConfigs(['show_numbers' => 0]);
- $formState = new FormState();
- $formState->addBuildInfo('args', [$facet]);
+ $form_state = new FormState();
+ $form_state->addBuildInfo('args', [$facet]);
$form = [];
- $built_form = $this->widget->buildForm($form, $formState);
+ $built_form = $this->widget->buildForm($form, $form_state);
$this->assertInternalType('array', $built_form);
$this->assertCount(4, $built_form['test__field']['#options']);
@@ -121,7 +121,7 @@ class CheckboxWidgetTest extends UnitTestCase {
'llama' => 'Llama',
'badger' => 'Badger',
'duck' => 'Duck',
- 'alpaca' => 'Alpaca'
+ 'alpaca' => 'Alpaca',
];
foreach ($expected_links as $index => $value) {
$this->assertEquals($value, $built_form['test__field']['#options'][$index]);
@@ -131,7 +131,7 @@ class CheckboxWidgetTest extends UnitTestCase {
// between those settings works.
$facet->setWidgetConfigs(['show_numbers' => 1]);
- $built_form = $this->widget->buildForm($form, $formState);
+ $built_form = $this->widget->buildForm($form, $form_state);
$this->assertInternalType('array', $built_form);
$this->assertCount(4, $built_form['test__field']['#options']);
diff --git a/tests/src/Unit/Plugin/widget/LinksWidgetTest.php b/tests/src/Unit/Plugin/widget/LinksWidgetTest.php
index 49b99fce938210659806d41958e83a918b7d09b7..8ed8bbf831e07424937e7abd79184674f89d622b 100644
--- a/tests/src/Unit/Plugin/widget/LinksWidgetTest.php
+++ b/tests/src/Unit/Plugin/widget/LinksWidgetTest.php
@@ -11,7 +11,6 @@ use Drupal\facets\Entity\Facet;
use Drupal\facets\Plugin\facets\widget\LinksWidget;
use Drupal\facets\Result\Result;
use Drupal\Tests\UnitTestCase;
-use Symfony\Component\DependencyInjection\ContainerBuilder;
/**
* Unit test for widget.
@@ -57,7 +56,7 @@ class LinksWidgetTest extends UnitTestCase {
}
/**
- * Test widget.
+ * Tests widget without filters.
*/
public function testNoFilterResults() {
$facet = new Facet([], 'facet');
@@ -77,7 +76,7 @@ class LinksWidgetTest extends UnitTestCase {
}
/**
- * Test widget.
+ * Test widget with 2 active items.
*/
public function testActiveItems() {
$original_results = $this->originalResults;
@@ -106,7 +105,7 @@ class LinksWidgetTest extends UnitTestCase {
}
/**
- * Test widget, make sure hiding and showing numbers works.
+ * Tests widget, make sure hiding and showing numbers works.
*/
public function testHideNumbers() {
$original_results = $this->originalResults;
diff --git a/tests/src/Unit/Processor/ProcessorPluginManagerTest.php b/tests/src/Unit/Processor/ProcessorPluginManagerTest.php
index fcfe48f0dbc185d57ec5366219d8b2c5a0dec0a1..535aaad637c86ba5197266d45e849504e7f83078 100644
--- a/tests/src/Unit/Processor/ProcessorPluginManagerTest.php
+++ b/tests/src/Unit/Processor/ProcessorPluginManagerTest.php
@@ -97,7 +97,8 @@ class ProcessorPluginManagerTest extends UnitTestCase {
*/
public function testConstruct() {
$namespaces = new ArrayObject();
- $this->sut = new ProcessorPluginManager($namespaces, $this->cache, $this->moduleHandler, $this->translator);
+ $sut = new ProcessorPluginManager($namespaces, $this->cache, $this->moduleHandler, $this->translator);
+ $this->assertInstanceOf('\Drupal\facets\Processor\ProcessorPluginManager', $sut);
}
/**
diff --git a/tests/src/Unit/QueryType/QueryTypePluginManagerTest.php b/tests/src/Unit/QueryType/QueryTypePluginManagerTest.php
index 3650c4b5dcec51ad56f74f3fc31a6684da4d6a4d..8c3bb527b902ef719809632582132c5e986dd6d1 100644
--- a/tests/src/Unit/QueryType/QueryTypePluginManagerTest.php
+++ b/tests/src/Unit/QueryType/QueryTypePluginManagerTest.php
@@ -86,7 +86,8 @@ class QueryTypePluginManagerTest extends UnitTestCase {
*/
public function testConstruct() {
$namespaces = new ArrayObject();
- $this->sut = new QueryTypePluginManager($namespaces, $this->cache, $this->moduleHandler);
+ $sut = new QueryTypePluginManager($namespaces, $this->cache, $this->moduleHandler);
+ $this->assertInstanceOf('\Drupal\facets\QueryType\QueryTypePluginManager', $sut);
}
/**