You are here

function _swagger_ui_formatter_is_library_directory in Swagger UI Field Formatter 8.2

Helper function to check where the Swagger UI library is installed.

Parameters

string $library_dir: The directory name which contains the Swagger UI library.

Return value

bool Returns TRUE if the Swagger UI library is installed under the given directory. Returns FALSE otherwise.

1 call to _swagger_ui_formatter_is_library_directory()
_swagger_ui_formatter_get_library_path in ./swagger_ui_formatter.module
Helper function to determine the Swagger UI library path.

File

./swagger_ui_formatter.module, line 104
Main module file for Swagger UI Field Formatter.

Code

function _swagger_ui_formatter_is_library_directory($library_dir) {
  $files_to_check = [
    'package.json',
    'dist/swagger-ui.css',
    'dist/swagger-ui-bundle.js',
    'dist/swagger-ui-standalone-preset.js',
  ];
  foreach ($files_to_check as $file) {
    if (!file_exists(DRUPAL_ROOT . $library_dir . '/' . $file)) {
      return FALSE;
    }
  }
  return TRUE;
}