You are here

protected function FormEntityHelperTrait::getBlockContent in Block Style Plugins 8.2

Get the Block Content entity.

Parameters

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

Return value

\Drupal\block_content\Entity\BlockContent The Block Content entity.

1 call to FormEntityHelperTrait::getBlockContent()
FormEntityHelperTrait::getBlockContentBundle in src/FormEntityHelperTrait.php
Get the block content bundle type.

File

src/FormEntityHelperTrait.php, line 67

Class

FormEntityHelperTrait
Provides a helper for getting information from the entity being styled.

Namespace

Drupal\block_style_plugins

Code

protected function getBlockContent(FormStateInterface $form_state) {

  // Get the current block config entity.
  $entity = $this
    ->getBlockConfigEntityFromFormState($form_state);

  /** @var \Drupal\Core\Block\BlockPluginInterface */
  $block_plugin = $entity
    ->getPlugin();
  $base_id = $block_plugin
    ->getBaseId();
  $uuid = $block_plugin
    ->getDerivativeId();
  $block_content = NULL;
  if ($base_id == 'block_content') {
    $block_content = $this
      ->getEntityRepository()
      ->loadEntityByUuid('block_content', $uuid);
  }
  return $block_content;
}