From b8037acd209eb900a77fb3ae1ad70898e97c7809 Mon Sep 17 00:00:00 2001 From: Alex Pott Date: Wed, 3 Apr 2024 11:41:05 +0100 Subject: [PATCH] Issue #3409456 by plopesc, smustgrave, quietone, e0ipso, catch: Remove SDC deprecated code before 11.0.0 --- .../Core/Asset/LibraryDiscoveryParser.php | 8 +-- .../Core/Template/ComponentsTwigExtension.php | 6 -- core/modules/sdc/README.txt | 26 -------- core/modules/sdc/sdc.info.yml | 5 +- core/modules/sdc/sdc.module | 64 ------------------- core/modules/sdc/sdc.services.yml | 44 ------------- .../src/Functional/LibrariesBCLayerTest.php | 45 ------------- core/modules/system/system.post_update.php | 9 +++ 8 files changed, 14 insertions(+), 193 deletions(-) delete mode 100644 core/modules/sdc/README.txt delete mode 100644 core/modules/sdc/sdc.module delete mode 100644 core/modules/sdc/sdc.services.yml delete mode 100644 core/modules/sdc/tests/src/Functional/LibrariesBCLayerTest.php diff --git a/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php b/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php index a44ff14fba0..e3e8ce08f94 100644 --- a/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php +++ b/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php @@ -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 @@ class LibraryDiscoveryParser { $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; } diff --git a/core/lib/Drupal/Core/Template/ComponentsTwigExtension.php b/core/lib/Drupal/Core/Template/ComponentsTwigExtension.php index b4f5365021b..49e214c6b88 100644 --- a/core/lib/Drupal/Core/Template/ComponentsTwigExtension.php +++ b/core/lib/Drupal/Core/Template/ComponentsTwigExtension.php @@ -44,12 +44,6 @@ final class ComponentsTwigExtension extends AbstractExtension { 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. ]; } diff --git a/core/modules/sdc/README.txt b/core/modules/sdc/README.txt deleted file mode 100644 index fdb7db73186..00000000000 --- a/core/modules/sdc/README.txt +++ /dev/null @@ -1,26 +0,0 @@ -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. diff --git a/core/modules/sdc/sdc.info.yml b/core/modules/sdc/sdc.info.yml index 98ef12cc431..6a41593d15c 100644 --- a/core/modules/sdc/sdc.info.yml +++ b/core/modules/sdc/sdc.info.yml @@ -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 diff --git a/core/modules/sdc/sdc.module b/core/modules/sdc/sdc.module deleted file mode 100644 index 89da82a3448..00000000000 --- a/core/modules/sdc/sdc.module +++ /dev/null @@ -1,64 +0,0 @@ -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; -} diff --git a/core/modules/sdc/sdc.services.yml b/core/modules/sdc/sdc.services.yml deleted file mode 100644 index 379762e1d79..00000000000 --- a/core/modules/sdc/sdc.services.yml +++ /dev/null @@ -1,44 +0,0 @@ -services: - _defaults: - public: false - - # This service is deprecated, use the one defined in core instead. - Drupal\sdc\Twig\TwigComponentLoader: - alias: 'Drupal\Core\Template\Loader\ComponentLoader' - deprecated: - package: 'drupal/core' - version: '10.3.0' - message: The "%alias_id%" service is deprecated since drupal/core 10.3.0 and will be removed in 11.0. - - # This service is deprecated, use the one defined in core instead. - Drupal\sdc\ComponentNegotiator: - alias: 'Drupal\Core\Theme\ComponentNegotiator' - deprecated: - package: 'drupal/core' - version: '10.3.0' - message: The "%alias_id%" service is deprecated since drupal/core 10.3.0 and will be removed in 11.0. - - # This service defines the deprecated twig functions related to SDC. - # Use the ones defined in core instead. - Drupal\sdc\Twig\TwigExtension: - alias: 'Drupal\Core\Template\ComponentsTwigExtension' - deprecated: - package: 'drupal/core' - version: '10.3.0' - message: The "%alias_id%" service is deprecated since drupal/core 10.3.0 and will be removed in 11.0. - - # This service is deprecated, use the one defined in core instead. - Drupal\sdc\Component\SchemaCompatibilityChecker: - alias: 'Drupal\Core\Theme\Component\SchemaCompatibilityChecker' - deprecated: - package: 'drupal/core' - version: '10.3.0' - message: The "%alias_id%" service is deprecated since drupal/core 10.3.0 and will be removed in 11.0. - - # This service is deprecated, use the one defined in core instead. - Drupal\sdc\Component\ComponentValidator: - alias: 'Drupal\Core\Theme\Component\ComponentValidator' - deprecated: - package: 'drupal/core' - version: '10.3.0' - message: The "%alias_id%" service is deprecated since drupal/core 10.3.0 and will be removed in 11.0. diff --git a/core/modules/sdc/tests/src/Functional/LibrariesBCLayerTest.php b/core/modules/sdc/tests/src/Functional/LibrariesBCLayerTest.php deleted file mode 100644 index e3417be3c89..00000000000 --- a/core/modules/sdc/tests/src/Functional/LibrariesBCLayerTest.php +++ /dev/null @@ -1,45 +0,0 @@ -expectDeprecation('The module \'sdc\' is deprecated. See https://www.drupal.org/docs/core-modules-and-themes/deprecated-and-obsolete#s-understanding-deprecated-extensions'); - $this->expectDeprecation('The sdc/sdc_theme_test--my-card 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'); - $build = [ - '#type' => 'inline_template', - '#template' => "

Foo

{{ attach_library('sdc/sdc_theme_test--my-card') }}", - ]; - \Drupal::state()->set('sdc_test_component', $build); - $output = $this->drupalGet('sdc-test-component'); - // Ensure the CSS from the component is properly added to the page. - $this->assertStringContainsString('my-card.css', $output); - } - -} diff --git a/core/modules/system/system.post_update.php b/core/modules/system/system.post_update.php index 13b15470f40..861e4ccd34a 100644 --- a/core/modules/system/system.post_update.php +++ b/core/modules/system/system.post_update.php @@ -223,3 +223,12 @@ function system_post_update_set_cron_logging_setting_to_boolean(): void { $config->set('logging', (bool) $logging)->save(); } } + +/** + * Uninstall the sdc module if installed. + */ +function system_post_update_sdc_uninstall() { + if (\Drupal::moduleHandler()->moduleExists('sdc')) { + \Drupal::service('module_installer')->uninstall(['sdc'], FALSE); + } +}