You are here

function ace_editor_lib_path in Ace Code Editor 8

Verifies that Ace library is present.

The library is searched in the directory DRUPAL_ROOT/libraries. DRUPAL_ROOT/libraries is recommended for storing external libraries. For preserving backwards compatibility, ace_editor/libraries is also checked.

4 calls to ace_editor_lib_path()
ace_editor_install in ./ace_editor.install
Implements hook_enable().
ace_editor_library_info_alter in ./ace_editor.module
Implements hook_library_info_alter().
ace_editor_library_info_build in ./ace_editor.module
Implements hook_library_info_build().
ace_editor_requirements in ./ace_editor.install
Implements hook_requirements().

File

./ace_editor.module, line 14
This file is used to write hooks that used in the module.

Code

function ace_editor_lib_path() {
  $paths_to_check = [
    '/libraries',
    '/' . drupal_get_path('module', 'ace_editor') . '/libraries/',
    '/' . drupal_get_path('profile', \Drupal::installProfile()) . '/libraries/',
  ];
  foreach ($paths_to_check as $path) {
    if (!is_dir(DRUPAL_ROOT . $path)) {
      continue;
    }
    $found = \Drupal::service('file_system')
      ->scanDirectory(DRUPAL_ROOT . $path, '/^ace\\.js/', [
      'recurse' => TRUE,
    ]);
    if ($found) {
      return substr(preg_replace('/ace\\.js/', '', reset($found)->uri), strlen(DRUPAL_ROOT));
    }
  }
  return FALSE;
}