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,
|
||||
{
|
||||
key: string;
|
||||
type: 'string' | 'enum_array';
|
||||
type: 'boolean' | 'number' | 'integer' | 'string' | 'enum' | 'enum_array';
|
||||
name: string;
|
||||
args: Record<string, unknown>;
|
||||
}
|
||||
|
@@ -7,9 +7,11 @@ use MailPoet\Automation\Engine\Integration\Payload;
|
||||
class Field {
|
||||
public const TYPE_BOOLEAN = 'boolean';
|
||||
public const TYPE_INTEGER = 'integer';
|
||||
public const TYPE_NUMBER = 'number';
|
||||
public const TYPE_STRING = 'string';
|
||||
public const TYPE_ENUM = 'enum';
|
||||
public const TYPE_ENUM_ARRAY = 'enum_array';
|
||||
public const TYPE_DATETIME = 'datetime';
|
||||
|
||||
/** @var string */
|
||||
private $key;
|
||||
|
@@ -8,6 +8,7 @@ use MailPoet\Automation\Engine\Integration\Payload;
|
||||
use MailPoet\Automation\Engine\Integration\Subject;
|
||||
use MailPoet\Automation\Integrations\MailPoet\Payloads\SubscriberPayload;
|
||||
use MailPoet\Entities\SegmentEntity;
|
||||
use MailPoet\Entities\SubscriberEntity;
|
||||
use MailPoet\NotFoundException;
|
||||
use MailPoet\Segments\SegmentsFinder;
|
||||
use MailPoet\Segments\SegmentsRepository;
|
||||
@@ -67,16 +68,6 @@ class SubscriberSubject implements Subject {
|
||||
/** @return Field[] */
|
||||
public function getFields(): array {
|
||||
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(
|
||||
'mailpoet:subscriber:email',
|
||||
Field::TYPE_STRING,
|
||||
@@ -85,6 +76,22 @@ class SubscriberSubject implements Subject {
|
||||
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(
|
||||
'mailpoet:subscriber:status',
|
||||
Field::TYPE_ENUM,
|
||||
@@ -94,14 +101,25 @@ class SubscriberSubject implements Subject {
|
||||
},
|
||||
[
|
||||
'options' => [
|
||||
SubscriberEntity::STATUS_SUBSCRIBED => __('Subscribed', 'mailpoet'),
|
||||
SubscriberEntity::STATUS_UNCONFIRMED => __('Unconfirmed', 'mailpoet'),
|
||||
SubscriberEntity::STATUS_UNSUBSCRIBED => __('Unsubscribed', 'mailpoet'),
|
||||
SubscriberEntity::STATUS_BOUNCED => __('Bounced', 'mailpoet'),
|
||||
[
|
||||
'id' => SubscriberEntity::STATUS_SUBSCRIBED,
|
||||
'name' => __('Subscribed', 'mailpoet'),
|
||||
],
|
||||
[
|
||||
'id' => SubscriberEntity::STATUS_UNCONFIRMED,
|
||||
'name' => __('Unconfirmed', 'mailpoet'),
|
||||
],
|
||||
[
|
||||
'id' => SubscriberEntity::STATUS_UNSUBSCRIBED,
|
||||
'name' => __('Unsubscribed', 'mailpoet'),
|
||||
],
|
||||
[
|
||||
'id' => SubscriberEntity::STATUS_BOUNCED,
|
||||
'name' => __('Bounced', 'mailpoet'),
|
||||
],
|
||||
],
|
||||
]
|
||||
),
|
||||
*/
|
||||
new Field(
|
||||
'mailpoet:subscriber:segments',
|
||||
Field::TYPE_ENUM_ARRAY,
|
||||
@@ -123,6 +141,14 @@ class SubscriberSubject implements Subject {
|
||||
}, $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