Add one field for each new filter type (number, integer, boolean, string)
[MAILPOET-4624] [MAILPOET-5001] [MAILPOET-5187]
This commit is contained in:
@@ -36,7 +36,7 @@ export type Registry = {
|
|||||||
string,
|
string,
|
||||||
{
|
{
|
||||||
key: string;
|
key: string;
|
||||||
type: 'string' | 'enum_array';
|
type: 'boolean' | 'number' | 'integer' | 'string' | 'enum' | 'enum_array';
|
||||||
name: string;
|
name: string;
|
||||||
args: Record<string, unknown>;
|
args: Record<string, unknown>;
|
||||||
}
|
}
|
||||||
|
@@ -7,9 +7,11 @@ use MailPoet\Automation\Engine\Integration\Payload;
|
|||||||
class Field {
|
class Field {
|
||||||
public const TYPE_BOOLEAN = 'boolean';
|
public const TYPE_BOOLEAN = 'boolean';
|
||||||
public const TYPE_INTEGER = 'integer';
|
public const TYPE_INTEGER = 'integer';
|
||||||
|
public const TYPE_NUMBER = 'number';
|
||||||
public const TYPE_STRING = 'string';
|
public const TYPE_STRING = 'string';
|
||||||
public const TYPE_ENUM = 'enum';
|
public const TYPE_ENUM = 'enum';
|
||||||
public const TYPE_ENUM_ARRAY = 'enum_array';
|
public const TYPE_ENUM_ARRAY = 'enum_array';
|
||||||
|
public const TYPE_DATETIME = 'datetime';
|
||||||
|
|
||||||
/** @var string */
|
/** @var string */
|
||||||
private $key;
|
private $key;
|
||||||
|
@@ -8,6 +8,7 @@ use MailPoet\Automation\Engine\Integration\Payload;
|
|||||||
use MailPoet\Automation\Engine\Integration\Subject;
|
use MailPoet\Automation\Engine\Integration\Subject;
|
||||||
use MailPoet\Automation\Integrations\MailPoet\Payloads\SubscriberPayload;
|
use MailPoet\Automation\Integrations\MailPoet\Payloads\SubscriberPayload;
|
||||||
use MailPoet\Entities\SegmentEntity;
|
use MailPoet\Entities\SegmentEntity;
|
||||||
|
use MailPoet\Entities\SubscriberEntity;
|
||||||
use MailPoet\NotFoundException;
|
use MailPoet\NotFoundException;
|
||||||
use MailPoet\Segments\SegmentsFinder;
|
use MailPoet\Segments\SegmentsFinder;
|
||||||
use MailPoet\Segments\SegmentsRepository;
|
use MailPoet\Segments\SegmentsRepository;
|
||||||
@@ -67,16 +68,6 @@ class SubscriberSubject implements Subject {
|
|||||||
/** @return Field[] */
|
/** @return Field[] */
|
||||||
public function getFields(): array {
|
public function getFields(): array {
|
||||||
return [
|
return [
|
||||||
// phpcs:disable Squiz.PHP.CommentedOutCode.Found -- temporarily hide those fields
|
|
||||||
/*
|
|
||||||
new Field(
|
|
||||||
'mailpoet:subscriber:id',
|
|
||||||
Field::TYPE_INTEGER,
|
|
||||||
__('Subscriber ID', 'mailpoet'),
|
|
||||||
function (SubscriberPayload $payload) {
|
|
||||||
return $payload->getId();
|
|
||||||
}
|
|
||||||
),
|
|
||||||
new Field(
|
new Field(
|
||||||
'mailpoet:subscriber:email',
|
'mailpoet:subscriber:email',
|
||||||
Field::TYPE_STRING,
|
Field::TYPE_STRING,
|
||||||
@@ -85,6 +76,22 @@ class SubscriberSubject implements Subject {
|
|||||||
return $payload->getEmail();
|
return $payload->getEmail();
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
|
new Field(
|
||||||
|
'mailpoet:subscriber:engagement-score',
|
||||||
|
Field::TYPE_NUMBER,
|
||||||
|
__('Engagement score', 'mailpoet'),
|
||||||
|
function (SubscriberPayload $payload) {
|
||||||
|
return $payload->getSubscriber()->getEngagementScore();
|
||||||
|
}
|
||||||
|
),
|
||||||
|
new Field(
|
||||||
|
'mailpoet:subscriber:is-globally-subscribed',
|
||||||
|
Field::TYPE_BOOLEAN,
|
||||||
|
__('Is globally subscribed', 'mailpoet'),
|
||||||
|
function (SubscriberPayload $payload) {
|
||||||
|
return $payload->getStatus() === SubscriberEntity::STATUS_SUBSCRIBED;
|
||||||
|
}
|
||||||
|
),
|
||||||
new Field(
|
new Field(
|
||||||
'mailpoet:subscriber:status',
|
'mailpoet:subscriber:status',
|
||||||
Field::TYPE_ENUM,
|
Field::TYPE_ENUM,
|
||||||
@@ -94,14 +101,25 @@ class SubscriberSubject implements Subject {
|
|||||||
},
|
},
|
||||||
[
|
[
|
||||||
'options' => [
|
'options' => [
|
||||||
SubscriberEntity::STATUS_SUBSCRIBED => __('Subscribed', 'mailpoet'),
|
[
|
||||||
SubscriberEntity::STATUS_UNCONFIRMED => __('Unconfirmed', 'mailpoet'),
|
'id' => SubscriberEntity::STATUS_SUBSCRIBED,
|
||||||
SubscriberEntity::STATUS_UNSUBSCRIBED => __('Unsubscribed', 'mailpoet'),
|
'name' => __('Subscribed', 'mailpoet'),
|
||||||
SubscriberEntity::STATUS_BOUNCED => __('Bounced', 'mailpoet'),
|
],
|
||||||
|
[
|
||||||
|
'id' => SubscriberEntity::STATUS_UNCONFIRMED,
|
||||||
|
'name' => __('Unconfirmed', 'mailpoet'),
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'id' => SubscriberEntity::STATUS_UNSUBSCRIBED,
|
||||||
|
'name' => __('Unsubscribed', 'mailpoet'),
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'id' => SubscriberEntity::STATUS_BOUNCED,
|
||||||
|
'name' => __('Bounced', 'mailpoet'),
|
||||||
|
],
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
*/
|
|
||||||
new Field(
|
new Field(
|
||||||
'mailpoet:subscriber:segments',
|
'mailpoet:subscriber:segments',
|
||||||
Field::TYPE_ENUM_ARRAY,
|
Field::TYPE_ENUM_ARRAY,
|
||||||
@@ -123,6 +141,14 @@ class SubscriberSubject implements Subject {
|
|||||||
}, $this->segmentsRepository->findBy(['type' => SegmentEntity::TYPE_DYNAMIC])),
|
}, $this->segmentsRepository->findBy(['type' => SegmentEntity::TYPE_DYNAMIC])),
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
|
new Field(
|
||||||
|
'mailpoet:subscriber:email-sent-count',
|
||||||
|
Field::TYPE_INTEGER,
|
||||||
|
__('Email — sent count', 'mailpoet'),
|
||||||
|
function (SubscriberPayload $payload) {
|
||||||
|
return $payload->getSubscriber()->getEmailCount();
|
||||||
|
}
|
||||||
|
),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user