You are here

private function BalloonPanelPlugin::getLibraryPaths in CKEditor Balloon Panel 8

Same name and namespace in other branches
  1. 2.0.x src/Plugin/CKEditorPlugin/BalloonPanelPlugin.php \Drupal\ckeditor_balloonpanel\Plugin\CKEditorPlugin\BalloonPanelPlugin::getLibraryPaths()

Returns an array of library directories.

Return value

str[] A list of library directories.

1 call to BalloonPanelPlugin::getLibraryPaths()
BalloonPanelPlugin::librariesGetPath in src/Plugin/CKEditorPlugin/BalloonPanelPlugin.php
Gets the path of a library.

File

src/Plugin/CKEditorPlugin/BalloonPanelPlugin.php, line 73

Class

BalloonPanelPlugin
Defines the "balloonpanel" plugin.

Namespace

Drupal\ckeditor_balloonpanel\Plugin\CKEditorPlugin

Code

private function getLibraryPaths() {
  $searchdir = [];
  $config = DrupalKernel::findSitePath(\Drupal::request());

  // Similar to 'modules' and 'themes' directories inside an installation
  // profile, installation profiles may want to place libraries into a
  // 'libraries' directory.
  if ($profile = \Drupal::installProfile()) {
    $profile_path = drupal_get_path('profile', $profile);
    $searchdir[] = "{$profile_path}/libraries";
    $searchdir[] = "{$profile_path}/libraries/ckeditor/plugins";
  }

  // Search sites/all/libraries for backwards-compatibility.
  $searchdir[] = 'sites/all/libraries';
  $searchdir[] = 'sites/all/libraries/ckeditor/plugins';

  // Always search the root 'libraries' directory.
  $searchdir[] = 'libraries';
  $searchdir[] = 'libraries/ckeditor/plugins';

  // Also search sites/<domain>/*.
  $searchdir[] = "{$config}/libraries";
  $searchdir[] = "{$config}/libraries/ckeditor/plugins";

  // Retrieve list of directories.
  $directories = [];
  $nomask = [
    'CVS',
  ];
  foreach ($searchdir as $dir) {
    if (is_dir($dir) && ($handle = opendir($dir))) {
      while (FALSE !== ($file = readdir($handle))) {
        if (!in_array($file, $nomask) && $file[0] != '.') {
          if (is_dir("{$dir}/{$file}")) {
            $directories[$file] = "{$dir}/{$file}";
          }
        }
      }
      closedir($handle);
    }
  }
  return $directories;
}