|
1
|
|
|
<?php declare(strict_types=1); |
|
2
|
|
|
|
|
3
|
|
|
namespace Shopware\Core\Checkout\Customer\Rule; |
|
4
|
|
|
|
|
5
|
|
|
use Shopware\Core\Checkout\CheckoutRuleScope; |
|
6
|
|
|
use Shopware\Core\Framework\Rule\Rule; |
|
7
|
|
|
use Shopware\Core\Framework\Rule\RuleComparison; |
|
8
|
|
|
use Shopware\Core\Framework\Rule\RuleConfig; |
|
9
|
|
|
use Shopware\Core\Framework\Rule\RuleConstraints; |
|
10
|
|
|
use Shopware\Core\Framework\Rule\RuleScope; |
|
11
|
|
|
use Shopware\Core\System\Salutation\SalutationDefinition; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* @package business-ops |
|
15
|
|
|
*/ |
|
16
|
|
|
class CustomerSalutationRule extends Rule |
|
17
|
|
|
{ |
|
18
|
|
|
public const RULE_NAME = 'customerSalutation'; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* @internal |
|
22
|
|
|
* |
|
23
|
|
|
* @param list<string>|null $salutationIds |
|
|
|
|
|
|
24
|
|
|
*/ |
|
25
|
|
|
public function __construct(public string $operator = self::OPERATOR_EQ, public ?array $salutationIds = null) |
|
26
|
|
|
{ |
|
27
|
|
|
parent::__construct(); |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
public function getConstraints(): array |
|
31
|
|
|
{ |
|
32
|
|
|
$constraints = [ |
|
33
|
|
|
'operator' => RuleConstraints::uuidOperators(true), |
|
34
|
|
|
]; |
|
35
|
|
|
|
|
36
|
|
|
if ($this->operator === self::OPERATOR_EMPTY) { |
|
37
|
|
|
return $constraints; |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
$constraints['salutationIds'] = RuleConstraints::uuids(); |
|
41
|
|
|
|
|
42
|
|
|
return $constraints; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
public function match(RuleScope $scope): bool |
|
46
|
|
|
{ |
|
47
|
|
|
if (!$scope instanceof CheckoutRuleScope) { |
|
48
|
|
|
return false; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
if (!$customer = $scope->getSalesChannelContext()->getCustomer()) { |
|
52
|
|
|
return RuleComparison::isNegativeOperator($this->operator); |
|
53
|
|
|
} |
|
54
|
|
|
$salutation = $customer->getSalutation(); |
|
55
|
|
|
|
|
56
|
|
|
if ($this->operator === self::OPERATOR_EMPTY) { |
|
57
|
|
|
return $salutation === null; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
if ($salutation === null) { |
|
61
|
|
|
return RuleComparison::isNegativeOperator($this->operator); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
return RuleComparison::uuids([$salutation->getId()], $this->salutationIds, $this->operator); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
public function getConfig(): RuleConfig |
|
68
|
|
|
{ |
|
69
|
|
|
return (new RuleConfig()) |
|
70
|
|
|
->operatorSet(RuleConfig::OPERATOR_SET_STRING, true, true) |
|
71
|
|
|
->entitySelectField('salutationIds', SalutationDefinition::ENTITY_NAME, true, ['labelProperty' => 'displayName']); |
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths