bueditor.module in BUEditor 8
Same filename and directory in other branches
Defines Drupal hooks for BUEditor.
File
bueditor.moduleView source
<?php
/**
* @file
* Defines Drupal hooks for BUEditor.
*/
use Drupal\Core\Url;
/**
* Implements hook_js_settings_alter().
*/
function bueditor_js_settings_alter(array &$settings, \Drupal\Core\Asset\AttachedAssetsInterface $assets) {
// XPreview library requires a tokenized URL.
$libraries = \Drupal::service('library.dependency_resolver')
->getLibrariesWithDependencies($assets
->getLibraries());
if (in_array('bueditor/drupal.xpreview', $libraries)) {
$options = [];
if (!\Drupal::currentUser()
->isAnonymous()) {
$options['query']['token'] = \Drupal::csrfToken()
->get('xpreview');
}
$settings['xPreview']['url'] = Url::fromRoute('drupal.xpreview', [], $options)
->toString();
}
}
/**
* Implements hook_library_info_alter().
*/
function bueditor_library_info_alter(array &$libraries, $module) {
// Use dev version of BUE library if dev mode is on.
if ($module === 'bueditor' && \Drupal::config('bueditor.settings')
->get('devmode')) {
$libraries['BUE'] = $libraries['BUE.dev'];
}
}
Functions
Name | Description |
---|---|
bueditor_js_settings_alter | Implements hook_js_settings_alter(). |
bueditor_library_info_alter | Implements hook_library_info_alter(). |