-
Notifications
You must be signed in to change notification settings - Fork 28
Open
Description
\Fab\Vidi\Facet\StandardFacet::class inside TCA grid -> facets section work only once.
E.g.:
'facets' => [
\Fab\Vidi\Facet\StandardFacet::class => [
'name' => 'foo',
'label' => 'Foo',
'suggestions' => [
1 => 'Foo 1',
2 => 'Foo 2',
]
],
\Fab\Vidi\Facet\StandardFacet::class => [
'name' => 'bar',
'label' => 'Bar',
'suggestions' => [
1 => 'Bar 1',
2 => 'Bar 2',
]
],
],shows only facet "bar" in a grid.
I think the reason is, that the class name is identical in both cases.
Because of this, the foreach inside Fab\Vidi\Tca\GridService::getFacets() doesn't get it's configuration:
foreach ($this->tca['facets'] as $key => $facetNameOrArray) {
}If this loop would be changed to this, it would be possible to set the className inside the configuration and use different keys:
foreach ($this->tca['facets'] as $key => $facetNameOrArray) {
if (is_array($facetNameOrArray)) {
$className = $facetNameOrArray['className'] ?? $key;
$name = $facetNameOrArray['name'] ?? '';
$label = isset($facetNameOrArray['label'])
? $this->getLanguageService()->sL($facetNameOrArray['label'])
: '';
$suggestions = $facetNameOrArray['suggestions'] ?? [];
$configuration = $facetNameOrArray['configuration'] ?? [];
/** @var FacetInterface $facetObject */
$facetObject = GeneralUtility::makeInstance($className, $name, $label, $suggestions, $configuration);
$this->facets[$facetObject->getName()] = $facetObject;
} else {
$this->facets[$facetNameOrArray] = $this->instantiateStandardFacet($facetNameOrArray);
}
}The TCA configuration has to be changed to this:
'facets' => [
'foo' => [
'className': \Fab\Vidi\Facet\StandardFacet::class
'name' => 'foo',
'label' => 'Foo',
'suggestions' => [
1 => 'Foo 1',
2 => 'Foo 2',
]
],
'bar' => [
'className': \Fab\Vidi\Facet\StandardFacet::class
'name' => 'bar',
'label' => 'Bar',
'suggestions' => [
1 => 'Bar 1',
2 => 'Bar 2',
]
],
],Because of th fallback to $key, if no className is defined, this would be compatible to old settings.
Metadata
Metadata
Assignees
Labels
No labels