toggle_editable_fields-8.x-1.x-dev/toggle_editable_fields.install

toggle_editable_fields.install
<?php

/**
 * @file
 * Install, update, and uninstall functions for toggle_editable_fields module.
 */

/**
 * Implements hook_requirements().
 */
function toggle_editable_fields_requirements($phase) {
  $requirements = [];

  // Define the paths to check for the library.
  $library_paths = [
    DRUPAL_ROOT . '/libraries/bootstrap-toggle/js/bootstrap-toggle.min.js',
    \Drupal::service('extension.list.profile')->getPath(\Drupal::installProfile()) . '/libraries/bootstrap-toggle/js/bootstrap-toggle.min.js',
  ];

  // Check if the library exists in any of the defined paths.
  $library_found = FALSE;
  foreach ($library_paths as $path) {
    if (file_exists($path)) {
      $library_found = TRUE;
      break;
    }
  }

  // If the library is not found, add a requirement error.
  if (!$library_found) {
    $requirements['bootstrap_toggle_library'] = [
      'title' => t('Bootstrap Toggle library missing'),
      'description' => t('Bootstrap Toggle requires the bootstrap-toggle.min.js library.
        Download it from <a href=":url" target="_blank">GitHub</a> and place it in the
        libraries folder (/libraries) or in the current profile libraries folder.',
        [':url' => 'https://github.com/minhur/bootstrap-toggle']),
      'severity' => REQUIREMENT_WARNING,
    ];
  }

  return $requirements;
}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc