You are here

protected function ReusableBlocksController::getBlockAttributes in Gutenberg 8.2

Get the block as a response array.

Parameters

\Drupal\block_content\BlockContentInterface $block: The block instance.

Return value

array The block response array.

2 calls to ReusableBlocksController::getBlockAttributes()
ReusableBlocksController::load in src/Controller/ReusableBlocksController.php
Returns JSON representing the loaded blocks.
ReusableBlocksController::save in src/Controller/ReusableBlocksController.php
Saves reusable block.

File

src/Controller/ReusableBlocksController.php, line 213

Class

ReusableBlocksController
Returns responses for our blocks routes.

Namespace

Drupal\gutenberg\Controller

Code

protected function getBlockAttributes(BlockContentInterface $block) {
  return [
    'id' => (int) $block
      ->id(),
    'title' => [
      'raw' => (string) $block
        ->get('info')->value,
    ],
    'content' => [
      'block_version' => 1,
      'raw' => (string) $block
        ->get('body')->value,
    ],
    'type' => 'wp_block',
    'status' => 'publish',
    'slug' => 'reusable_block_' . $block
      ->id(),
  ];
}