You are here

private function CkeditorTemplates::getTemplatesDefaultPath in CKEditor Templates 8

Generate the path to the template file.

The file will be picked from :

  • the default theme if the file exists
  • the ckeditor template directory otherwise.

Return value

array List of path to the template file

1 call to CkeditorTemplates::getTemplatesDefaultPath()
CkeditorTemplates::getConfig in src/Plugin/CKEditorPlugin/CkeditorTemplates.php
Returns the additions to CKEDITOR.config for a specific CKEditor instance.

File

src/Plugin/CKEditorPlugin/CkeditorTemplates.php, line 167

Class

CkeditorTemplates
Defines the "Templates" plugin.

Namespace

Drupal\ckeditor_templates\Plugin\CKEditorPlugin

Code

private function getTemplatesDefaultPath() {

  // Default to module folder.
  $defaultPath = base_path() . $this
    ->getTemplatesPluginPath() . '/templates/default.js';

  // Get site default theme name.
  $defaultThemConfig = $this->configFactoryService
    ->get('system.theme');
  $defaultThemeName = $defaultThemConfig
    ->get('default');
  $defaultThemeFileAbsolutePath = DRUPAL_ROOT . '/' . drupal_get_path('theme', $defaultThemeName) . '/templates/ckeditor_templates.js';
  if (file_exists($defaultThemeFileAbsolutePath)) {
    $defaultPath = base_path() . drupal_get_path('theme', $defaultThemeName) . '/templates/ckeditor_templates.js';
  }
  return [
    $defaultPath,
  ];
}