You are here

private function A11yCheckerPlugin::getLibraryPaths in CKEditor Accessibility Checker 8

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

Returns an array of library directories.

Return value

str[] A list of library directories.

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

File

src/Plugin/CKEditorPlugin/A11yCheckerPlugin.php, line 94

Class

A11yCheckerPlugin
Defines the "a11ychecker" plugin.

Namespace

Drupal\ckeditor_a11ychecker\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;
}