Commit c71acc1b authored by StryKaizer's avatar StryKaizer Committed by borisson_

Issue #2913244 by borisson_, StryKaizer: Disable boolean processor on non-boolean facets

parent 583eaef6
......@@ -2,6 +2,7 @@
namespace Drupal\facets\Plugin\facets\processor;
use Drupal\Core\TypedData\DataDefinitionInterface;
use Drupal\facets\FacetInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\facets\Processor\BuildProcessorInterface;
......@@ -84,4 +85,17 @@ class BooleanItemProcessor extends ProcessorPluginBase implements BuildProcessor
];
}
/**
* {@inheritdoc}
*/
public function supportsFacet(FacetInterface $facet) {
$data_definition = $facet->getDataDefinition();
$property_definitions = $data_definition->getPropertyDefinitions();
foreach ($property_definitions as $k => $definition) {
if ($definition->getDataType() == "boolean") {
return TRUE;
}};
return FALSE;
}
}
......@@ -703,4 +703,15 @@ class ProcessorIntegrationTest extends FacetsTestBase {
$this->assertNoFacetBlocksAppear();
}
/**
* Tests that processors are hidden when the correct fields aren't there.
*/
public function testHiddenProcessors() {
$facet_id = 'alpaca';
$this->editForm = 'admin/config/search/facets/' . $facet_id . '/edit';
$this->createFacet('Alpaca', $facet_id);
$this->drupalGet($this->editForm);
$this->assertSession()->pageTextNotContains('Boolean item label');
}
}
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