Commit 984aff62 authored by borisson_'s avatar borisson_ Committed by borisson_

Issue #2896175 by borisson_: Fix phpcs errors

parent e54263e2
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
* @file * @file
* Provides the slider functionality. * Provides the slider functionality.
*/ */
(function ($) { (function ($) {
'use strict'; 'use strict';
......
...@@ -123,7 +123,7 @@ class SliderIntegrationTest extends FacetsTestBase { ...@@ -123,7 +123,7 @@ class SliderIntegrationTest extends FacetsTestBase {
'type' => 'item', 'type' => 'item',
'keywords' => ['orange'], 'keywords' => ['orange'],
'category' => 'item_category', 'category' => 'item_category',
'field_integer' => (bool) $i%2 ? $i : $i+1, 'field_integer' => (bool) $i % 2 ? $i : $i + 1,
])->save(); ])->save();
} }
......
...@@ -95,7 +95,7 @@ class DefaultFacetsSummaryManager { ...@@ -95,7 +95,7 @@ class DefaultFacetsSummaryManager {
$facets_config = $facets_summary->getFacets(); $facets_config = $facets_summary->getFacets();
// Exclude facets which were not selected for this summary. // Exclude facets which were not selected for this summary.
$facets = array_filter($facets, $facets = array_filter($facets,
function($item) use ($facets_config) { function ($item) use ($facets_config) {
return (isset($facets_config[$item->id()])); return (isset($facets_config[$item->id()]));
} }
); );
...@@ -145,7 +145,7 @@ class DefaultFacetsSummaryManager { ...@@ -145,7 +145,7 @@ class DefaultFacetsSummaryManager {
* @return array * @return array
* The rendered links to the active facets. * The rendered links to the active facets.
*/ */
protected function buildResultTree($show_count, $results) { protected function buildResultTree($show_count, array $results) {
$items = []; $items = [];
foreach ($results as $result) { foreach ($results as $result) {
if ($result->isActive()) { if ($result->isActive()) {
......
...@@ -57,7 +57,7 @@ class ResetFacetsProcessor extends ProcessorPluginBase implements BuildProcessor ...@@ -57,7 +57,7 @@ class ResetFacetsProcessor extends ProcessorPluginBase implements BuildProcessor
// Lets use any first facet to get correct url. // Lets use any first facet to get correct url.
$results = reset($facets)->getResults(); $results = reset($facets)->getResults();
/** @var \Drupal\Core\Url $first_item_url */ /** @var \Drupal\Core\Url $first_item_url */
$first_item_url = reset($results)->getUrl(); $first_item_url = reset($results)->getUrl();
$first_item_url = clone ($first_item_url); $first_item_url = clone ($first_item_url);
$first_item_url->setOptions(['query' => $query_params]); $first_item_url->setOptions(['query' => $query_params]);
......
...@@ -5,7 +5,6 @@ namespace Drupal\Tests\facets_summary\Functional; ...@@ -5,7 +5,6 @@ namespace Drupal\Tests\facets_summary\Functional;
use Drupal\Tests\facets\Functional\FacetsTestBase; use Drupal\Tests\facets\Functional\FacetsTestBase;
use Drupal\facets_summary\Entity\FacetsSummary; use Drupal\facets_summary\Entity\FacetsSummary;
use Drupal\views\Views; use Drupal\views\Views;
use Symfony\Component\DependencyInjection\ContainerInterface;
/** /**
* Tests the overall functionality of the Facets summary admin UI. * Tests the overall functionality of the Facets summary admin UI.
......
...@@ -126,4 +126,5 @@ class FacetSource extends ConfigEntityBase implements FacetSourceInterface { ...@@ -126,4 +126,5 @@ class FacetSource extends ConfigEntityBase implements FacetSourceInterface {
public function setBreadcrumbSettings(array $settings) { public function setBreadcrumbSettings(array $settings) {
$this->breadcrumb = $settings; $this->breadcrumb = $settings;
} }
} }
...@@ -10,13 +10,11 @@ use Drupal\Component\Utility\Html; ...@@ -10,13 +10,11 @@ use Drupal\Component\Utility\Html;
use Drupal\facets_summary\Entity\FacetsSummary; use Drupal\facets_summary\Entity\FacetsSummary;
use Drupal\facets_summary\FacetsSummaryInterface; use Drupal\facets_summary\FacetsSummaryInterface;
/** /**
* Builds a listing of facet entities. * Builds a listing of facet entities.
*/ */
class FacetListBuilder extends DraggableListBuilder { class FacetListBuilder extends DraggableListBuilder {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
...@@ -137,7 +135,7 @@ class FacetListBuilder extends DraggableListBuilder { ...@@ -137,7 +135,7 @@ class FacetListBuilder extends DraggableListBuilder {
* Builds an array of facet summary for display in the overview. * Builds an array of facet summary for display in the overview.
*/ */
public function buildFacetSummaryRow(FacetsSummaryInterface $entity) { public function buildFacetSummaryRow(FacetsSummaryInterface $entity) {
/** @var \Drupal\facets\FacetInterface $entity */; /** @var \Drupal\facets\FacetInterface $entity */
$facet = $entity; $facet = $entity;
$row = parent::buildRow($entity); $row = parent::buildRow($entity);
return [ return [
...@@ -151,21 +149,21 @@ class FacetListBuilder extends DraggableListBuilder { ...@@ -151,21 +149,21 @@ class FacetListBuilder extends DraggableListBuilder {
'#markup' => 'Facets Summary', '#markup' => 'Facets Summary',
], ],
'title' => [ 'title' => [
'#theme_wrappers' => [ '#theme_wrappers' => [
'container' => [ 'container' => [
'#attributes' => ['class' => 'facets-title'], '#attributes' => ['class' => 'facets-title'],
]
],
'#type' => 'link',
'#title' => $facet->label(),
'#attributes' => [
'class' => ['search-api-title'],
],
'#wrapper_attributes' => [
'colspan' => 2,
], ],
] + $facet->toUrl('edit-form')->toRenderArray(), ],
'oprations' => $row['operations'], '#type' => 'link',
'#title' => $facet->label(),
'#attributes' => [
'class' => ['search-api-title'],
],
'#wrapper_attributes' => [
'colspan' => 2,
],
] + $facet->toUrl('edit-form')->toRenderArray(),
'operations' => $row['operations'],
'#attributes' => [ '#attributes' => [
'title' => $this->t('ID: @name', ['@name' => $facet->id()]), 'title' => $this->t('ID: @name', ['@name' => $facet->id()]),
'class' => [ 'class' => [
...@@ -193,7 +191,7 @@ class FacetListBuilder extends DraggableListBuilder { ...@@ -193,7 +191,7 @@ class FacetListBuilder extends DraggableListBuilder {
'#theme_wrappers' => [ '#theme_wrappers' => [
'container' => [ 'container' => [
'#attributes' => ['class' => 'facets-title'], '#attributes' => ['class' => 'facets-title'],
] ],
], ],
'#type' => 'markup', '#type' => 'markup',
'#markup' => $facet_source['id'], '#markup' => $facet_source['id'],
...@@ -263,7 +261,7 @@ class FacetListBuilder extends DraggableListBuilder { ...@@ -263,7 +261,7 @@ class FacetListBuilder extends DraggableListBuilder {
$form['facets'][$facet->id()]['weight']['#attributes']['class'][] = $subgroup_class; $form['facets'][$facet->id()]['weight']['#attributes']['class'][] = $subgroup_class;
$form['facets'][$facet->id()]['weight']['#delta'] = $delta; $form['facets'][$facet->id()]['weight']['#delta'] = $delta;
} }
elseif ($facet instanceof FacetsSummaryInterface){ elseif ($facet instanceof FacetsSummaryInterface) {
$form['facets'][$facet->id()] = $this->buildFacetSummaryRow($facet); $form['facets'][$facet->id()] = $this->buildFacetSummaryRow($facet);
} }
} }
...@@ -373,4 +371,5 @@ class FacetListBuilder extends DraggableListBuilder { ...@@ -373,4 +371,5 @@ class FacetListBuilder extends DraggableListBuilder {
'lone_facets' => $facets, 'lone_facets' => $facets,
]; ];
} }
} }
...@@ -458,7 +458,7 @@ class DefaultFacetManager { ...@@ -458,7 +458,7 @@ class DefaultFacetManager {
* @return \Drupal\facets\Result\ResultInterface[] * @return \Drupal\facets\Result\ResultInterface[]
* A sorted array of results. * A sorted array of results.
*/ */
protected function sortFacetResults(array $active_sort_processors, $results) { protected function sortFacetResults(array $active_sort_processors, array $results) {
uasort($results, function ($a, $b) use ($active_sort_processors) { uasort($results, function ($a, $b) use ($active_sort_processors) {
$return = 0; $return = 0;
foreach ($active_sort_processors as $sort_processor) { foreach ($active_sort_processors as $sort_processor) {
......
...@@ -42,7 +42,8 @@ interface FacetSourcePluginInterface extends PluginFormInterface, DependentPlugi ...@@ -42,7 +42,8 @@ interface FacetSourcePluginInterface extends PluginFormInterface, DependentPlugi
/** /**
* Returns the path of the facet source, used to build the facet url. * Returns the path of the facet source, used to build the facet url.
* *
* @return string The path. * @return string
* The path.
*/ */
public function getPath(); public function getPath();
......
...@@ -58,7 +58,7 @@ class FacetSourcePluginManager extends DefaultPluginManager { ...@@ -58,7 +58,7 @@ class FacetSourcePluginManager extends DefaultPluginManager {
// Definitions that are based on search api when search api is not enabled // Definitions that are based on search api when search api is not enabled
// should not exist, so make sure we do exactly that, we do this in // should not exist, so make sure we do exactly that, we do this in
// ::findDefinitions because this one is called before the result is saved. // ::findDefinitions because this one is called before the result is saved.
$defs = array_filter($defs, function($item) { $defs = array_filter($defs, function ($item) {
if ($item['id'] === 'search_api' && !$this->moduleHandler->moduleExists('search_api')) { if ($item['id'] === 'search_api' && !$this->moduleHandler->moduleExists('search_api')) {
return FALSE; return FALSE;
} }
......
...@@ -15,7 +15,6 @@ interface SearchApiFacetSourceInterface extends FacetSourcePluginInterface { ...@@ -15,7 +15,6 @@ interface SearchApiFacetSourceInterface extends FacetSourcePluginInterface {
*/ */
public function getIndex(); public function getIndex();
/** /**
* Retrieves the Search API display plugin associated with this facet source. * Retrieves the Search API display plugin associated with this facet source.
* *
...@@ -23,4 +22,5 @@ interface SearchApiFacetSourceInterface extends FacetSourcePluginInterface { ...@@ -23,4 +22,5 @@ interface SearchApiFacetSourceInterface extends FacetSourcePluginInterface {
* The Search API display plugin associated with this facet source. * The Search API display plugin associated with this facet source.
*/ */
public function getDisplay(); public function getDisplay();
} }
...@@ -35,7 +35,17 @@ class FacetCloneForm extends EntityForm { ...@@ -35,7 +35,17 @@ class FacetCloneForm extends EntityForm {
*/ */
protected $displayPluginManager; protected $displayPluginManager;
public function __construct(FacetSourcePluginManager $facetSourcePluginManager, DisplayPluginManager $displayPluginManager,EntityStorageInterface $facetStorage) { /**
* Creates the class.
*
* @param \Drupal\facets\FacetSource\FacetSourcePluginManager $facetSourcePluginManager
* The facet source plugin manager.
* @param \Drupal\search_api\Display\DisplayPluginManager $displayPluginManager
* Search api's display plugin manager.
* @param \Drupal\Core\Entity\EntityStorageInterface $facetStorage
* Entity storage class.
*/
public function __construct(FacetSourcePluginManager $facetSourcePluginManager, DisplayPluginManager $displayPluginManager, EntityStorageInterface $facetStorage) {
$this->facetSourcePluginManager = $facetSourcePluginManager; $this->facetSourcePluginManager = $facetSourcePluginManager;
$this->displayPluginManager = $displayPluginManager; $this->displayPluginManager = $displayPluginManager;
$this->facetStorage = $facetStorage; $this->facetStorage = $facetStorage;
......
...@@ -134,8 +134,8 @@ class FacetSourceEditForm extends EntityForm { ...@@ -134,8 +134,8 @@ class FacetSourceEditForm extends EntityForm {
'#states' => [ '#states' => [
'visible' => [ 'visible' => [
':input[name="breadcrumb[active]"]' => ['checked' => TRUE], ':input[name="breadcrumb[active]"]' => ['checked' => TRUE],
] ],
] ],
]; ];
// The parent's form build method will add a save button. // The parent's form build method will add a save button.
......
...@@ -4,7 +4,6 @@ namespace Drupal\facets\Plugin\facets\facet_source; ...@@ -4,7 +4,6 @@ namespace Drupal\facets\Plugin\facets\facet_source;
use Drupal\Component\Plugin\DependentPluginInterface; use Drupal\Component\Plugin\DependentPluginInterface;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
use Drupal\facets\Exception\InvalidQueryTypeException; use Drupal\facets\Exception\InvalidQueryTypeException;
use Drupal\facets\FacetInterface; use Drupal\facets\FacetInterface;
use Drupal\facets\FacetSource\FacetSourcePluginBase; use Drupal\facets\FacetSource\FacetSourcePluginBase;
......
...@@ -28,14 +28,14 @@ class TestPreQuery extends ProcessorPluginBase implements PreQueryProcessorInter ...@@ -28,14 +28,14 @@ class TestPreQuery extends ProcessorPluginBase implements PreQueryProcessorInter
return [ return [
'test_value' => [ 'test_value' => [
'#type' => 'textfield', '#type' => 'textfield',
] ],
]; ];
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function preQuery(\Drupal\facets\FacetInterface $facet) { public function preQuery(FacetInterface $facet) {
drupal_set_message($this->getConfiguration()['test_value']); drupal_set_message($this->getConfiguration()['test_value']);
} }
......
...@@ -17,6 +17,8 @@ class DummyQuery extends QueryString { ...@@ -17,6 +17,8 @@ class DummyQuery extends QueryString {
/** /**
* A string that separates the filters in the query string. * A string that separates the filters in the query string.
*
* @var string
*/ */
protected $separator = '||'; protected $separator = '||';
......
...@@ -79,7 +79,7 @@ class BreadcrumbIntegrationTest extends FacetsTestBase { ...@@ -79,7 +79,7 @@ class BreadcrumbIntegrationTest extends FacetsTestBase {
* Edit the facet configuration with the given values. * Edit the facet configuration with the given values.
* *
* @param array $config * @param array $config
* The new configuration for the facet * The new configuration for the facet.
*/ */
public function editFacetConfig(array $config = []) { public function editFacetConfig(array $config = []) {
$this->drupalGet('admin/config/search/facets'); $this->drupalGet('admin/config/search/facets');
...@@ -98,8 +98,7 @@ class BreadcrumbIntegrationTest extends FacetsTestBase { ...@@ -98,8 +98,7 @@ class BreadcrumbIntegrationTest extends FacetsTestBase {
* Tests Breadcrumb with the given config. * Tests Breadcrumb with the given config.
*/ */
protected function breadcrumbTest() { protected function breadcrumbTest() {
// Breadcrumb should show Keywords: orange > Type: article, item // Breadcrumb should show Keywords: orange > Type: article, item.
$initial_query = ['search_api_fulltext' => 'foo', 'test_param' => 1]; $initial_query = ['search_api_fulltext' => 'foo', 'test_param' => 1];
$this->drupalGet('search-api-test-fulltext', ['query' => $initial_query]); $this->drupalGet('search-api-test-fulltext', ['query' => $initial_query]);
...@@ -139,4 +138,5 @@ class BreadcrumbIntegrationTest extends FacetsTestBase { ...@@ -139,4 +138,5 @@ class BreadcrumbIntegrationTest extends FacetsTestBase {
public function testNonGroupingIntegration() { public function testNonGroupingIntegration() {
$this->markTestSkipped('Not yet implemented.'); $this->markTestSkipped('Not yet implemented.');
} }
} }
...@@ -107,4 +107,5 @@ class FacetSourceTest extends FacetsTestBase { ...@@ -107,4 +107,5 @@ class FacetSourceTest extends FacetsTestBase {
$this->assertSession()->checkboxChecked('breadcrumb[group]'); $this->assertSession()->checkboxChecked('breadcrumb[group]');
$this->assertSession()->checkboxChecked('breadcrumb[active]'); $this->assertSession()->checkboxChecked('breadcrumb[active]');
} }
} }
...@@ -111,6 +111,7 @@ class DependentFacetProcessorTest extends UnitTestCase { ...@@ -111,6 +111,7 @@ class DependentFacetProcessorTest extends UnitTestCase {
* Provides test cases with data. * Provides test cases with data.
* *
* @return array * @return array
* An array of test data.
*/ */
public function provideNegated() { public function provideNegated() {
return [ return [
......
...@@ -53,7 +53,7 @@ class TranslateEntityProcessorTest extends UnitTestCase { ...@@ -53,7 +53,7 @@ class TranslateEntityProcessorTest extends UnitTestCase {
* *
* @var \Drupal\facets\Result\ResultInterface[] * @var \Drupal\facets\Result\ResultInterface[]
*/ */
protected $original_results; protected $originalResults;
/** /**
* {@inheritdoc} * {@inheritdoc}
...@@ -109,8 +109,8 @@ class TranslateEntityProcessorTest extends UnitTestCase { ...@@ -109,8 +109,8 @@ class TranslateEntityProcessorTest extends UnitTestCase {
->method('getFieldIdentifier') ->method('getFieldIdentifier')
->willReturn('testfield'); ->willReturn('testfield');
$this->original_results = [new Result(2, 2, 5)]; $this->originalResults = [new Result(2, 2, 5)];
$this->facet->setResults($this->original_results); $this->facet->setResults($this->originalResults);
// Mock language manager. // Mock language manager.
$this->languageManager = $this->getMockBuilder(LanguageManagerInterface::class) $this->languageManager = $this->getMockBuilder(LanguageManagerInterface::class)
...@@ -163,14 +163,14 @@ class TranslateEntityProcessorTest extends UnitTestCase { ...@@ -163,14 +163,14 @@ class TranslateEntityProcessorTest extends UnitTestCase {
// Without the processor we expect the id to display. // Without the processor we expect the id to display.
foreach ($expected_results as $key => $expected) { foreach ($expected_results as $key => $expected) {
$this->assertEquals($expected['nid'], $this->original_results[$key]->getRawValue()); $this->assertEquals($expected['nid'], $this->originalResults[$key]->getRawValue());
$this->assertEquals($expected['nid'], $this->original_results[$key]->getDisplayValue()); $this->assertEquals($expected['nid'], $this->originalResults[$key]->getDisplayValue());
} }
// With the processor we expect the title to display. // With the processor we expect the title to display.
/** @var \Drupal\facets\Result\ResultInterface[] $filtered_results */ /** @var \Drupal\facets\Result\ResultInterface[] $filtered_results */
$processor = new TranslateEntityProcessor([], 'translate_entity', [], $this->languageManager, $this->entityTypeManager); $processor = new TranslateEntityProcessor([], 'translate_entity', [], $this->languageManager, $this->entityTypeManager);
$filtered_results = $processor->build($this->facet, $this->original_results); $filtered_results = $processor->build($this->facet, $this->originalResults);
foreach ($expected_results as $key => $expected) { foreach ($expected_results as $key => $expected) {
$this->assertEquals($expected['nid'], $filtered_results[$key]->getRawValue()); $this->assertEquals($expected['nid'], $filtered_results[$key]->getRawValue());
$this->assertEquals($expected['title'], $filtered_results[$key]->getDisplayValue()); $this->assertEquals($expected['title'], $filtered_results[$key]->getDisplayValue());
...@@ -206,13 +206,13 @@ class TranslateEntityProcessorTest extends UnitTestCase { ...@@ -206,13 +206,13 @@ class TranslateEntityProcessorTest extends UnitTestCase {
// Without the processor we expect the id to display. // Without the processor we expect the id to display.
foreach ($expected_results as $key => $expected) { foreach ($expected_results as $key => $expected) {
$this->assertEquals($expected['tid'], $this->original_results[$key]->getRawValue()); $this->assertEquals($expected['tid'], $this->originalResults[$key]->getRawValue());
$this->assertEquals($expected['tid'], $this->original_results[$key]->getDisplayValue()); $this->assertEquals($expected['tid'], $this->originalResults[$key]->getDisplayValue());
} }
/** @var \Drupal\facets\Result\ResultInterface[] $filtered_results */ /** @var \Drupal\facets\Result\ResultInterface[] $filtered_results */
$processor = new TranslateEntityProcessor([], 'translate_entity', [], $this->languageManager, $this->entityTypeManager); $processor = new TranslateEntityProcessor([], 'translate_entity', [], $this->languageManager, $this->entityTypeManager);
$filtered_results = $processor->build($this->facet, $this->original_results); $filtered_results = $processor->build($this->facet, $this->originalResults);
// With the processor we expect the title to display. // With the processor we expect the title to display.
foreach ($expected_results as $key => $expected) { foreach ($expected_results as $key => $expected) {
...@@ -226,7 +226,6 @@ class TranslateEntityProcessorTest extends UnitTestCase { ...@@ -226,7 +226,6 @@ class TranslateEntityProcessorTest extends UnitTestCase {
*/ */
public function testDeletedEntityResults() { public function testDeletedEntityResults() {
// Set original results. // Set original results.
$term_storage = $this->getMock(EntityStorageInterface::class); $term_storage = $this->getMock(EntityStorageInterface::class);
$term_storage->expects($this->any()) $term_storage->expects($this->any())
->method('loadMultiple') ->method('loadMultiple')
...@@ -238,7 +237,7 @@ class TranslateEntityProcessorTest extends UnitTestCase { ...@@ -238,7 +237,7 @@ class TranslateEntityProcessorTest extends UnitTestCase {
// Processor should return nothing (and not throw an exception). // Processor should return nothing (and not throw an exception).
/** @var \Drupal\facets\Result\ResultInterface[] $filtered_results */ /** @var \Drupal\facets\Result\ResultInterface[] $filtered_results */
$processor = new TranslateEntityProcessor([], 'translate_entity', [], $this->languageManager, $this->entityTypeManager); $processor = new TranslateEntityProcessor([], 'translate_entity', [], $this->languageManager, $this->entityTypeManager);
$filtered_results = $processor->build($this->facet, $this->original_results); $filtered_results = $processor->build($this->facet, $this->originalResults);
$this->assertEmpty($filtered_results); $this->assertEmpty($filtered_results);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment