Issue #2834982: Replace non-test usages of \Drupal::service('renderer') with IoC injection
Merge request reports
Activity
51 54 * The image factory service. 52 55 */ 53 public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, array $third_party_settings, ElementInfoManagerInterface $element_info, ImageFactory $image_factory = NULL) { 54 parent::__construct($plugin_id, $plugin_definition, $field_definition, $settings, $third_party_settings, $element_info); 55 $this->imageFactory = $image_factory ?: \Drupal::service('image.factory'); 56 public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, array $third_party_settings, ElementInfoManagerInterface $element_info, RendererInterface $renderer = NULL, ImageFactory $image_factory = NULL) { 57 if (!$renderer) { 58 @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); 59 $renderer = \Drupal::service('renderer'); 60 } 61 parent::__construct($plugin_id, $plugin_definition, $field_definition, $settings, $third_party_settings, $element_info, $renderer); 62 if (!$image_factory) { 63 @trigger_error('Calling ' . __METHOD__ . '() without the $image_factory 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); 64 $image_factory = \Drupal::service('image.factory'); 65 } 66 $this->imageFactory = $image_factory; - Comment on lines +62 to +66
Should we do this at all? My reasoning here is that we're getting into a lot of moving arguments around if there's a NULL-able one before one that will become required in 11.0.x.
If we should do this, can we do this in this issue, or is this one for a separate issue, which would need to land first before we can commit this issue?
42 48 * Definition. 43 49 * @param \Drupal\filter\FilterPluginManager $filter_manager 44 50 * Filter plugin manager. 51 * @param \Drupal\Core\Render\RendererInterface $renderer 52 * The renderer service. 45 53 */ 46 public function __construct(array $configuration, $plugin_id, $plugin_definition, FilterPluginManager $filter_manager = NULL) { 54 public function __construct(array $configuration, $plugin_id, $plugin_definition, FilterPluginManager $filter_manager = NULL, RendererInterface $renderer = NULL) { 47 55 parent::__construct($configuration, $plugin_id, $plugin_definition); 48 $this->filterManager = $filter_manager ?: \Drupal::service('plugin.manager.filter'); 56 $this->filterManager = $filter_manager; 57 if (!$filter_manager) { 58 @trigger_error('Calling ' . __METHOD__ . '() without the $filter_manager 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); 59 $filter_manager = \Drupal::service('plugin.manager.filter'); 60 } 61 $this->filterManager = $filter_manager; - Comment on lines +56 to +61
Should we do this at all? My reasoning here is that we're getting into a lot of moving arguments around if there's a NULL-able one before one that will become required in 11.0.x.
If we should do this, can we do this in this issue, or is this one for a separate issue, which would need to land first before we can commit this issue?
51 57 * The book manager. 52 58 * @param \Drupal\Core\Entity\EntityRepositoryInterface $entity_repository 53 59 * The entity repository service. 60 * @param \Drupal\Core\Render\RendererInterface $renderer 61 * The renderer service. 54 62 */ 55 public function __construct(EntityStorageInterface $node_storage, BookManagerInterface $book_manager, EntityRepositoryInterface $entity_repository) { 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, RendererInterface $renderer = NULL) { 63 public function __construct(EntityStorageInterface $node_storage, BookManagerInterface $book_manager, EntityRepositoryInterface $entity_repository, protected RendererInterface $renderer = NULL) {
52 58 * @param \Drupal\Core\Entity\EntityRepositoryInterface $entity_repository 53 59 * The entity repository service. 60 * @param \Drupal\Core\Render\RendererInterface $renderer 61 * The renderer service. 54 62 */ 55 public function __construct(EntityStorageInterface $node_storage, BookManagerInterface $book_manager, EntityRepositoryInterface $entity_repository) { 63 public function __construct(EntityStorageInterface $node_storage, BookManagerInterface $book_manager, EntityRepositoryInterface $entity_repository, RendererInterface $renderer = NULL) { 56 64 $this->nodeStorage = $node_storage; 57 65 $this->bookManager = $book_manager; 58 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; 59 72 } - 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 }
22 24 */ 23 25 protected $build; 24 26 27 /** 28 * Constructs an EntityLink object. 29 * 30 * @param array $configuration 31 * A configuration array containing information about the plugin instance. 32 * @param string $plugin_id 33 * The plugin_id for the plugin instance. 34 * @param mixed $plugin_definition 35 * The plugin implementation definition. 36 * @param \Drupal\Core\Render\RendererInterface $renderer 37 * The renderer service. 38 */ 39 public function __construct(array $configuration, $plugin_id, $plugin_definition, RendererInterface $renderer = NULL) { 31 * A configuration array containing information about the plugin instance. 32 * @param string $plugin_id 33 * The plugin_id for the plugin instance. 34 * @param mixed $plugin_definition 35 * The plugin implementation definition. 36 * @param \Drupal\Core\Render\RendererInterface $renderer 37 * The renderer service. 38 */ 39 public function __construct(array $configuration, $plugin_id, $plugin_definition, RendererInterface $renderer = NULL) { 40 parent::__construct($configuration, $plugin_id, $plugin_definition); 41 if (!$renderer) { 42 @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); 43 $renderer = \Drupal::service('renderer'); 44 } 45 $this->renderer = $renderer; 46 } - Comment on lines +40 to +46
40 parent::__construct($configuration, $plugin_id, $plugin_definition); 41 if (!$renderer) { 42 @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); 43 $renderer = \Drupal::service('renderer'); 44 } 45 $this->renderer = $renderer; 46 } 40 parent::__construct($configuration, $plugin_id, $plugin_definition); 41 if ($this->renderer === NULL) { 42 @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); 43 $this->renderer = \Drupal::service('renderer'); 44 } 45 }
30 32 */ 31 33 public string $uid; 32 34 35 /** 36 * Constructs an StatisticsLastCommentName object. 37 * 38 * @param array $configuration 39 * A configuration array containing information about the plugin instance. 40 * @param string $plugin_id 41 * The plugin_id for the plugin instance. 42 * @param mixed $plugin_definition 43 * The plugin implementation definition. 44 * @param \Drupal\Core\Render\RendererInterface $renderer 45 * The renderer service. 46 */ 47 public function __construct(array $configuration, $plugin_id, $plugin_definition, RendererInterface $renderer = NULL) {
Please register or sign in to reply