drupal_container() is deprecated, and all calls in the layout module need to be replaced with Drupal::service(), except for where the module_handler service is requested, which needs to be replaced with Drupal::moduleHandler() (see #1957154: Replace calls to drupal_container()->get('module_handler') service with Drupal::moduleHandler())

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

kgoel’s picture

Assigned: Unassigned » kgoel
kgoel’s picture

Status: Active » Needs review
FileSize
1.97 KB

Status: Needs review » Needs work

The last submitted patch, layout-2011094-2.patch, failed testing.

ddrozdik’s picture

+++ b/core/modules/layout/layout.module
@@ -58,7 +58,7 @@ function layout_permission() {
  *   The layout plugin manager instance.
  */
 function layout_manager() {
-  return drupal_container()->get('plugin.manager.layout');
+  return Drupal::moduleHandler()->get('plugin.manager.layout');
 }

This is incorrect way, just use Drupal::service('plugin.manager.layout'); in this case

+++ b/core/modules/layout/lib/Drupal/layout/Plugin/Derivative/Layout.php
@@ -59,7 +59,7 @@ public function getDerivativeDefinitions(array $base_plugin_definition) {
-    foreach (drupal_container()->get('module_handler')->getModuleList() as $module => $filename) {
+    foreach (Drupal::moduleHandler()->get('module_handler')->getModuleList() as $module => $filename) {

Also incorrect using, should be: \Drupal::moduleHandler()->getModuleList()

In this part the leading \ should be before calling class(I just think we loosely agreed on omitting in procedural code)

kgoel’s picture

Status: Needs work » Needs review
FileSize
1.95 KB

Status: Needs review » Needs work

The last submitted patch, layout-2011094-5.patch, failed testing.

kgoel’s picture

Status: Needs work » Needs review
FileSize
1.96 KB

Status: Needs review » Needs work

The last submitted patch, layout-2011094-7.patch, failed testing.

kgoel’s picture

Status: Needs work » Needs review
FileSize
1.14 KB
ddrozdik’s picture

Status: Needs review » Reviewed & tested by the community

looks good - RTBC

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/layout/layout.moduleundefined
@@ -58,7 +58,7 @@ function layout_permission() {
 function layout_manager() {
-  return drupal_container()->get('plugin.manager.layout');
+  return Drupal::service('plugin.manager.layout');
 }

I'd be a fan of getting rid of this function entirely and replace calls to it with either the injected service (where possible) or Drupal::service('plugin.manager.layout')

+++ b/core/modules/layout/lib/Drupal/layout/Tests/LayoutDerivativesTest.phpundefined
@@ -33,7 +33,7 @@ public static function getInfo() {
-    $manager = drupal_container()->get('plugin.manager.layout');
+    $manager = \Drupal::service('plugin.manager.layout');

Should be $this->container->get('plugin.manager.layout');

kgoel’s picture

Status: Needs work » Needs review
FileSize
1.96 KB
1.97 KB

Status: Needs review » Needs work
Issue tags: -Novice

The last submitted patch, layout-2011094-12.patch, failed testing.

kgoel’s picture

Status: Needs work » Needs review

#12: layout-2011094-12.patch queued for re-testing.

Status: Needs review » Needs work
Issue tags: +Novice

The last submitted patch, layout-2011094-12.patch, failed testing.

kgoel’s picture

Status: Needs work » Needs review
FileSize
1.75 KB
3.72 KB

@alexpott -I just ran grep on layout_manager and found that this is being called in LayoutController.php. I am not sure if you meant to get rid of this code also.

./lib/Drupal/layout/Controller/LayoutController.php: * @param \Drupal\layout\Plugin\Type\LayoutManager $layout_manager
./lib/Drupal/layout/Controller/LayoutController.php: function __construct(LayoutManager $layout_manager) {
./lib/Drupal/layout/Controller/LayoutController.php: $this->layoutManager = $layout_manager;

ddrozdik’s picture

Status: Needs review » Reviewed & tested by the community

Applied, works good.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 1230f1d and pushed to 8.x. Thanks!

Automatically closed -- issue fixed for 2 weeks with no activity.