You are here

protected function WebformScheduledEmailManager::getEntities in Webform 8.5

Same name and namespace in other branches
  1. 6.x modules/webform_scheduled_email/src/WebformScheduledEmailManager.php \Drupal\webform_scheduled_email\WebformScheduledEmailManager::getEntities()

Inspects an entity and returns the associates webform, webform submission, and/or source entity.

Parameters

\Drupal\Core\Entity\EntityInterface|null $entity: A webform, webform submission, or source entity.

Return value

array An array containing webform, webform submission, and source entity.

3 calls to WebformScheduledEmailManager::getEntities()
WebformScheduledEmailManager::cronSchedule in modules/webform_scheduled_email/src/WebformScheduledEmailManager.php
Schedule emails.
WebformScheduledEmailManager::cronSend in modules/webform_scheduled_email/src/WebformScheduledEmailManager.php
Sending schedule emails.
WebformScheduledEmailManager::total in modules/webform_scheduled_email/src/WebformScheduledEmailManager.php
Get the total number of scheduled emails.

File

modules/webform_scheduled_email/src/WebformScheduledEmailManager.php, line 815

Class

WebformScheduledEmailManager
Defines the webform scheduled email manager.

Namespace

Drupal\webform_scheduled_email

Code

protected function getEntities(EntityInterface $entity = NULL) {
  $webform = NULL;
  $webform_submission = NULL;
  $source_entity = NULL;
  if ($entity instanceof WebformInterface) {
    $webform = $entity;
  }
  elseif ($entity instanceof WebformSubmissionInterface) {
    $webform_submission = $entity;
    $webform = $webform_submission
      ->getWebform();
  }
  elseif ($entity instanceof EntityInterface) {

    /** @var \Drupal\webform\WebformEntityReferenceManagerInterface $entity_reference_manager */
    $entity_reference_manager = \Drupal::service('webform.entity_reference_manager');
    $source_entity = $entity;
    $webform = $entity_reference_manager
      ->getWebform($source_entity);
  }
  return [
    $webform,
    $webform_submission,
    $source_entity,
  ];
}