public function WebformEntityInjectionTrait::setEntities in Webform 6.x
Same name and namespace in other branches
- 8.5 src/Plugin/WebformEntityInjectionTrait.php \Drupal\webform\Plugin\WebformEntityInjectionTrait::setEntities()
1 call to WebformEntityInjectionTrait::setEntities()
- WebformElementBase::prepare in src/
Plugin/ WebformElementBase.php - Prepare an element to be rendered within a webform.
File
- src/
Plugin/ WebformEntityInjectionTrait.php, line 79
Class
- WebformEntityInjectionTrait
- Provides an webform/webform submission entity inject trait.
Namespace
Drupal\webform\PluginCode
public function setEntities(EntityInterface $entity) {
if ($entity instanceof WebformInterface) {
$this->webform = $entity;
$this->webformSubmission = NULL;
}
elseif ($entity instanceof WebformSubmissionInterface) {
$this->webform = $entity
->getWebform();
$this->webformSubmission = $entity;
}
else {
throw new \Exception('Entity type must be a webform or webform submission');
}
return $this;
}