Refactor segment filter data to embedded object
[MAILPOET-3177]
This commit is contained in:
committed by
Veljko V
parent
bd63ae508f
commit
40c9f047be
40
lib/Entities/DynamicSegmentFilterData.php
Normal file
40
lib/Entities/DynamicSegmentFilterData.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace MailPoet\Entities;
|
||||
|
||||
use MailPoetVendor\Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* @ORM\Embeddable()
|
||||
*/
|
||||
class DynamicSegmentFilterData {
|
||||
const TYPE_USER_ROLE = 'userRole';
|
||||
const TYPE_EMAIL = 'email';
|
||||
const TYPE_WOOCOMMERCE = 'woocommerce';
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="serialized_array")
|
||||
* @var array|null
|
||||
*/
|
||||
private $filterData;
|
||||
|
||||
public function __construct(array $filterData) {
|
||||
$this->filterData = $filterData;
|
||||
}
|
||||
|
||||
public function getData(): ?array {
|
||||
return $this->filterData;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed|null
|
||||
*/
|
||||
public function getParam(string $name) {
|
||||
return $this->filterData[$name] ?? null;
|
||||
}
|
||||
|
||||
public function getFilterType(): ?string {
|
||||
$filterData = $this->getData();
|
||||
return $filterData['segmentType'] ?? null;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user