sdc.module

Same filename and directory in other branches
  1. 11.x core/modules/sdc/sdc.module

Module implementation file.

File

core/modules/sdc/sdc.module

View source
<?php


/**
 * @file
 * Module implementation file.
 */

use Drupal\Core\Theme\ComponentPluginManager;
use Drupal\Core\Plugin\Component;
@class_alias('Drupal\\Core\\Render\\Element', 'Drupal\\sdc\\Utilities');
@class_alias('Drupal\\Core\\Render\\Element\\ComponentElement', 'Drupal\\sdc\\Element\\ComponentElement');
@class_alias('Drupal\\Core\\Render\\Component\\Exception\\ComponentNotFoundException', 'Drupal\\sdc\\Exception\\ComponentNotFoundException');
@class_alias('Drupal\\Core\\Render\\Component\\Exception\\IncompatibleComponentSchema', 'Drupal\\sdc\\Exception\\IncompatibleComponentSchema');
@class_alias('Drupal\\Core\\Render\\Component\\Exception\\InvalidComponentDataException', 'Drupal\\sdc\\Exception\\InvalidComponentDataException');
@class_alias('Drupal\\Core\\Render\\Component\\Exception\\InvalidComponentException', 'Drupal\\sdc\\Exception\\InvalidComponentException');
@class_alias('Drupal\\Core\\Theme\\Component\\ComponentMetadata', 'Drupal\\sdc\\Component\\ComponentMetadata');
@class_alias('Drupal\\Core\\Theme\\Component\\ComponentValidator', 'Drupal\\sdc\\Component\\ComponentValidator');
@class_alias('Drupal\\Core\\Theme\\Component\\SchemaCompatibilityChecker', 'Drupal\\sdc\\Component\\SchemaCompatibilityChecker');
@class_alias('Drupal\\Core\\Plugin\\Component', 'Drupal\\sdc\\Plugin\\Component');
@class_alias('Drupal\\Core\\Plugin\\Discovery\\DirectoryWithMetadataDiscovery', 'Drupal\\sdc\\Plugin\\Discovery\\DirectoryWithMetadataDiscovery');
@class_alias('Drupal\\Core\\Plugin\\Discovery\\DirectoryWithMetadataPluginDiscovery', 'Drupal\\sdc\\Plugin\\Discovery\\DirectoryWithMetadataPluginDiscovery');
@class_alias('Drupal\\Core\\Plugin\\Discovery\\RegexRecursiveFilterIterator', 'Drupal\\sdc\\Plugin\\Discovery\\RegexRecursiveFilterIterator');
@class_alias('Drupal\\Core\\Template\\ComponentNodeVisitor', 'Drupal\\sdc\\Twig\\ComponentNodeVisitor');
@class_alias('Drupal\\Core\\Template\\Loader\\ComponentLoader', 'Drupal\\sdc\\Twig\\TwigComponentLoader');
@class_alias('Drupal\\Core\\Theme\\ComponentNegotiator', 'Drupal\\sdc\\ComponentNegotiator');
@class_alias('Drupal\\Core\\Theme\\ComponentPluginManager', 'Drupal\\sdc\\ComponentPluginManager');
@class_alias('Drupal\\Core\\Theme\\ExtensionType', 'Drupal\\sdc\\ExtensionType');

/**
 * Implements hook_library_info_build().
 */
function sdc_library_info_build() {
  $deprecation_message = 'The %library_id% asset library is deprecated in Drupal 10.3.0 and will be removed in Drupal 11.0.0. Use the core/components.[component-id] library instead. See https://www.drupal.org/node/3410260';
  // Iterate over all the components to get the CSS and JS files.
  $plugin_manager = \Drupal::service('plugin.manager.sdc');
  assert($plugin_manager instanceof ComponentPluginManager);
  $components = $plugin_manager->getAllComponents();
  // Generate backwards compatible deprecated libraries that depend on the new
  // library name scheme.
  $libraries = array_reduce($components, static function (array $libraries, Component $component) use ($deprecation_message) {
    // The library name is something like core/components.my-theme--my-comp.
    $library_name = $component->getLibraryName();
    // The library ID is something like my-theme--my-comp.
    $library_id = str_replace('core/components.', '', $library_name);
    // Adding these libraries will result in the old 'sdc/my-theme--my-comp'.
    return array_merge($libraries, [
      $library_id => [
        'dependencies' => [
          $library_name,
        ],
        'deprecated' => $deprecation_message,
      ],
    ]);
  }, []);
  // Alias the library sdc/all to core/components.all.
  $libraries['all'] = [
    'dependencies' => [
      'core/components.all',
    ],
    'deprecated' => 'The %library_id% asset library is deprecated in Drupal 10.3.0 and will be removed in Drupal 11.0.0. Use the core/components.all library instead. See https://www.drupal.org/node/3410260',
  ];
  return $libraries;
}

Functions

Title Deprecated Summary
sdc_library_info_build Implements hook_library_info_build().

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