public function StopIssue::executeMultiple in Simplenews 8
Executes the plugin for an array of objects.
Parameters
array $objects: An array of entities.
Overrides ActionBase::executeMultiple
1 call to StopIssue::executeMultiple()
- StopIssue::execute in src/
Plugin/ Action/ StopIssue.php - Executes the plugin.
File
- src/
Plugin/ Action/ StopIssue.php, line 23
Class
- StopIssue
- Stops a newsletter issue.
Namespace
Drupal\simplenews\Plugin\ActionCode
public function executeMultiple(array $entities) {
foreach ($entities as $node) {
if ($node->simplenews_issue->status == SIMPLENEWS_STATUS_SEND_PENDING) {
// Delete the mail spool entries of this newsletter issue.
$count = \Drupal::service('simplenews.spool_storage')
->deleteMails(array(
'nid' => $node
->id(),
));
// Set newsletter issue to not sent yet.
$node->simplenews_issue->status = SIMPLENEWS_STATUS_SEND_NOT;
$node
->save();
$this
->messenger()
->addMessage(t('Sending of %title was stopped. @count pending email(s) were deleted.', array(
'%title' => $node
->getTitle(),
'@count' => $count,
)));
}
}
}