You are here

function gutenberg_cloud_gutenberg_blocks_alter in Gutenberg 8.2

Same name and namespace in other branches
  1. 8 modules/gutenberg_cloud/gutenberg_cloud.module \gutenberg_cloud_gutenberg_blocks_alter()

Implements hook_gutenberg_blocks_alter().

File

modules/gutenberg_cloud/gutenberg_cloud.module, line 11
Provides integration with Gutenberg cloud.

Code

function gutenberg_cloud_gutenberg_blocks_alter(array &$js_files_edit, array &$css_files_edit, array &$css_files_view) {
  $cloudBlocksManager = \Drupal::service('gutenberg_cloud.block_manager');
  $blocks = $cloudBlocksManager
    ->loadInstalledBlocks();
  $base_url = $cloudBlocksManager
    ->getCdnUrl();
  foreach ($blocks as $block) {
    if ($block
      ->getEditCss()) {
      $css_files_edit[] = $block
        ->getAssetUrl('edit_css', $base_url);
    }
    if ($block
      ->getViewCss()) {
      $css_files_view[] = $block
        ->getAssetUrl('view_css', $base_url);
    }
    if ($block
      ->getJs()) {
      $js_files_edit[] = $block
        ->getAssetUrl('js', $base_url);
    }
  }
}