public function CoreViewsContextualFilter::getDataDefinition in Core Views Facets 8
Throws
\Drupal\facets\Exception\Exception
Overrides CoreViewsFacetSourceBase::getDataDefinition
File
- src/
Plugin/ facets/ facet_source/ CoreViewsContextualFilter.php, line 276
Class
- CoreViewsContextualFilter
- Represents a facet source of the core views with contextual filters.
Namespace
Drupal\core_views_facets\Plugin\facets\facet_sourceCode
public function getDataDefinition($field_name) {
$this->view
->build($this->pluginDefinition['view_display']);
$definition = $this->view->argument[$field_name]->definition;
$original_field_name = $this
->getOriginalFieldName($definition);
$field_definition = $this->entityFieldManager
->getFieldStorageDefinitions($definition['entity_type']);
if (isset($field_definition[$original_field_name])) {
$property_definitions = $field_definition[$original_field_name]
->getPropertyDefinitions();
$field_type = $field_definition[$original_field_name]
->getType();
foreach ($property_definitions as $property_definition) {
if ($field_type === $property_definition
->getDataType()) {
return $property_definition;
}
}
}
throw new Exception("Field with name {$field_name} does not have a definition");
}