function EntityFormWizardBase::initValues
Same name in other branches
- 4.0.x src/Wizard/EntityFormWizardBase.php \Drupal\ctools\Wizard\EntityFormWizardBase::initValues()
Overrides FormWizardBase::initValues
File
-
src/
Wizard/ EntityFormWizardBase.php, line 74
Class
- EntityFormWizardBase
- The base class for all entity form wizards.
Namespace
Drupal\ctools\WizardCode
public function initValues() {
$storage = $this->entityTypeManager
->getStorage($this->getEntityType());
if ($this->getMachineName()) {
$values = $this->getTempstore()
->get($this->getMachineName());
if (!$values) {
$entity = $storage->load($this->getMachineName());
$values[$this->getEntityType()] = $entity;
$values['id'] = $entity->id();
$values['label'] = $entity->label();
}
}
else {
$entity = $storage->create([]);
$values[$this->getEntityType()] = $entity;
}
$event = new WizardEvent($this, $values);
$this->dispatcher
->dispatch($event, FormWizardInterface::LOAD_VALUES);
return $event->getValues();
}