Skip to content

pkp/pkp-lib#11303 job worker mode locale set issue #11304

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: stable-3_4_0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions classes/mail/Mailable.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ class Mailable extends IlluminateMailable
/** @var string embedded footer of the email */
protected string $footer;

/** @var bool define if email data has been set */
protected bool $isDataSet = false;

public function __construct(array $variables = [])
{
if (!empty($variables)) {
Expand Down Expand Up @@ -236,6 +239,16 @@ public function setData(?string $locale = null): void
}

$this->addFooter($locale); // set the locale for the email footer

$this->isDataSet = true;
}

/**
* return if the data for this email has been set
*/
public function hasDataSet(): bool
{
return $this->isDataSet;
}

/**
Expand Down Expand Up @@ -492,6 +505,7 @@ protected static function getTypeNames(ReflectionType $type): array
}
$isUnion = $type instanceof ReflectionUnionType;
if ($isUnion || $type instanceof ReflectionIntersectionType) {
/** @var ReflectionIntersectionType $type */
$flattenTypes = collect($type->getTypes())
->map(fn ($type) => static::getTypeNames($type))
->flatten();
Expand Down
4 changes: 3 additions & 1 deletion classes/mail/Mailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ public function send($view, array $data = [], $callback = null)
{
if (is_a($view, Mailable::class)) {
/** @var Mailable $view */
$view->setData();
if (!$view->hasDataSet()) {
$view->setData();
}
}

// Application is set to sandbox mode and will sent any emails to log
Expand Down