Commit 17a26cda authored by gbyte.co's avatar gbyte.co Committed by gbyte.co

Issue #3080510 by jnicola, gbyte.co: Assertion error on multi-step form node creation

parent a6252df3
......@@ -113,21 +113,16 @@ function simple_sitemap_entity_form_submit($form, FormStateInterface &$form_stat
switch ($f->getEntityCategory()) {
case 'bundle':
$generator->setBundleSettings($f->getEntityTypeId(),
!empty($f->getBundleName()) ? $f->getBundleName() : $f->getFormEntityId(),
$settings
);
$generator->setBundleSettings($f->getEntityTypeId(), $f->getBundleName(), $settings);
if (empty($settings['index'])) {
$generator->removeEntityInstanceSettings($f->getEntityTypeId(), $f->getInstanceId());
}
break;
case 'instance':
$generator->setEntityInstanceSettings($f->getEntityTypeId(),
!empty($f->getInstanceId()) ? $f->getInstanceId() : $f->getFormEntityId(),
$settings
);
if (!$f->entityIsNew()) {
$generator->setEntityInstanceSettings($f->getEntityTypeId(), $f->getInstanceId(), $settings);
}
break;
}
}
......
......@@ -223,6 +223,13 @@ class FormHelper {
return TRUE;
}
/**
* @return bool
*/
public function entityIsNew() {
return !empty($entity = $this->getFormEntity()) ? $entity->isNew() : TRUE;
}
/**
* @param array $form_fragment
* @return $this
......@@ -408,7 +415,7 @@ class FormHelper {
$this->setEntityTypeId($entity_type_id);
$this->setBundleName($this->entityHelper->getEntityInstanceBundleName($form_entity));
// New menu link's id is '' instead of NULL, hence checking for empty.
$this->setInstanceId(!$form_entity->isNew() && !empty($form_entity->id()) ? $form_entity->id() : NULL);
$this->setInstanceId(!$this->entityIsNew() ? $form_entity->id() : NULL);
break;
default:
......@@ -432,6 +439,7 @@ class FormHelper {
&& in_array($form_object->getOperation(), self::$allowedFormOperations)) {
return $form_object->getEntity();
}
return FALSE;
}
......@@ -453,17 +461,6 @@ class FormHelper {
return $this;
}
/**
* Gets new entity Id after entity creation.
* To be used in an entity form submit.
*
* @return int
* Entity ID.
*/
public function getFormEntityId() {
return $this->formState->getFormObject()->getEntity()->id();
}
/**
* Checks if simple_sitemap values have been changed after submitting the form.
* To be used in an entity form submit.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment