Verified Commit b8037acd authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3409456 by plopesc, smustgrave, quietone, e0ipso, catch: Remove SDC...

Issue #3409456 by plopesc, smustgrave, quietone, e0ipso, catch: Remove SDC deprecated code before 11.0.0
parent 8fe4fb06
Loading
Loading
Loading
Loading
Loading
+2 −6
Original line number Diff line number Diff line
@@ -95,10 +95,10 @@ class LibraryDiscoveryParser {
   *   The libraries directory file finder.
   * @param \Drupal\Core\Extension\ExtensionPathResolver $extension_path_resolver
   *   The extension path resolver.
   * @param \Drupal\Core\Theme\ComponentPluginManager|null $component_plugin_manager
   * @param \Drupal\Core\Theme\ComponentPluginManager $component_plugin_manager
   *   The component plugin manager.
   */
  public function __construct($root, ModuleHandlerInterface $module_handler, ThemeManagerInterface $theme_manager, StreamWrapperManagerInterface $stream_wrapper_manager, LibrariesDirectoryFileFinder $libraries_directory_file_finder, ExtensionPathResolver $extension_path_resolver, ?ComponentPluginManager $component_plugin_manager = NULL) {
  public function __construct($root, ModuleHandlerInterface $module_handler, ThemeManagerInterface $theme_manager, StreamWrapperManagerInterface $stream_wrapper_manager, LibrariesDirectoryFileFinder $libraries_directory_file_finder, ExtensionPathResolver $extension_path_resolver, ComponentPluginManager $component_plugin_manager) {
    $this->root = $root;
    $this->moduleHandler = $module_handler;
    $this->themeManager = $theme_manager;
@@ -106,10 +106,6 @@ public function __construct($root, ModuleHandlerInterface $module_handler, Theme
    $this->librariesDirectoryFileFinder = $libraries_directory_file_finder;
    $this->extensionPathResolver = $extension_path_resolver;
    $this->fileCache = FileCacheFactory::get('library_parser');
    if (!isset($component_plugin_manager)) {
      @trigger_error('Calling ' . __METHOD__ . '() without the $component_plugin_manager argument is deprecated in drupal:10.3.0 and will be required in drupal:11.0.0. See https://www.drupal.org/node/3410260', E_USER_DEPRECATED);
      $component_plugin_manager = \Drupal::service('plugin.manager.sdc');
    }
    $this->componentPluginManager = $component_plugin_manager;
  }

+0 −6
Original line number Diff line number Diff line
@@ -44,12 +44,6 @@ public function getFunctions(): array {
    return [
      new TwigFunction('add_component_context', [$this, 'addAdditionalContext'], ['needs_context' => TRUE]),
      new TwigFunction('validate_component_props', [$this, 'validateProps'], ['needs_context' => TRUE]),
      // @todo remove in drupal:11.0.0.
      // @see https://www.drupal.org/project/drupal/issues/3409456.
      // Start of BC layer.
      new TwigFunction('sdc_additional_context', [$this, 'addAdditionalContext'], ['needs_context' => TRUE, 'deprecated' => '10.3.0', 'alternative' => 'add_component_context']),
      new TwigFunction('sdc_validate_props', [$this, 'validateProps'], ['needs_context' => TRUE, 'deprecated' => '10.3.0', 'alternative' => 'validate_component_props']),
      // End of BC layer.
    ];
  }

core/modules/sdc/README.txt

deleted100644 → 0
+0 −26
Original line number Diff line number Diff line
The API of Single Directory Components includes:

  - The component plugin manager (the service with name plugin.manager.sdc).
    This service will be needed by modules that need to find and instantiate
    components.
  - The exceptions. Code using Single Directory Components can rely, and extend,
    the exceptions provided by the experimental module.
  - The folder structure of a component and the naming conventions of the files
    in it.
  - The structure of the component metadata (the my-component.component.yml).
    Note that the metadata of the component is described, and optionally
    validated, by the schema in metadata.schema.json (this file is for internal validation and not part of the API).
  - The render element and its class \Drupal\Core\Render\Element\ComponentElement.
  - The naming convention for the ID when using Twig's include, embed, and
    extends. This naming convention is [module/theme]:[component machine name].
    See the example below.

{% embed 'my-theme:my-component' with { prop1: content.field_for_prop1 } %}
  {% block slot1 %}
    {{ content|without('field_for_prop1') }}
  {% endblock %}
{% endembed %}

This way  of specifying the component for Twig's include, embed, and
extends('my-theme:my-component' in the example) will not change, as it is
considered an API.
+3 −2
Original line number Diff line number Diff line
@@ -3,7 +3,8 @@ type: module
description: 'Allows discovery and rendering of self-contained UI components.'
version: VERSION
package: Core (Experimental)
lifecycle: deprecated
lifecycle_link: 'https://www.drupal.org/docs/core-modules-and-themes/deprecated-and-obsolete#s-understanding-deprecated-extensions'
lifecycle: obsolete
lifecycle_link: https://www.drupal.org/node/3223395#s-sdc
dependencies:
  - drupal:serialization
hidden: true

core/modules/sdc/sdc.module

deleted100644 → 0
+0 −64
Original line number Diff line number Diff line
<?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;
}
Loading