Skip to content

Commit 264b430

Browse files
committed
Merge remote-tracking branch 'origin/MAUT-11515' into development
2 parents dd246f6 + da13e10 commit 264b430

8 files changed

+23
-13
lines changed

CustomFieldType/AbstractCustomFieldType.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function getTableAlias(): string
6565
/**
6666
* @return mixed[]
6767
*/
68-
public function getOperators(string $context = null): array
68+
public function getOperators(): array
6969
{
7070
return $this->filterOperatorProvider->getAllOperators();
7171
}

CustomFieldType/AbstractMultivalueType.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function getEntityClass(): string
5858
/**
5959
* @return mixed[]
6060
*/
61-
public function getOperators(string $context = null): array
61+
public function getOperators(): array
6262
{
6363
$allOperators = parent::getOperators();
6464
$allowedOperators = array_flip(['empty', '!empty', 'in', '!in']);

CustomFieldType/AbstractTextType.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function getEntityClass(): string
3434
/**
3535
* @return mixed[]
3636
*/
37-
public function getOperators(string $context = null): array
37+
public function getOperators(): array
3838
{
3939
$allOperators = parent::getOperators();
4040
$allowedOperators = array_flip(['=', '!=', 'empty', '!empty', 'like', '!like', 'startsWith', 'endsWith', 'contains']);

CustomFieldType/CustomFieldTypeInterface.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function getTableAlias(): string;
6060
/**
6161
* @return mixed[]
6262
*/
63-
public function getOperators(string $context = null): array;
63+
public function getOperators(): array;
6464

6565
/**
6666
* @return mixed[]

CustomFieldType/DateOperatorTrait.php

+6-4
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,16 @@ public function getOperatorOptions(): array
2323
/**
2424
* @return mixed[]
2525
*/
26-
public function getOperators(string $context = null): array
26+
public function getOperators(): array
2727
{
2828
$allOperators = parent::getOperators();
29-
if ('segment' === $context) {
30-
return $allOperators;
31-
}
3229
$allowedOperators = array_flip(['=', '!=', 'gt', 'gte', 'lt', 'lte', 'empty', '!empty', 'between', '!between', 'inLast', 'inNext']);
3330

3431
return array_intersect_key($allOperators, $allowedOperators);
3532
}
33+
34+
public function getOperatorsForSegment(): array
35+
{
36+
return parent::getOperators();
37+
}
3638
}

CustomFieldType/IntType.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function getOperatorOptions(): array
5858
/**
5959
* @return mixed[]
6060
*/
61-
public function getOperators(string $context = null): array
61+
public function getOperators(): array
6262
{
6363
$allOperators = parent::getOperators();
6464
$allowedOperators = array_flip(['=', '!=', 'gt', 'gte', 'lt', 'lte', 'empty', '!empty', 'between', '!between']);

CustomFieldType/SelectType.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function getSymfonyFormFieldType(): string
3636
/**
3737
* @return mixed[]
3838
*/
39-
public function getOperators(string $context = null): array
39+
public function getOperators(): array
4040
{
4141
$allOperators = parent::getOperators();
4242
$allowedOperators = array_flip(['=', '!=', 'empty', '!empty']);

EventListener/SegmentFiltersChoicesGenerateSubscriber.php

+11-3
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,20 @@ function (CustomObject $customObject) use ($event, $fieldTypes): void {
9191

9292
/** @var CustomField $customField */
9393
foreach ($customObject->getCustomFields()->getIterator() as $customField) {
94-
if ($customField->getType() === $fieldTypes[HiddenType::NAME]) { // We don't want to show hidden types in filter list
94+
if ($customField->getType() === $fieldTypes[HiddenType::NAME]) {
95+
// We don't want to show hidden types in filter list
9596
continue;
9697
}
9798

98-
$context = method_exists($this->typeOperatorProvider, 'getContext') ? $this->typeOperatorProvider->getContext() : '';
99-
$allowedOperators = $customField->getTypeObject()->getOperators($context);
99+
if (method_exists($this->typeOperatorProvider, 'getContext') &&
100+
'segment' === $this->typeOperatorProvider->getContext() &&
101+
method_exists($customField->getTypeObject(), 'getOperatorsForSegment')
102+
) {
103+
$allowedOperators = $customField->getTypeObject()->getOperatorsForSegment();
104+
} else {
105+
$allowedOperators = $customField->getTypeObject()->getOperators();
106+
}
107+
100108
$typeOperators = $this->typeOperatorProvider->getOperatorsForFieldType($customField->getType());
101109
$availableOperators = array_flip($typeOperators);
102110
$operators = array_intersect_key($availableOperators, $allowedOperators);

0 commit comments

Comments
 (0)