You are here

public function N1EDSelfHosted::getSelfHostedConfig in N1ED - Visual editor as CKEditor plugin with Bootstrap support 8.2

File

src/Controller/N1EDSelfHosted.php, line 52

Class

N1EDSelfHosted

Namespace

Drupal\n1ed\Controller

Code

public function getSelfHostedConfig() : array {
  $config = [];
  if ($this
    ->checkSelfHostedFiles()) {
    $plugin_file = file_get_contents($this->plugin_file);
    preg_match('/\\/\\*N1ED-ECO-CONFIG-START\\*\\/(.*?)\\/\\*N1ED-ECO-CONFIG-END\\*\\//s', $plugin_file, $match);
    if ($match[1]) {
      $n1ed_conf = json_decode($match[1], true);
    }
    $arr = [];
    foreach ($this
      ->getPluginsAvailable() as $plugin_name) {
      $arr[] = $plugin_name;
      if ($plugin_name == 'Widgets') {
        array_push($arr, 'CustomTemplates', 'ConfigEditor', 'Include', 'Structure');
      }
      if ($plugin_name == 'BootstrapEditor') {
        array_push($arr, 'BootstrapWidgets', 'BootstrapBlocks', 'BootstrapTheme');
      }
    }
    return [
      'error' => null,
      'data' => [
        'conf' => $n1ed_conf,
        'pluginsAvailable' => $arr,
      ],
    ];
  }
  else {
    return $this
      ->noFilesResponse();
  }
  return $config;
}