You are here

function _yamlform_asset_alter in YAML Form 8

Alter CSS or JavaScript assets to include custom form assets.

Note: CSS and JavaScript are not aggregated or minified to make it easier for themers to debug and custom their code. We could write the CSS and JS to the 'files/css' and 'files/js' using the hash key and aggregrate them.

Parameters

array $items: An array of all CSS or JavaScript being presented on the page.

\Drupal\Core\Asset\AttachedAssetsInterface $assets: The assets attached to the current response.

string $type: The type of asset being attached.

string $extension: The asset file extension being attached.

2 calls to _yamlform_asset_alter()
yamlform_css_alter in ./yamlform.module
Implements hook_css_alter().
yamlform_js_alter in ./yamlform.module
Implements hook_js_alter().

File

./yamlform.module, line 314
Enables the creation of forms and questionnaires.

Code

function _yamlform_asset_alter(array &$items, AttachedAssetsInterface $assets, $type, $extension) {
  $settings = $assets
    ->getSettings();
  if (empty($settings['yamlform']['assets'][$type])) {
    return;
  }
  $path = drupal_get_path('module', 'yamlform');
  foreach ($settings['yamlform']['assets'][$type] as $id => $hash) {
    $key = "{$path}/{$extension}/yamlform.assets.{$extension}";
    if (isset($items[$key])) {
      $items[$key] = [
        'data' => base_path() . "yamlform/{$id}/assets/{$type}?v={$hash}",
        'group' => 1000,
        'weight' => 1000,
      ] + $items[$key];
    }
  }
}