Skip to content

Commit 142fee3

Browse files
committed
Issue #3441392 by Binoli Lalani, smustgrave, andypost, quietone, pradhumanjain2311, longwave, catch: Removed deprecated code in Render system
1 parent 53039b1 commit 142fee3

9 files changed

+62
-292
lines changed

lib/Drupal/Component/Render/FormattableMarkup.php

+2-12
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,8 @@ public function jsonSerialize(): string {
130130
* An associative array of replacements. Each array key should be the same
131131
* as a placeholder in $string. The corresponding value should be a string
132132
* or an object that implements \Drupal\Component\Render\MarkupInterface.
133-
* Null args[] values are deprecated in Drupal 9.5 and will fail in
134-
* Drupal 11.0. The value replaces the placeholder in $string. Sanitization
135-
* and formatting will be done before replacement. The type of sanitization
133+
* The args[] value replaces the placeholder in $string. Sanitization and
134+
* formatting will be done before replacement. The type of sanitization
136135
* and formatting depends on the first character of the key:
137136
* - @variable: When the placeholder replacement value is:
138137
* - A string, the replaced value in the returned string will be sanitized
@@ -194,15 +193,6 @@ public function jsonSerialize(): string {
194193
protected static function placeholderFormat($string, array $args) {
195194
// Transform arguments before inserting them.
196195
foreach ($args as $key => $value) {
197-
if (is_null($value)) {
198-
// It's probably a bug to provide a null value for the placeholder arg,
199-
// and in D11 this will no longer be allowed. When this trigger_error
200-
// is removed, also remove isset $value checks inside the switch{}
201-
// below.
202-
// phpcs:ignore Drupal.Semantics.FunctionTriggerError
203-
@trigger_error(sprintf('Deprecated NULL placeholder value for key (%s) in: "%s". This will throw a PHP error in drupal:11.0.0. See https://www.drupal.org/node/3318826', (string) $key, (string) $string), E_USER_DEPRECATED);
204-
$value = '';
205-
}
206196
switch ($key[0]) {
207197
case '@':
208198
// Escape if the value is not an object from a class that implements

lib/Drupal/Core/Render/Element/Ajax.php

-45
This file was deleted.

lib/Drupal/Core/Render/Element/RenderElementBase.php

-6
Original file line numberDiff line numberDiff line change
@@ -372,12 +372,6 @@ public static function preRenderAjaxForm($element) {
372372
$settings['options']['query'][FormBuilderInterface::AJAX_FORM_REQUEST] = TRUE;
373373
}
374374

375-
// @todo Legacy support. Remove in Drupal 8.
376-
if (isset($settings['method']) && $settings['method'] == 'replace') {
377-
@trigger_error('Using "replace" as the method in #ajax property is deprecated in drupal:10.3.0 and is removed from drupal:11.0.0. Use "replaceWith" instead. See https://www.drupal.org/project/drupal/issues/3303557', E_USER_DEPRECATED);
378-
$settings['method'] = 'replaceWith';
379-
}
380-
381375
// Convert \Drupal\Core\Url object to string.
382376
if (isset($settings['url']) && $settings['url'] instanceof Url) {
383377
$url = $settings['url']->setOptions($settings['options'])->toString(TRUE);

lib/Drupal/Core/Render/ElementInfoManager.php

+9-35
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
namespace Drupal\Core\Render;
44

55
use Drupal\Core\Cache\CacheBackendInterface;
6-
use Drupal\Core\Cache\CacheTagsInvalidatorInterface;
7-
use Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait;
86
use Drupal\Core\Extension\ModuleHandlerInterface;
97
use Drupal\Core\Extension\ThemeHandlerInterface;
108
use Drupal\Core\Plugin\DefaultPluginManager;
@@ -25,36 +23,13 @@
2523
*/
2624
class ElementInfoManager extends DefaultPluginManager implements ElementInfoManagerInterface {
2725

28-
use DeprecatedServicePropertyTrait;
29-
30-
/**
31-
* Defines deprecated injected properties.
32-
*
33-
* @var array
34-
*/
35-
protected array $deprecatedProperties = ['cacheTagInvalidator' => 'cache_tags.invalidator'];
36-
3726
/**
3827
* Stores the available element information.
3928
*
4029
* @var array
4130
*/
4231
protected $elementInfo;
4332

44-
/**
45-
* The theme manager.
46-
*
47-
* @var \Drupal\Core\Theme\ThemeManagerInterface
48-
*/
49-
protected $themeManager;
50-
51-
/**
52-
* The theme handler.
53-
*
54-
* @var \Drupal\Core\Cache\CacheTagsInvalidatorInterface
55-
*/
56-
protected $themeHandler;
57-
5833
/**
5934
* Constructs an ElementInfoManager object.
6035
*
@@ -63,22 +38,21 @@ class ElementInfoManager extends DefaultPluginManager implements ElementInfoMana
6338
* keyed by the corresponding namespace to look for plugin implementations.
6439
* @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend
6540
* Cache backend instance to use.
66-
* @param \Drupal\Core\Extension\ThemeHandlerInterface|\Drupal\Core\Cache\CacheTagsInvalidatorInterface $theme_handler
41+
* @param \Drupal\Core\Extension\ThemeHandlerInterface $themeHandler
6742
* The theme handler.
6843
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
6944
* The module handler to invoke the alter hook with.
70-
* @param \Drupal\Core\Theme\ThemeManagerInterface $theme_manager
45+
* @param \Drupal\Core\Theme\ThemeManagerInterface $themeManager
7146
* The theme manager.
7247
*/
73-
public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ThemeHandlerInterface|CacheTagsInvalidatorInterface $theme_handler, ModuleHandlerInterface $module_handler, ThemeManagerInterface $theme_manager) {
48+
public function __construct(
49+
\Traversable $namespaces,
50+
CacheBackendInterface $cache_backend,
51+
protected ThemeHandlerInterface $themeHandler,
52+
ModuleHandlerInterface $module_handler,
53+
protected ThemeManagerInterface $themeManager,
54+
) {
7455
$this->setCacheBackend($cache_backend, 'element_info');
75-
$this->themeManager = $theme_manager;
76-
if ($theme_handler instanceof CacheTagsInvalidatorInterface) {
77-
@trigger_error('Calling ' . __METHOD__ . '() with the $cache_tag_invalidator argument is deprecated in drupal:10.2.0 and will be removed in drupal:11.0.0. Pass $theme_handler instead. See https://www.drupal.org/node/3355227', E_USER_DEPRECATED);
78-
$theme_handler = \Drupal::service('theme_handler');
79-
}
80-
$this->themeHandler = $theme_handler;
81-
8256
parent::__construct('Element', $namespaces, $module_handler, 'Drupal\Core\Render\Element\ElementInterface', RenderElement::class, 'Drupal\Core\Render\Annotation\RenderElement');
8357
$this->alterInfo('element_plugin');
8458
}

lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php

+16-60
Original file line numberDiff line numberDiff line change
@@ -33,88 +33,44 @@
3333
*/
3434
class HtmlResponseAttachmentsProcessor implements AttachmentsResponseProcessorInterface {
3535

36-
/**
37-
* The asset resolver service.
38-
*
39-
* @var \Drupal\Core\Asset\AssetResolverInterface
40-
*/
41-
protected $assetResolver;
42-
4336
/**
4437
* A config object for the system performance configuration.
4538
*
4639
* @var \Drupal\Core\Config\Config
4740
*/
4841
protected $config;
4942

50-
/**
51-
* The CSS asset collection renderer service.
52-
*
53-
* @var \Drupal\Core\Asset\AssetCollectionRendererInterface
54-
*/
55-
protected $cssCollectionRenderer;
56-
57-
/**
58-
* The JS asset collection renderer service.
59-
*
60-
* @var \Drupal\Core\Asset\AssetCollectionRendererInterface
61-
*/
62-
protected $jsCollectionRenderer;
63-
64-
/**
65-
* The request stack.
66-
*
67-
* @var \Symfony\Component\HttpFoundation\RequestStack
68-
*/
69-
protected $requestStack;
70-
71-
/**
72-
* The renderer.
73-
*
74-
* @var \Drupal\Core\Render\RendererInterface
75-
*/
76-
protected $renderer;
77-
78-
/**
79-
* The module handler service.
80-
*
81-
* @var \Drupal\Core\Extension\ModuleHandlerInterface
82-
*/
83-
protected $moduleHandler;
84-
8543
/**
8644
* Constructs a HtmlResponseAttachmentsProcessor object.
8745
*
88-
* @param \Drupal\Core\Asset\AssetResolverInterface $asset_resolver
46+
* @param \Drupal\Core\Asset\AssetResolverInterface $assetResolver
8947
* An asset resolver.
9048
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
9149
* A config factory for retrieving required config objects.
92-
* @param \Drupal\Core\Asset\AssetCollectionRendererInterface $css_collection_renderer
50+
* @param \Drupal\Core\Asset\AssetCollectionRendererInterface $cssCollectionRenderer
9351
* The CSS asset collection renderer.
94-
* @param \Drupal\Core\Asset\AssetCollectionRendererInterface $js_collection_renderer
52+
* @param \Drupal\Core\Asset\AssetCollectionRendererInterface $jsCollectionRenderer
9553
* The JS asset collection renderer.
96-
* @param \Symfony\Component\HttpFoundation\RequestStack $request_stack
54+
* @param \Symfony\Component\HttpFoundation\RequestStack $requestStack
9755
* The request stack.
9856
* @param \Drupal\Core\Render\RendererInterface $renderer
9957
* The renderer.
100-
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
58+
* @param \Drupal\Core\Extension\ModuleHandlerInterface $moduleHandler
10159
* The module handler service.
102-
* @param \Drupal\Core\Language\LanguageManagerInterface|null $languageManager
60+
* @param \Drupal\Core\Language\LanguageManagerInterface $languageManager
10361
* The language manager.
10462
*/
105-
public function __construct(AssetResolverInterface $asset_resolver, ConfigFactoryInterface $config_factory, AssetCollectionRendererInterface $css_collection_renderer, AssetCollectionRendererInterface $js_collection_renderer, RequestStack $request_stack, RendererInterface $renderer, ModuleHandlerInterface $module_handler, protected ?LanguageManagerInterface $languageManager = NULL) {
106-
$this->assetResolver = $asset_resolver;
63+
public function __construct(
64+
protected AssetResolverInterface $assetResolver,
65+
ConfigFactoryInterface $config_factory,
66+
protected AssetCollectionRendererInterface $cssCollectionRenderer,
67+
protected AssetCollectionRendererInterface $jsCollectionRenderer,
68+
protected RequestStack $requestStack,
69+
protected RendererInterface $renderer,
70+
protected ModuleHandlerInterface $moduleHandler,
71+
protected LanguageManagerInterface $languageManager,
72+
) {
10773
$this->config = $config_factory->get('system.performance');
108-
$this->cssCollectionRenderer = $css_collection_renderer;
109-
$this->jsCollectionRenderer = $js_collection_renderer;
110-
$this->requestStack = $request_stack;
111-
$this->renderer = $renderer;
112-
$this->moduleHandler = $module_handler;
113-
if (!isset($languageManager)) {
114-
// phpcs:ignore Drupal.Semantics.FunctionTriggerError
115-
@trigger_error('Calling ' . __METHOD__ . '() without the $languageManager argument is deprecated in drupal:10.1.0 and will be required in drupal:11.0.0', E_USER_DEPRECATED);
116-
$this->languageManager = \Drupal::languageManager();
117-
}
11874
}
11975

12076
/**

lib/Drupal/Core/Render/PlaceholderingRenderCache.php

+12-19
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
namespace Drupal\Core\Render;
44

5-
use Drupal\Core\Cache\CacheFactoryInterface;
65
use Drupal\Core\Cache\Context\CacheContextsManager;
6+
use Drupal\Core\Cache\VariationCacheFactoryInterface;
77
use Symfony\Component\HttpFoundation\RequestStack;
88

99
/**
@@ -39,13 +39,6 @@
3939
*/
4040
class PlaceholderingRenderCache extends RenderCache {
4141

42-
/**
43-
* The placeholder generator.
44-
*
45-
* @var \Drupal\Core\Render\PlaceholderGeneratorInterface
46-
*/
47-
protected $placeholderGenerator;
48-
4942
/**
5043
* Stores rendered results for automatically placeholdered elements.
5144
*
@@ -74,22 +67,22 @@ class PlaceholderingRenderCache extends RenderCache {
7467
/**
7568
* Constructs a new PlaceholderingRenderCache object.
7669
*
77-
* @param \Symfony\Component\HttpFoundation\RequestStack $request_stack
70+
* @param \Symfony\Component\HttpFoundation\RequestStack $requestStack
7871
* The request stack.
79-
* @param \Drupal\Core\Cache\VariationCacheFactoryInterface $cache_factory
72+
* @param \Drupal\Core\Cache\VariationCacheFactoryInterface $cacheFactory
8073
* The variation cache factory.
81-
* @param \Drupal\Core\Cache\Context\CacheContextsManager $cache_contexts_manager
74+
* @param \Drupal\Core\Cache\Context\CacheContextsManager $cacheContextsManager
8275
* The cache contexts manager.
83-
* @param \Drupal\Core\Render\PlaceholderGeneratorInterface $placeholder_generator
76+
* @param \Drupal\Core\Render\PlaceholderGeneratorInterface $placeholderGenerator
8477
* The placeholder generator.
8578
*/
86-
public function __construct(RequestStack $request_stack, $cache_factory, CacheContextsManager $cache_contexts_manager, PlaceholderGeneratorInterface $placeholder_generator) {
87-
if ($cache_factory instanceof CacheFactoryInterface) {
88-
@trigger_error('Injecting ' . __CLASS__ . ' with the "cache_factory" service is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use "variation_cache_factory" instead. See https://www.drupal.org/node/3365546', E_USER_DEPRECATED);
89-
$cache_factory = \Drupal::service('variation_cache_factory');
90-
}
91-
parent::__construct($request_stack, $cache_factory, $cache_contexts_manager);
92-
$this->placeholderGenerator = $placeholder_generator;
79+
public function __construct(
80+
RequestStack $requestStack,
81+
VariationCacheFactoryInterface $cacheFactory,
82+
CacheContextsManager $cacheContextsManager,
83+
protected PlaceholderGeneratorInterface $placeholderGenerator,
84+
) {
85+
parent::__construct($requestStack, $cacheFactory, $cacheContextsManager);
9386
}
9487

9588
/**

lib/Drupal/Core/Render/RenderCache.php

+9-33
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
namespace Drupal\Core\Render;
44

55
use Drupal\Core\Cache\CacheableMetadata;
6-
use Drupal\Core\Cache\CacheFactoryInterface;
76
use Drupal\Core\Cache\Context\CacheContextsManager;
7+
use Drupal\Core\Cache\VariationCacheFactoryInterface;
88
use Symfony\Component\HttpFoundation\RequestStack;
99

1010
/**
@@ -14,45 +14,21 @@
1414
*/
1515
class RenderCache implements RenderCacheInterface {
1616

17-
/**
18-
* The request stack.
19-
*
20-
* @var \Symfony\Component\HttpFoundation\RequestStack
21-
*/
22-
protected $requestStack;
23-
24-
/**
25-
* The variation cache factory.
26-
*
27-
* @var \Drupal\Core\Cache\VariationCacheFactoryInterface
28-
*/
29-
protected $cacheFactory;
30-
31-
/**
32-
* The cache contexts manager.
33-
*
34-
* @var \Drupal\Core\Cache\Context\CacheContextsManager
35-
*/
36-
protected $cacheContextsManager;
37-
3817
/**
3918
* Constructs a new RenderCache object.
4019
*
41-
* @param \Symfony\Component\HttpFoundation\RequestStack $request_stack
20+
* @param \Symfony\Component\HttpFoundation\RequestStack $requestStack
4221
* The request stack.
43-
* @param \Drupal\Core\Cache\VariationCacheFactoryInterface $cache_factory
22+
* @param \Drupal\Core\Cache\VariationCacheFactoryInterface $cacheFactory
4423
* The variation cache factory.
45-
* @param \Drupal\Core\Cache\Context\CacheContextsManager $cache_contexts_manager
24+
* @param \Drupal\Core\Cache\Context\CacheContextsManager $cacheContextsManager
4625
* The cache contexts manager.
4726
*/
48-
public function __construct(RequestStack $request_stack, $cache_factory, CacheContextsManager $cache_contexts_manager) {
49-
if ($cache_factory instanceof CacheFactoryInterface) {
50-
@trigger_error('Injecting ' . __CLASS__ . ' with the "cache_factory" service is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use "variation_cache_factory" instead. See https://www.drupal.org/node/3365546', E_USER_DEPRECATED);
51-
$cache_factory = \Drupal::service('variation_cache_factory');
52-
}
53-
$this->requestStack = $request_stack;
54-
$this->cacheFactory = $cache_factory;
55-
$this->cacheContextsManager = $cache_contexts_manager;
27+
public function __construct(
28+
protected RequestStack $requestStack,
29+
protected VariationCacheFactoryInterface $cacheFactory,
30+
protected CacheContextsManager $cacheContextsManager,
31+
) {
5632
}
5733

5834
/**

0 commit comments

Comments
 (0)