Issue #2834982: Replace non-test usages of \Drupal::service('renderer') with IoC injection
Compare changes
@@ -10,6 +10,7 @@
@@ -42,6 +43,11 @@ class BookAdminEditForm extends FormBase {
- Comment on lines 44 to 45Oleh Vehera @volegerSuggested change
45 46 /** 47 * The renderer service. 48 */ 49 protected RendererInterface $renderer; 50 51 /** 45 46 /**
@@ -51,11 +57,18 @@ class BookAdminEditForm extends FormBase {
63 public function __construct(EntityStorageInterface $node_storage, BookManagerInterface $book_manager, EntityRepositoryInterface $entity_repository, RendererInterface $renderer = NULL) { 63 public function __construct(EntityStorageInterface $node_storage, BookManagerInterface $book_manager, EntityRepositoryInterface $entity_repository, protected RendererInterface $renderer = NULL) {
- Comment on lines 58 to 59
66 $this->entityRepository = $entity_repository; 67 if (!$renderer) { 68 @trigger_error('Calling ' . __METHOD__ . '() without the $renderer argument is deprecated in drupal:10.1.0 and will be required in drupal:11.0.0. See https://www.drupal.org/node/2876656', E_USER_DEPRECATED); 69 $renderer = \Drupal::service('renderer'); 70 } 71 $this->renderer = $renderer; 72 } 66 $this->entityRepository = $entity_repository; 67 if ($this->renderer === NULL) { 68 @trigger_error('Calling ' . __METHOD__ . '() without the $renderer argument is deprecated in drupal:10.1.0 and will be required in drupal:11.0.0. See https://www.drupal.org/node/2876656', E_USER_DEPRECATED); 69 $this->renderer = \Drupal::service('renderer'); 70 } 71 }
@@ -66,7 +79,8 @@ public static function create(ContainerInterface $container) {
@@ -235,7 +249,7 @@ protected function bookAdminTableTree(array $tree, array &$form) {