Add getValue method to Field

[MAILPOET-4191]
This commit is contained in:
John Oleksowicz
2022-04-05 11:54:57 -05:00
committed by Veljko V
parent 69b523171f
commit b2f2f2665c
2 changed files with 8 additions and 3 deletions

View File

@@ -54,6 +54,11 @@ class Field {
return $this->factory;
}
// @phpstan-ignore-next-line - there is no consistent return type
public function getValue() {
return $this->getFactory()();
}
public function getArgs(): array {
return $this->args;
}

View File

@@ -61,14 +61,14 @@ class SendWelcomeEmailAction implements Action {
throw InvalidStateException::create()->withMessage(__('No mailpoet:segment subject provided.', 'mailpoet'));
}
$globalSubscriberStatus = $subscriberSubject->getSubscriberStatusField()->getFactory()();
$globalSubscriberStatus = $subscriberSubject->getSubscriberStatusField()->getValue();
if ($globalSubscriberStatus !== SubscriberEntity::STATUS_SUBSCRIBED) {
throw InvalidStateException::create()->withMessage(__(sprintf("Cannot send a welcome email to a subscriber with a global subscription status of '%s'.", $globalSubscriberStatus), 'mailpoet'));
}
$segmentName = $segmentSubject->getNameField()->getFactory()();
$segmentName = $segmentSubject->getNameField()->getValue();
$idField = $subscriberSubject->getSubscriberIdField();
$subscriberId = $idField->getFactory()();
$subscriberId = $idField->getValue();
if ($subscriberId === null) {
throw NotFoundException::create()->withMessage(__(sprintf("Subscriber with ID '%s' not found.", $subscriberId), 'mailpoet'));
}