-
Notifications
You must be signed in to change notification settings - Fork 690
Expand file tree
/
Copy pathSortingCodeConditionRule.php
More file actions
39 lines (31 loc) · 1.05 KB
/
SortingCodeConditionRule.php
File metadata and controls
39 lines (31 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
declare(strict_types=1);
namespace CraftCms\Cms\Address\Conditions;
use CraftCms\Cms\Address\Elements\Address;
use CraftCms\Cms\Condition\BaseTextConditionRule;
use CraftCms\Cms\Element\Conditions\Contracts\ElementConditionRuleInterface;
use CraftCms\Cms\Element\Contracts\ElementInterface;
use CraftCms\Cms\Element\Queries\AddressQuery;
use CraftCms\Cms\Element\Queries\Contracts\ElementQueryInterface;
use function CraftCms\Cms\t;
class SortingCodeConditionRule extends BaseTextConditionRule implements ElementConditionRuleInterface
{
public function getLabel(): string
{
return t('Sorting Code');
}
public function getExclusiveQueryParams(): array
{
return ['sortingCode'];
}
public function modifyQuery(ElementQueryInterface $query): void
{
/** @var AddressQuery $query */
$query->sortingCode($this->paramValue());
}
public function matchElement(ElementInterface $element): bool
{
/** @var Address $element */
return $this->matchValue($element->sortingCode);
}
}