Add getter for operator
[MAILPOET-3954]
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace MailPoet\Entities;
|
||||
|
||||
use MailPoet\Segments\DynamicSegments\Filters\UserRole;
|
||||
use MailPoet\Segments\DynamicSegments\Filters\WooCommerceProduct;
|
||||
use MailPoetVendor\Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
@@ -17,9 +18,9 @@ class DynamicSegmentFilterData {
|
||||
public const CONNECT_TYPE_AND = 'and';
|
||||
public const CONNECT_TYPE_OR = 'or';
|
||||
|
||||
const OPERATOR_ANY = 'any';
|
||||
const OPERATOR_ALL = 'all';
|
||||
const OPERATOR_NONE = 'none';
|
||||
public const OPERATOR_ALL = 'all';
|
||||
public const OPERATOR_ANY = 'any';
|
||||
public const OPERATOR_NONE = 'none';
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="serialized_array")
|
||||
@@ -79,4 +80,20 @@ class DynamicSegmentFilterData {
|
||||
}
|
||||
return $this->filterData['action'] ?? null;
|
||||
}
|
||||
|
||||
public function getOperator(): ?string {
|
||||
$operator = $this->filterData['operator'] ?? null;
|
||||
if (!$operator) {
|
||||
return $this->getDefaultOperator();
|
||||
}
|
||||
|
||||
return $operator;
|
||||
}
|
||||
|
||||
private function getDefaultOperator(): ?string {
|
||||
if ($this->getFilterType() === self::TYPE_WOOCOMMERCE && $this->getAction() === WooCommerceProduct::ACTION_PRODUCT) {
|
||||
return self::OPERATOR_ANY;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user