Skip to content
Snippets Groups Projects
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
No related branches found
No related tags found
32 merge requests!12227Issue #3181946 by jonmcl, mglaman,!11131[10.4.x-only-DO-NOT-MERGE]: Issue ##2842525 Ajax attached to Views exposed filter form does not trigger callbacks,!9470[10.3.x-only-DO-NOT-MERGE]: #3331771 Fix file_get_contents(): Passing null to parameter,!8540Issue #3457061: Bootstrap Modal dialog Not closing after 10.3.0 Update,!8528Issue #3456871 by Tim Bozeman: Support NULL services,!8373Issue #3427374 by danflanagan8, Vighneshh: taxonomy_tid ViewsArgumentDefault...,!7526Expose roles in response,!7352Draft: Resolve #3203489 "Set filename as",!5423Draft: Resolve #3329907 "Test2",!3878Removed unused condition head title for views,!3818Issue #2140179: $entity->original gets stale between updates,!3742Issue #3328429: Create item list field formatter for displaying ordered and unordered lists,!3731Claro: role=button on status report items,!3651Issue #3347736: Create new SDC component for Olivero (header-search),!3531Issue #3336994: StringFormatter always displays links to entity even if the user in context does not have access,!3478Issue #3337882: Deleted menus are not removed from content type config,!3355Issue #3209129: Scrolling problems when adding a block via layout builder,!3154Fixes #2987987 - CSRF token validation broken on routes with optional parameters.,!3133core/modules/system/css/components/hidden.module.css,!2964Issue #2865710 : Dependencies from only one instance of a widget are used in display modes,!2812Issue #3312049: [Followup] Fix Drupal.Commenting.FunctionComment.MissingReturnType returns for NULL,!2794Issue #3100732: Allow specifying `meta` data on JSON:API objects,!2378Issue #2875033: Optimize joins and table selection in SQL entity query implementation,!2062Issue #3246454: Add weekly granularity to views date sort,!1105Issue #3025039: New non translatable field on translatable content throws error,!1073issue #3191727: Focus states on mobile second level navigation items fixed,!10223132456: Fix issue where views instances are emptied before an ajax request is complete,!877Issue #2708101: Default value for link text is not saved,!617Issue #3043725: Provide a Entity Handler for user cancelation,!579Issue #2230909: Simple decimals fail to pass validation,!560Move callback classRemove outside of the loop,!555Issue #3202493
Pipeline #136261 passed with warnings
Pipeline: drupal

#136263

    ......@@ -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;
    }
    ......
    ......@@ -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.
    ];
    }
    ......
    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,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
    <?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;
    }
    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.
    <?php
    declare(strict_types=1);
    namespace Drupal\Tests\sdc\Functional;
    use Drupal\Tests\BrowserTestBase;
    /**
    * Tests the correct rendering of components.
    *
    * @group sdc
    * @group legacy
    *
    * @internal
    */
    final class LibrariesBCLayerTest extends BrowserTestBase {
    /**
    * {@inheritdoc}
    */
    protected static $modules = ['system', 'sdc', 'sdc_test'];
    /**
    * {@inheritdoc}
    */
    protected $defaultTheme = 'sdc_theme_test';
    /**
    * Tests libraryOverrides.
    */
    public function testLibraryBCLayer(): void {
    $this->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' => "<h2>Foo</h2>{{ 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);
    }
    }
    ......@@ -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);
    }
    }
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Please register or to comment