You are here

protected function WebformSubmissionLimitBlock::getSourceEntity in Webform 8.5

Same name and namespace in other branches
  1. 6.x src/Plugin/Block/WebformSubmissionLimitBlock.php \Drupal\webform\Plugin\Block\WebformSubmissionLimitBlock::getSourceEntity()

Get the source entity.

Return value

\Drupal\Core\Entity\EntityInterface|bool|null The source entity, NULL the if source entity is not applicable, or FALSE if the source entity is not available.

3 calls to WebformSubmissionLimitBlock::getSourceEntity()
WebformSubmissionLimitBlock::blockAccess in src/Plugin/Block/WebformSubmissionLimitBlock.php
Indicates whether the block should be shown.
WebformSubmissionLimitBlock::getTotal in src/Plugin/Block/WebformSubmissionLimitBlock.php
Get total number of submissions for selected limit type.
WebformSubmissionLimitBlock::getWebform in src/Plugin/Block/WebformSubmissionLimitBlock.php
Get the webform.

File

src/Plugin/Block/WebformSubmissionLimitBlock.php, line 476

Class

WebformSubmissionLimitBlock
Provides a 'Webform submission limit' block.

Namespace

Drupal\webform\Plugin\Block

Code

protected function getSourceEntity() {
  if (!$this->configuration['source_entity']) {
    return NULL;
  }
  if (!isset($this->sourceEntity)) {
    if ($this->configuration['entity_type'] && $this->configuration['entity_id']) {
      $entity_storage = $this->entityTypeManager
        ->getStorage($this->configuration['entity_type']);
      if (!$entity_storage) {
        $this->sourceEntity = FALSE;
      }
      else {
        $this->sourceEntity = $entity_storage
          ->load($this->configuration['entity_id']) ?: FALSE;
      }
    }
    else {
      $this->sourceEntity = $this->requestHandler
        ->getCurrentSourceEntity('webform') ?: FALSE;
    }
  }
  return $this->sourceEntity;
}