public function WebformEntityReferenceManager::setUserWebformId in Webform 6.x
Same name and namespace in other branches
- 8.5 src/WebformEntityReferenceManager.php \Drupal\webform\WebformEntityReferenceManager::setUserWebformId()
Set user specified webform for a source entity.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: A fieldable content entity.
string $webform_id: A webform id.
Overrides WebformEntityReferenceManagerInterface::setUserWebformId
File
- src/
WebformEntityReferenceManager.php, line 120
Class
- WebformEntityReferenceManager
- Webform entity reference (field) manager.
Namespace
Drupal\webformCode
public function setUserWebformId(EntityInterface $entity, $webform_id) {
$module = 'webform_' . $entity
->getEntityTypeId();
$uid = $this->currentUser
->id();
$name = $entity
->id();
$values = $this->userData
->get($module, $uid, $name) ?: [];
$values['target_id'] = $webform_id;
$this->userData
->set($module, $uid, $name, $values);
}