You are here

public static function ReusableBlocks::blockContentValidate in Panopoly Magic 8.2

Validation callback for editing block_content plugins.

Parameters

array $form: The form array.

\Drupal\Core\Form\FormStateInterface $form_state: The form state.

File

src/Alterations/ReusableBlocks.php, line 188

Class

ReusableBlocks
A service for altering some Layout Builder forms to allow reusable blocks.

Namespace

Drupal\panopoly_magic\Alterations

Code

public static function blockContentValidate(array $form, FormStateInterface $form_state) {
  $block_form = $form['block_form'];

  /** @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);
  $form_display
    ->validateFormValues($block_content, $block_form, $complete_form_state);

  // @todo Remove when https://www.drupal.org/project/drupal/issues/2948549 is closed.
  $form_state
    ->setTemporaryValue('block_form_parents', $block_form['#parents']);
}