diff --git a/src/Plugin/Block/ContentEmbedBlock.php b/src/Plugin/Block/ContentEmbedBlock.php index e03c717..20281de 100644 --- a/src/Plugin/Block/ContentEmbedBlock.php +++ b/src/Plugin/Block/ContentEmbedBlock.php @@ -5,6 +5,7 @@ namespace Drupal\content_browser\Plugin\Block; use Drupal\Component\Utility\NestedArray; use Drupal\Core\Block\BlockBase; use Drupal\Core\Form\FormStateInterface; +use Drupal\Core\Form\SubformStateInterface; use Drupal\node\Entity\Node; /** @@ -47,6 +48,16 @@ class ContentEmbedBlock extends BlockBase { * {@inheritdoc} */ public function blockForm($form, FormStateInterface $form_state) { + // This method receives a sub form state instead of the full form state. + // There is an ongoing discussion around this which could result in the + // passed form state going back to a full form state. In order to prevent + // future breakage because of a core update we'll just check which type of + // FormStateInterface we've been passed and act accordingly. + // @See https://www.drupal.org/node/2798261 + if ($form_state instanceof SubformStateInterface) { + $form_state = $form_state->getCompleteFormState(); + } + $entities = $form_state->getValue([ 'settings', 'selection',