You are here

protected function CloudBlock::mapFromBlock in Gutenberg 8.2

Same name and namespace in other branches
  1. 8 modules/gutenberg_cloud/src/CloudBlock.php \Drupal\gutenberg_cloud\CloudBlock::mapFromBlock()

Map the API block to CloudBlock properties.

Parameters

object $block: Cloud Block from API.

1 call to CloudBlock::mapFromBlock()
CloudBlock::__construct in modules/gutenberg_cloud/src/CloudBlock.php
CloudBlock constructor.

File

modules/gutenberg_cloud/src/CloudBlock.php, line 81

Class

CloudBlock
Class CloudBlock.

Namespace

Drupal\gutenberg_cloud

Code

protected function mapFromBlock(\stdClass $block) {
  $structure = [
    'name' => $block->name,
    'version' => $block->version,
    'label' => $block->config->name,
    'description' => $block->package->description,
    'js' => $block->config->js ?? NULL,
    'screenshot' => $block->config->screenshot ?? NULL,
    'edit_css' => $block->config->editor ?? NULL,
    'view_css' => $block->config->css ?? NULL,
    'raw' => $block,
  ];
  $this
    ->setConfig($structure);
}