protected function EntityLegalDocumentForm::savePublishedVersion in Entity Legal 3.0.x
Return value
$this
File
- src/
Form/ EntityLegalDocumentForm.php, line 473
Class
- EntityLegalDocumentForm
- Base form for contact form edit forms.
Namespace
Drupal\entity_legal\FormCode
protected function savePublishedVersion(array $form, FormStateInterface $form_state) {
$published_version_id = $form_state
->getValue('published_version');
if (!$published_version_id) {
return $this;
}
// Update the published version.
if ($form_state
->get('published_version') && $form_state
->get('published_version') !== $form_state
->getValue('published_version')) {
$storage = $this->entityTypeManager
->getStorage(ENTITY_LEGAL_DOCUMENT_VERSION_ENTITY_NAME);
/** @var \Drupal\entity_legal\EntityLegalDocumentVersionInterface $published_version */
$published_version = $storage
->load($form_state
->getValue('published_version'));
$this->entity
->setPublishedVersion($published_version);
}
return $this;
}