- 🇨🇳China jungle Chongqing, China
@ankitsingh0188 thanks for working on this.
See https://stackoverflow.com/questions/18142870/git-error-fatal-corrupt-pat... for the error, maybe you should try the git CLI to get the patch or see https://www.drupal.org/docs/develop/git/using-git-to-contribute-to-drupa... →
Also, please see #3123210: Replace non-test usages of \Drupal::theme() with IoC injection → as a good example.
- 🇨🇳China jungle Chongqing, China
+++ b/core/lib/Drupal/Core/Session/UserSession.php @@ -130,12 +130,12 @@ public function isAnonymous() { - $language_list = \Drupal::languageManager()->getLanguages(); + $language_list = \Drupal::service('language_manager')->getLanguages(); ... - return $fallback_to_default ? \Drupal::languageManager()->getDefaultLanguage()->getId() : ''; + return $fallback_to_default ? \Drupal::service('language_manager')->getDefaultLanguage()->getId() : '';
Those are not "Using IoC as possible". They are almost the same. Again see fixed issue #3123210: Replace non-test usages of \Drupal::theme() with IoC injection → as the example.
- Issue was unassigned.
- Status changed to Needs review
over 1 year ago 7:02am 16 February 2023 - Status changed to Needs work
over 1 year ago 7:08am 16 February 2023 - 🇮🇳India ankitsingh0188 Pune
I think the patch #25 📌 Replace non-test usages of \Drupal::languageManager() with IoC injection Needs review will address the issue as mentioned in #21 📌 Replace non-test usages of \Drupal::languageManager() with IoC injection Needs review
- 🇨🇳China jungle Chongqing, China
Or see the commit of the issue #3123210: Replace non-test usages of \Drupal::theme() with IoC injection → as the example
- 🇮🇳India ankitsingh0188 Pune
@jungle I have updated the patch and using IoC wherever possible.
- 🇨🇳China jungle Chongqing, China
+++ b/core/lib/Drupal/Core/Ajax/AjaxResponseAttachmentsProcessor.php @@ -99,10 +106,11 @@ public function __construct(AssetResolverInterface $asset_resolver, ConfigFactor @trigger_error('Calling ' . __METHOD__ . '() without the $language_manager argument is deprecated in drupal:10.1.0 and will be required in drupal:11.0.0', E_USER_DEPRECATED); +++ b/core/lib/Drupal/Core/Field/FormatterBase.php @@ -69,13 +79,18 @@ public function __construct($plugin_id, $plugin_definition, FieldDefinitionInter + @trigger_error('Calling ' . __METHOD__ . '() without the $language_manager argument is deprecated in drupal:10.1.0 and will be required in drupal:11.0.0', E_USER_DEPRECATED); +++ b/core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php @@ -81,6 +81,13 @@ class HtmlResponseAttachmentsProcessor implements AttachmentsResponseProcessorIn + /** + * The language manager. + * + * @var \Drupal\Core\Language\LanguageManagerInterface + */ + protected $languageManager; @@ -98,10 +105,10 @@ class HtmlResponseAttachmentsProcessor implements AttachmentsResponseProcessorIn - * @param \Drupal\Core\Language\LanguageManagerInterface|null $languageManager + * @param \Drupal\Core\Language\LanguageManagerInterface|null $language_manager ... - 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) { + 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, LanguageManagerInterface $language_manager = NULL) { @@ -109,10 +116,11 @@ public function __construct(AssetResolverInterface $asset_resolver, ConfigFactor + @trigger_error('Calling ' . __METHOD__ . '() without the $language_manager argument is deprecated in drupal:10.1.0 and will be required in drupal:11.0.0', E_USER_DEPRECATED);
This is fine. it's constructor property promotion introduced in PHP8, let's adopt it in this issue. and hopefully, it gets applied to other sister issues.
+++ b/core/lib/Drupal/Core/Ajax/AjaxResponseAttachmentsProcessor.php @@ -99,10 +106,11 @@ public function __construct(AssetResolverInterface $asset_resolver, ConfigFactor @trigger_error('Calling ' . __METHOD__ . '() without the $language_manager argument is deprecated in drupal:10.1.0 and will be required in drupal:11.0.0', E_USER_DEPRECATED); +++ b/core/lib/Drupal/Core/Field/FormatterBase.php @@ -69,13 +79,18 @@ public function __construct($plugin_id, $plugin_definition, FieldDefinitionInter + @trigger_error('Calling ' . __METHOD__ . '() without the $language_manager argument is deprecated in drupal:10.1.0 and will be required in drupal:11.0.0', E_USER_DEPRECATED); +++ b/core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php @@ -109,10 +116,11 @@ public function __construct(AssetResolverInterface $asset_resolver, ConfigFactor + @trigger_error('Calling ' . __METHOD__ . '() without the $language_manager argument is deprecated in drupal:10.1.0 and will be required in drupal:11.0.0', E_USER_DEPRECATED); +++ b/core/lib/Drupal/Core/Routing/RouteProvider.php @@ -131,7 +131,11 @@ public function __construct(Connection $connection, StateInterface $state, Curre + @trigger_error('Calling ' . __METHOD__ . '() without the $language_manager argument is deprecated in drupal:10.1.0 and will be required in drupal:11.0.0', E_USER_DEPRECATED);
A change record link is expected. Tagging needs CR.
- Assigned to jungle
- Issue was unassigned.
- Status changed to Needs review
over 1 year ago 11:27am 16 February 2023 After applying the patch #37 site is down → . After adding some changes in patch #40 site is working
The last submitted patch, 42: 3123207-42.patch, failed testing. View results →