You are here

public function BlocksRendererHelper::getBlockFromPluginId in Gutenberg 8

Same name and namespace in other branches
  1. 8.2 src/BlocksRendererHelper.php \Drupal\gutenberg\BlocksRendererHelper::getBlockFromPluginId()

Create instance of block plugin from given ID and config.

Parameters

string $id: Block Plugin ID.

array $config: Block configuration.

Return value

object|null Block Plugin instance or null.

File

src/BlocksRendererHelper.php, line 69

Class

BlocksRendererHelper
Class BlocksRendererHelper.

Namespace

Drupal\gutenberg

Code

public function getBlockFromPluginId($id, array $config = []) {
  try {
    return $this->blockManager
      ->createInstance($id, $config);
  } catch (PluginException $e) {
    return NULL;
  }
}