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

Issue #2896175 by borisson_: Fix phpcs errors

parent e54263e2
......@@ -2,6 +2,7 @@
* @file
* Provides the slider functionality.
*/
(function ($) {
'use strict';
......
......@@ -123,7 +123,7 @@ class SliderIntegrationTest extends FacetsTestBase {
'type' => 'item',
'keywords' => ['orange'],
'category' => 'item_category',
'field_integer' => (bool) $i%2 ? $i : $i+1,
'field_integer' => (bool) $i % 2 ? $i : $i + 1,
])->save();
}
......
......@@ -95,7 +95,7 @@ class DefaultFacetsSummaryManager {
$facets_config = $facets_summary->getFacets();
// Exclude facets which were not selected for this summary.
$facets = array_filter($facets,
function($item) use ($facets_config) {
function ($item) use ($facets_config) {
return (isset($facets_config[$item->id()]));
}
);
......@@ -145,7 +145,7 @@ class DefaultFacetsSummaryManager {
* @return array
* The rendered links to the active facets.
*/
protected function buildResultTree($show_count, $results) {
protected function buildResultTree($show_count, array $results) {
$items = [];
foreach ($results as $result) {
if ($result->isActive()) {
......
......@@ -5,7 +5,6 @@ namespace Drupal\Tests\facets_summary\Functional;
use Drupal\Tests\facets\Functional\FacetsTestBase;
use Drupal\facets_summary\Entity\FacetsSummary;
use Drupal\views\Views;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Tests the overall functionality of the Facets summary admin UI.
......
......@@ -126,4 +126,5 @@ class FacetSource extends ConfigEntityBase implements FacetSourceInterface {
public function setBreadcrumbSettings(array $settings) {
$this->breadcrumb = $settings;
}
}
......@@ -10,13 +10,11 @@ use Drupal\Component\Utility\Html;
use Drupal\facets_summary\Entity\FacetsSummary;
use Drupal\facets_summary\FacetsSummaryInterface;
/**
* Builds a listing of facet entities.
*/
class FacetListBuilder extends DraggableListBuilder {
/**
* {@inheritdoc}
*/
......@@ -137,7 +135,7 @@ class FacetListBuilder extends DraggableListBuilder {
* Builds an array of facet summary for display in the overview.
*/
public function buildFacetSummaryRow(FacetsSummaryInterface $entity) {
/** @var \Drupal\facets\FacetInterface $entity */;
/** @var \Drupal\facets\FacetInterface $entity */
$facet = $entity;
$row = parent::buildRow($entity);
return [
......@@ -154,7 +152,7 @@ class FacetListBuilder extends DraggableListBuilder {
'#theme_wrappers' => [
'container' => [
'#attributes' => ['class' => 'facets-title'],
]
],
],
'#type' => 'link',
'#title' => $facet->label(),
......@@ -165,7 +163,7 @@ class FacetListBuilder extends DraggableListBuilder {
'colspan' => 2,
],
] + $facet->toUrl('edit-form')->toRenderArray(),
'oprations' => $row['operations'],
'operations' => $row['operations'],
'#attributes' => [
'title' => $this->t('ID: @name', ['@name' => $facet->id()]),
'class' => [
......@@ -193,7 +191,7 @@ class FacetListBuilder extends DraggableListBuilder {
'#theme_wrappers' => [
'container' => [
'#attributes' => ['class' => 'facets-title'],
]
],
],
'#type' => 'markup',
'#markup' => $facet_source['id'],
......@@ -263,7 +261,7 @@ class FacetListBuilder extends DraggableListBuilder {
$form['facets'][$facet->id()]['weight']['#attributes']['class'][] = $subgroup_class;
$form['facets'][$facet->id()]['weight']['#delta'] = $delta;
}
elseif ($facet instanceof FacetsSummaryInterface){
elseif ($facet instanceof FacetsSummaryInterface) {
$form['facets'][$facet->id()] = $this->buildFacetSummaryRow($facet);
}
}
......@@ -373,4 +371,5 @@ class FacetListBuilder extends DraggableListBuilder {
'lone_facets' => $facets,
];
}
}
......@@ -458,7 +458,7 @@ class DefaultFacetManager {
* @return \Drupal\facets\Result\ResultInterface[]
* 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) {
$return = 0;
foreach ($active_sort_processors as $sort_processor) {
......
......@@ -42,7 +42,8 @@ interface FacetSourcePluginInterface extends PluginFormInterface, DependentPlugi
/**
* Returns the path of the facet source, used to build the facet url.
*
* @return string The path.
* @return string
* The path.
*/
public function getPath();
......
......@@ -58,7 +58,7 @@ class FacetSourcePluginManager extends DefaultPluginManager {
// 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
// ::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')) {
return FALSE;
}
......
......@@ -15,7 +15,6 @@ interface SearchApiFacetSourceInterface extends FacetSourcePluginInterface {
*/
public function getIndex();
/**
* Retrieves the Search API display plugin associated with this facet source.
*
......@@ -23,4 +22,5 @@ interface SearchApiFacetSourceInterface extends FacetSourcePluginInterface {
* The Search API display plugin associated with this facet source.
*/
public function getDisplay();
}
......@@ -35,7 +35,17 @@ class FacetCloneForm extends EntityForm {
*/
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->displayPluginManager = $displayPluginManager;
$this->facetStorage = $facetStorage;
......
......@@ -134,8 +134,8 @@ class FacetSourceEditForm extends EntityForm {
'#states' => [
'visible' => [
':input[name="breadcrumb[active]"]' => ['checked' => TRUE],
]
]
],
],
];
// The parent's form build method will add a save button.
......
......@@ -4,7 +4,6 @@ namespace Drupal\facets\Plugin\facets\facet_source;
use Drupal\Component\Plugin\DependentPluginInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
use Drupal\facets\Exception\InvalidQueryTypeException;
use Drupal\facets\FacetInterface;
use Drupal\facets\FacetSource\FacetSourcePluginBase;
......
......@@ -28,14 +28,14 @@ class TestPreQuery extends ProcessorPluginBase implements PreQueryProcessorInter
return [
'test_value' => [
'#type' => 'textfield',
]
],
];
}
/**
* {@inheritdoc}
*/
public function preQuery(\Drupal\facets\FacetInterface $facet) {
public function preQuery(FacetInterface $facet) {
drupal_set_message($this->getConfiguration()['test_value']);
}
......
......@@ -17,6 +17,8 @@ class DummyQuery extends QueryString {
/**
* A string that separates the filters in the query string.
*
* @var string
*/
protected $separator = '||';
......
......@@ -79,7 +79,7 @@ class BreadcrumbIntegrationTest extends FacetsTestBase {
* Edit the facet configuration with the given values.
*
* @param array $config
* The new configuration for the facet
* The new configuration for the facet.
*/
public function editFacetConfig(array $config = []) {
$this->drupalGet('admin/config/search/facets');
......@@ -98,8 +98,7 @@ class BreadcrumbIntegrationTest extends FacetsTestBase {
* Tests Breadcrumb with the given config.
*/
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];
$this->drupalGet('search-api-test-fulltext', ['query' => $initial_query]);
......@@ -139,4 +138,5 @@ class BreadcrumbIntegrationTest extends FacetsTestBase {
public function testNonGroupingIntegration() {
$this->markTestSkipped('Not yet implemented.');
}
}
......@@ -107,4 +107,5 @@ class FacetSourceTest extends FacetsTestBase {
$this->assertSession()->checkboxChecked('breadcrumb[group]');
$this->assertSession()->checkboxChecked('breadcrumb[active]');
}
}
......@@ -111,6 +111,7 @@ class DependentFacetProcessorTest extends UnitTestCase {
* Provides test cases with data.
*
* @return array
* An array of test data.
*/
public function provideNegated() {
return [
......
......@@ -53,7 +53,7 @@ class TranslateEntityProcessorTest extends UnitTestCase {
*
* @var \Drupal\facets\Result\ResultInterface[]
*/
protected $original_results;
protected $originalResults;
/**
* {@inheritdoc}
......@@ -109,8 +109,8 @@ class TranslateEntityProcessorTest extends UnitTestCase {
->method('getFieldIdentifier')
->willReturn('testfield');
$this->original_results = [new Result(2, 2, 5)];
$this->facet->setResults($this->original_results);
$this->originalResults = [new Result(2, 2, 5)];
$this->facet->setResults($this->originalResults);
// Mock language manager.
$this->languageManager = $this->getMockBuilder(LanguageManagerInterface::class)
......@@ -163,14 +163,14 @@ class TranslateEntityProcessorTest extends UnitTestCase {
// Without the processor we expect the id to display.
foreach ($expected_results as $key => $expected) {
$this->assertEquals($expected['nid'], $this->original_results[$key]->getRawValue());
$this->assertEquals($expected['nid'], $this->original_results[$key]->getDisplayValue());
$this->assertEquals($expected['nid'], $this->originalResults[$key]->getRawValue());
$this->assertEquals($expected['nid'], $this->originalResults[$key]->getDisplayValue());
}
// With the processor we expect the title to display.
/** @var \Drupal\facets\Result\ResultInterface[] $filtered_results */
$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) {
$this->assertEquals($expected['nid'], $filtered_results[$key]->getRawValue());
$this->assertEquals($expected['title'], $filtered_results[$key]->getDisplayValue());
......@@ -206,13 +206,13 @@ class TranslateEntityProcessorTest extends UnitTestCase {
// Without the processor we expect the id to display.
foreach ($expected_results as $key => $expected) {
$this->assertEquals($expected['tid'], $this->original_results[$key]->getRawValue());
$this->assertEquals($expected['tid'], $this->original_results[$key]->getDisplayValue());
$this->assertEquals($expected['tid'], $this->originalResults[$key]->getRawValue());
$this->assertEquals($expected['tid'], $this->originalResults[$key]->getDisplayValue());
}
/** @var \Drupal\facets\Result\ResultInterface[] $filtered_results */
$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.
foreach ($expected_results as $key => $expected) {
......@@ -226,7 +226,6 @@ class TranslateEntityProcessorTest extends UnitTestCase {
*/
public function testDeletedEntityResults() {
// Set original results.
$term_storage = $this->getMock(EntityStorageInterface::class);
$term_storage->expects($this->any())
->method('loadMultiple')
......@@ -238,7 +237,7 @@ class TranslateEntityProcessorTest extends UnitTestCase {
// Processor should return nothing (and not throw an exception).
/** @var \Drupal\facets\Result\ResultInterface[] $filtered_results */
$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);
}
......
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