Refactor
This commit is contained in:
parent
6466e6a459
commit
88d5d4a126
1 changed files with 13 additions and 8 deletions
|
@ -30,14 +30,7 @@ readonly final class AddRandomCtaToDailyEmail {
|
|||
return;
|
||||
}
|
||||
|
||||
$nodeStorage = $this->entityTypeManager->getStorage('node');
|
||||
$query = $nodeStorage->getQuery();
|
||||
$query->condition('status', NodeInterface::PUBLISHED);
|
||||
$query->condition('type', 'daily_email_cta');
|
||||
$query->accessCheck();
|
||||
$ctaNodes = $nodeStorage->loadMultiple($query->execute());
|
||||
|
||||
$ctas = Ctas::fromNodes($ctaNodes);
|
||||
$ctas = $this->getCtas();
|
||||
|
||||
if ($ctas->isEmpty()) {
|
||||
return;
|
||||
|
@ -46,4 +39,16 @@ readonly final class AddRandomCtaToDailyEmail {
|
|||
$email->set('field_daily_email_cta', $ctas->getRandomCta());
|
||||
}
|
||||
|
||||
private function getCtas(): Ctas {
|
||||
$nodeStorage = $this->entityTypeManager->getStorage('node');
|
||||
$query = $nodeStorage->getQuery();
|
||||
$query->condition('status', NodeInterface::PUBLISHED);
|
||||
$query->condition('type', 'daily_email_cta');
|
||||
$query->accessCheck();
|
||||
|
||||
$ctaNodes = $nodeStorage->loadMultiple($query->execute());
|
||||
|
||||
return Ctas::fromNodes($ctaNodes);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue