Commit 2fcccd66 authored by borisson_'s avatar borisson_ Committed by borisson_

Issue #2913247 by borisson_, StryKaizer: Disable Uid to Username processor when not relevant

parent c71acc1b
......@@ -2,6 +2,7 @@
namespace Drupal\facets\Plugin\facets\processor;
use Drupal\Core\TypedData\DataReferenceDefinitionInterface;
use Drupal\facets\FacetInterface;
use Drupal\facets\Processor\BuildProcessorInterface;
use Drupal\facets\Processor\ProcessorPluginBase;
......@@ -39,4 +40,21 @@ class UidToUserNameCallbackProcessor extends ProcessorPluginBase implements Buil
return $usernames;
}
/**
* {@inheritdoc}
*/
public function supportsFacet(FacetInterface $facet) {
$data_definition = $facet->getDataDefinition();
$property_definitions = $data_definition->getPropertyDefinitions();
foreach ($property_definitions as $k => $definition) {
if (
$definition instanceof DataReferenceDefinitionInterface &&
$definition->getDataType() === 'entity_reference' &&
$definition->getTargetDefinition()->getConstraint('EntityType') === "user"
) {
return TRUE;
}};
return FALSE;
}
}
......@@ -712,6 +712,7 @@ class ProcessorIntegrationTest extends FacetsTestBase {
$this->createFacet('Alpaca', $facet_id);
$this->drupalGet($this->editForm);
$this->assertSession()->pageTextNotContains('Boolean item label');
$this->assertSession()->pageTextNotContains('Transform UID to user name');
}
}
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