You are here

function _chosen_lib_get_chosen_path in Chosen 8.2

Same name and namespace in other branches
  1. 3.0.x modules/chosen_lib/chosen_lib.module \_chosen_lib_get_chosen_path()

Get the location of the chosen library.

Return value

string The location of the library, or FALSE if the library isn't installed.

3 calls to _chosen_lib_get_chosen_path()
ChosenConfigForm::buildForm in src/Form/ChosenConfigForm.php
Chosen configuration form.
chosen_lib_library_info_alter in modules/chosen_lib/chosen_lib.module
Implements hook_library_info_alter().
chosen_requirements in ./chosen.install
Implements hook_requirements().

File

modules/chosen_lib/chosen_lib.module, line 38
General functions and hook implementations.

Code

function _chosen_lib_get_chosen_path() {
  if (function_exists('libraries_get_path')) {
    return libraries_get_path('chosen');
  }

  // The following logic is taken from libraries_get_libraries()
  $searchdir = [];

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

  // Always search libraries.
  $searchdir[] = 'libraries';

  // Also search sites/<domain>/*.
  $searchdir[] = \Drupal::service('site.path') . '/libraries';
  foreach ($searchdir as $dir) {
    if (file_exists($dir . '/chosen/chosen.jquery.min.js') || file_exists($dir . '/chosen/chosen.jquery.js')) {
      return $dir . '/chosen';
    }
  }
  return FALSE;
}