protected function WebformSubmissionLimitBlock::getWebform in Webform 8.5
Same name and namespace in other branches
- 6.x src/Plugin/Block/WebformSubmissionLimitBlock.php \Drupal\webform\Plugin\Block\WebformSubmissionLimitBlock::getWebform()
Get the webform.
Return value
\Drupal\webform\WebformInterface|bool The webform or FALSE if the webform is not available.
3 calls to WebformSubmissionLimitBlock::getWebform()
- 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::replaceTokens in src/
Plugin/ Block/ WebformSubmissionLimitBlock.php - Replace tokens in text.
File
- src/
Plugin/ Block/ WebformSubmissionLimitBlock.php, line 438
Class
- WebformSubmissionLimitBlock
- Provides a 'Webform submission limit' block.
Namespace
Drupal\webform\Plugin\BlockCode
protected function getWebform() {
if (isset($this->webform)) {
return $this->webform;
}
if ($this->configuration['webform_id']) {
$this->webform = Webform::load($this->configuration['webform_id']) ?: FALSE;
}
else {
$this->webform = $this->requestHandler
->getCurrentWebform() ?: FALSE;
}
// Apply overridden settings to the webform which requires
// a temp webform submission.
if ($this->webform) {
/** @var \Drupal\webform\WebformSubmissionStorageInterface $webform_submission_storage */
$webform_submission_storage = $this->entityTypeManager
->getStorage('webform_submission');
$values = [
'webform_id' => $this
->getWebform()
->id(),
];
if ($source_entity = $this
->getSourceEntity()) {
$values += [
'entity_type' => $source_entity
->getEntityTypeId(),
'entity_id' => $source_entity
->id(),
];
}
$temp_webform_submission = $webform_submission_storage
->create($values);
$this->webform
->invokeHandlers('overrideSettings', $temp_webform_submission);
}
return $this->webform;
}