public static function ReusableBlocks::blockContentSubmit in Panopoly Magic 8.2
Submission callback for editing block_content plugins.
Parameters
array $form: The form array.
\Drupal\Core\Form\FormStateInterface $form_state: The form state.
Throws
\Drupal\Core\Entity\EntityStorageException
File
- src/
Alterations/ ReusableBlocks.php, line 210
Class
- ReusableBlocks
- A service for altering some Layout Builder forms to allow reusable blocks.
Namespace
Drupal\panopoly_magic\AlterationsCode
public static function blockContentSubmit(array $form, FormStateInterface $form_state) {
// @todo Remove when https://www.drupal.org/project/drupal/issues/2948549 is closed.
$block_form = NestedArray::getValue($form, $form_state
->getTemporaryValue('block_form_parents'));
/** @var \Drupal\block_content\BlockContentInterface $block_content */
$block_content = $block_form['#block'];
$form_display = EntityFormDisplay::collectRenderDisplay($block_content, 'edit');
$complete_form_state = $form_state instanceof SubformStateInterface ? $form_state
->getCompleteFormState() : $form_state;
$form_display
->extractFormValues($block_content, $block_form, $complete_form_state);
$block_content
->setInfo($form_state
->getValue('label'));
$block_content
->save();
}