You are here

function _libraries_test_callback in Libraries API 8.3

Sets the '[group] callback' key, where [group] is prepare, detect, or load.

This function is used as a test callback for the all callback groups.

It sets the '[group] callback' (see above) key to 'applied ([part])' where [part] is either 'top-level', 'version x.y' (where x.y is the passed-in version string), 'variant example' (where example is the passed-in variant name), or 'version x.y, variant example' (see above), depending on the part of the library the passed-in library information belongs to.

Parameters

$library: An array of library information, which may be version- or variant-specific. Passed by reference.

$version: The version the library information passed in $library belongs to, or NULL if the passed library information is not version-specific.

$variant: The variant the library information passed in $library belongs to, or NULL if the passed library information is not variant-specific.

5 calls to _libraries_test_callback()
_libraries_test_info_callback in tests/modules/libraries_test/libraries_test.module
Sets the 'info callback' key.
_libraries_test_post_detect_callback in tests/modules/libraries_test/libraries_test.module
Sets the 'post-detect callback' key.
_libraries_test_post_load_callback in tests/modules/libraries_test/libraries_test.module
Sets the 'post-load callback' key.
_libraries_test_pre_detect_callback in tests/modules/libraries_test/libraries_test.module
Sets the 'pre-detect callback' key.
_libraries_test_pre_load_callback in tests/modules/libraries_test/libraries_test.module
Sets the 'pre-load callback' key.

File

tests/modules/libraries_test/libraries_test.module, line 445
Tests the library detection and loading.

Code

function _libraries_test_callback(&$library, $version, $variant, $group) {
  $string = 'applied';
  if (isset($version) && isset($variant)) {
    $string .= " (version {$version}, variant {$variant})";
  }
  elseif (isset($version)) {
    $string .= " (version {$version})";
  }
  elseif (isset($variant)) {
    $string .= " (variant {$variant})";
  }
  else {
    $string .= ' (top-level)';
  }
  $library["{$group} callback"] = $string;

  // The following is used to test caching of library information.
  // Only set the message for the top-level library to prevent confusing,
  // duplicate messages.
  if (!isset($version) && !isset($variant) && \Drupal::state()
    ->get('libraries_test.cache', FALSE)) {
    \Drupal::messenger()
      ->addMessage(SafeMarkup::set("The <em>{$group}</em> callback group was invoked."));
  }
}