You are here

UtilsController.php in Gutenberg 8

Same filename and directory in other branches
  1. 8.2 src/Controller/UtilsController.php

File

src/Controller/UtilsController.php
View source
<?php

namespace Drupal\gutenberg\Controller;

use Symfony\Component\Yaml\Yaml;
use Drupal\Core\Controller\ControllerBase;

/**
 * Utility controller.
 */
class UtilsController extends ControllerBase {

  /**
   * Get blocks settings.
   */
  public static function getBlocksSettings() {
    $settings =& drupal_static(__FUNCTION__);
    if (!isset($settings)) {
      $module_handler = \Drupal::service('module_handler');
      $path = $module_handler
        ->getModule('gutenberg')
        ->getPath();
      $file_path = DRUPAL_ROOT . '/' . $path . '/' . 'gutenberg.blocks.yml';
      if (file_exists($file_path)) {
        $file_contents = file_get_contents($file_path);
        $settings = Yaml::parse($file_contents);
      }
    }
    return $settings;
  }

}

Classes

Namesort descending Description
UtilsController Utility controller.