function quickedit_library_info_alter

Same name in other branches
  1. 8.9.x core/modules/quickedit/quickedit.module \quickedit_library_info_alter()

Implements hook_library_info_alter().

Includes additional stylesheets defined by the admin theme to allow it to customize the Quick Edit toolbar appearance.

An admin theme can specify CSS files to make the front-end administration experience of in-place editing match the administration experience in the back-end.

The CSS files can be specified via the "edit_stylesheets" property in the .info.yml file:

quickedit_stylesheets:
-css / quickedit . css;

File

core/modules/quickedit/quickedit.module, line 79

Code

function quickedit_library_info_alter(&$libraries, $extension) {
    if ($extension === 'quickedit' && isset($libraries['quickedit'])) {
        $theme = Drupal::config('system.theme')->get('admin');
        // First let the base theme modify the library, then the actual theme.
        $alter_library = function (&$library, $theme) use (&$alter_library) {
            
            /** @var \Drupal\Core\Extension\ThemeExtensionList $theme_list */
            $theme_list = \Drupal::service('extension.list.theme');
            if (!empty($theme) && ($theme_path = $theme_list->getPath($theme))) {
                $info = $theme_list->getExtensionInfo($theme);
                // Recurse to process base theme(s) first.
                if (isset($info['base theme'])) {
                    $alter_library($library, $info['base theme']);
                }
                if (isset($info['quickedit_stylesheets'])) {
                    foreach ($info['quickedit_stylesheets'] as $path) {
                        $library['css']['theme']['/' . $theme_path . '/' . $path] = [];
                    }
                }
            }
        };
        $alter_library($libraries['quickedit'], $theme);
    }
    $moduleHandler = \Drupal::moduleHandler();
    if ($moduleHandler->moduleExists('ckeditor5')) {
        $libraries['internal.drupal.ckeditor5']['dependencies'][] = 'quickedit/quickedit.ckeditor5-temporary-work-around';
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.