You are here

function _phone_international_get_path in International Phone 3.x

Get the location of the intl-tel-input library.

Return value

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

2 calls to _phone_international_get_path()
PhoneInternationalElement::processInternationalPhone in src/Element/PhoneInternationalElement.php
Add tel and hidden input to phone_international element.
phone_international_library_info_alter in ./phone_international.module
Implements hook_library_info_alter().

File

./phone_international.module, line 76
Contains phone_international.module.

Code

function _phone_international_get_path() {
  if (function_exists('libraries_get_path')) {
    return libraries_get_path('intl-tel-input');
  }

  // 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 . '/intl-tel-input/build/js/intlTelInput.min.js') || file_exists($dir . '/intl-tel-input/build/js/intlTelInput.js')) {
      return $dir . '/intl-tel-input/build';
    }
  }
  return FALSE;
}