summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorborisson_2016-01-27 15:16:07 (GMT)
committerJoris Vercammen2016-01-27 15:16:07 (GMT)
commita7524691529b66f4aa66b6dd58c55653468343c9 (patch)
treea5563a07b9f273b79483a508808a0092553b7d1a
parent2921f6d682c6c55e55b128f834a3000639782a85 (diff)
Issue #2656748 by borisson_: Fix issues with documentation standards
-rw-r--r--core_search_facets/src/FacetsQuery.php4
-rw-r--r--core_search_facets/src/Plugin/Search/NodeSearchFacets.php13
-rw-r--r--core_search_facets/src/Plugin/facets/facet_source/CoreNodeSearchFacetSource.php37
-rw-r--r--core_search_facets/src/Plugin/facets/facet_source/CoreNodeSearchFacetSourceDeriver.php21
-rw-r--r--core_search_facets/src/Plugin/facets/query_type/CoreNodeSearchString.php3
-rw-r--r--core_search_facets/src/Tests/HooksTest.php6
-rw-r--r--core_search_facets/src/Tests/IntegrationTest.php5
-rw-r--r--core_search_facets/src/Tests/WebTestBase.php4
-rw-r--r--facets.module2
-rw-r--r--src/Annotation/FacetsFacetSource.php4
-rw-r--r--src/Entity/Facet.php20
-rw-r--r--src/Entity/FacetSource.php8
-rw-r--r--src/FacetInterface.php58
-rw-r--r--src/FacetListBuilder.php2
-rw-r--r--src/FacetManager/DefaultFacetManager.php31
-rw-r--r--src/FacetSource/FacetSourceDeriverBase.php1
-rw-r--r--src/FacetSource/FacetSourcePluginBase.php2
-rw-r--r--src/FacetSource/FacetSourcePluginInterface.php6
-rw-r--r--src/FacetSource/FacetSourcePluginManager.php10
-rw-r--r--src/FacetSourceInterface.php4
-rw-r--r--src/Form/FacetDisplayForm.php4
-rw-r--r--src/Form/FacetForm.php27
-rw-r--r--src/Form/FacetSourceEditForm.php9
-rw-r--r--src/Plugin/Block/FacetBlock.php8
-rw-r--r--src/Plugin/Block/FacetBlockDeriver.php4
-rw-r--r--src/Plugin/Condition/OtherFacet.php2
-rw-r--r--src/Plugin/facets/facet_source/SearchApiBaseFacetSource.php5
-rw-r--r--src/Plugin/facets/processor/UrlProcessorHandler.php13
-rw-r--r--src/Plugin/facets/query_type/SearchApiString.php3
-rw-r--r--src/Plugin/facets/url_processor/QueryString.php25
-rw-r--r--src/Plugin/facets/widget/CheckboxWidget.php1
-rw-r--r--src/Plugin/facets/widget/LinksWidget.php6
-rw-r--r--src/Processor/BuildProcessorInterface.php2
-rw-r--r--src/Processor/PostQueryProcessorInterface.php2
-rw-r--r--src/Processor/PreQueryProcessorInterface.php2
-rw-r--r--src/Processor/ProcessorPluginBase.php3
-rw-r--r--src/Processor/WidgetOrderPluginBase.php2
-rw-r--r--src/Processor/WidgetOrderProcessorInterface.php2
-rw-r--r--src/QueryType/QueryTypeInterface.php4
-rw-r--r--src/QueryType/QueryTypePluginBase.php4
-rw-r--r--src/Result/Result.php2
-rw-r--r--src/Result/ResultInterface.php14
-rw-r--r--src/Tests/ExampleContentTrait.php86
-rw-r--r--src/Tests/FacetSourceTest.php4
-rw-r--r--src/Tests/IntegrationTest.php12
-rw-r--r--src/Tests/UrlIntegrationTest.php2
-rw-r--r--src/Tests/WidgetIntegrationTest.php10
-rw-r--r--src/UrlProcessor/UrlProcessorInterface.php1
-rw-r--r--src/Widget/WidgetInterface.php4
-rw-r--r--tests/facets_query_processor/src/Plugin/facets/url_processor/DummyQuery.php14
-rw-r--r--tests/src/Unit/FacetSource/FacetSourcePluginManagerTest.php3
-rw-r--r--tests/src/Unit/Plugin/Condition/OtherFacetTest.php1
-rw-r--r--tests/src/Unit/Plugin/processor/ActiveWidgetOrderProcessorTest.php4
-rw-r--r--tests/src/Unit/Plugin/processor/CountLimitProcessorTest.php10
-rw-r--r--tests/src/Unit/Plugin/processor/CountWidgetOrderProcessorTest.php4
-rw-r--r--tests/src/Unit/Plugin/processor/DisplayValueWidgetOrderProcessorTest.php6
-rw-r--r--tests/src/Unit/Plugin/processor/ExcludeSpecifiedItemsProcessorTest.php8
-rw-r--r--tests/src/Unit/Plugin/processor/HideNonNarrowingResultProcessorTest.php5
-rw-r--r--tests/src/Unit/Plugin/processor/RawValueWidgetOrderProcessorTest.php4
-rw-r--r--tests/src/Unit/Plugin/processor/UidToUserNameCallbackProcessorTest.php3
-rw-r--r--tests/src/Unit/Plugin/processor/UrlProcessorHandlerTest.php4
-rw-r--r--tests/src/Unit/Plugin/query_type/SearchApiStringTest.php4
-rw-r--r--tests/src/Unit/Plugin/url_processor/QueryStringTest.php14
-rw-r--r--tests/src/Unit/Plugin/widget/CheckboxWidgetTest.php22
-rw-r--r--tests/src/Unit/Plugin/widget/LinksWidgetTest.php7
-rw-r--r--tests/src/Unit/Processor/ProcessorPluginManagerTest.php3
-rw-r--r--tests/src/Unit/QueryType/QueryTypePluginManagerTest.php3
67 files changed, 295 insertions, 328 deletions
diff --git a/core_search_facets/src/FacetsQuery.php b/core_search_facets/src/FacetsQuery.php
index a34c055..9eb1347 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 ab5687c..3b499ab 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 92bd17b..0fd5dcc 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 f1ba3cd..e14b487 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 74a896f..7834550 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 b3dac67..dfc31c9 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 c69edff..6209476 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 f9ffb0c..e68b66d 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 ceda0c8..2e89c4a 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 7389e31..550313d 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 a75a505..c28d7e3 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.
@@ -253,13 +258,6 @@ class Facet extends ConfigEntityBase implements FacetInterface {
/**
* {@inheritdoc}
*/
- public function id() {
- return $this->id;
- }
-
- /**
- * {@inheritdoc}
- */
protected function urlRouteParameters($rel) {
$parameters = parent::urlRouteParameters($rel);
return $parameters;
@@ -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 9aa4733..5768a6a 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.
@@ -79,13 +78,6 @@ class FacetSource extends ConfigEntityBase implements FacetSourceInterface {
/**
* {@inheritdoc}
*/
- public function id() {
- return $this->id;
- }
-
- /**
- * {@inheritdoc}
- */
public function getName() {
return $this->name;
}
diff --git a/src/FacetInterface.php b/src/FacetInterface.php
index 02cd6b1..6a92d90 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 fb4bd7c..abfa1c1 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 0221c12..9eaf544 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,7 +132,7 @@ 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.
@@ -144,6 +140,16 @@ class DefaultFacetManager {
}
/**
+ * 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.
*
* This method is called by the implementing module to initialize the facet
@@ -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 3797606..392c7c4 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 8cf6b8e..27acfd6 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 91a519f..4dff129 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 1b62874..8c0c0a5 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 8c6e909..fd46572 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 170feca..5f93de4 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 d19739c..6ddc996 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
*/
@@ -75,22 +75,6 @@ class FacetForm extends EntityForm {
}
/**
- * 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.
*
* @return \Drupal\Core\Entity\EntityStorageInterface
@@ -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();
@@ -273,13 +257,6 @@ class FacetForm extends EntityForm {
/**
* {@inheritdoc}
*/
- public function validateForm(array &$form, FormStateInterface $form_state) {
- parent::validateForm($form, $form_state);
- }
-
- /**
- * {@inheritdoc}
- */
public function submitForm(array &$form, FormStateInterface $form_state) {
parent::submitForm($form, $form_state);
diff --git a/src/Form/FacetSourceEditForm.php b/src/Form/FacetSourceEditForm.php
index 45b14cc..b2a0933 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.') . '<br />- ' . implode('<br>- ', $url_processors_description),
+ 'The URL Processor defines the url structure used for this facet source.') . '<br />- ' . implode('<br>- ', $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 9830129..fc14150 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 6dffef2..9305023 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 b706466..893e7c1 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 882600f..1bef6c5 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 5a78e00..8779a8f 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 eb2a484..c2a45a2 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 9be51c0..ce36f54 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 a202ccd..3f66a75 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 67bc5fb..0ee9a10 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 d494f27..76c77bd 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 3a93206..a8aea56 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 72c854d..1c1f793 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 c5221b0..48fc2d8 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 3014f64..3aac26a 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 e07c84d..fadab54 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 d43e3ac..ab735db 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 497a7f2..01f0b33 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 f430981..b748f64 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 6589608..bed1d87 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 0b34cd3..5bb93f4 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 9bd8f9c..bb39811 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 d6ea22d..20f93b1 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 e5ebf98..63f8da3 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 142f6d1..34c728e 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 3bc51a1..5b56c49 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 536ba71..bf31429 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 764e67c..bc17ce2 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 1c76807..ed643d7 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 dc0860a..821f075 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 185c360..5eff654 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 4db2c91..ed87d3d 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 1e86337..5c2346f 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 606e52d..81ee397 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 71870f9..ff33e6d 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 f1bdba7..64be36f 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 c8bff42..5a61827 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 14aca50..d5393c8 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 c411be8..13cdc5b 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 58d5966..1005ecd 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 7f30653..eabebc7 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 187dddd..372f436 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 49b99fc..8ed8bbf 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 fcfe48f..535aaad 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 3650c4b..8c3bb52 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);
}
/**