Problem/Motivation

When autowiring a repository class (NodeRepository for example) matching service cannot be found. This is because there is a backslash in front of the Drupal namespace.

Steps to reproduce

Create a service and class.
for the service, set autowire to true
In the class, autowire NodeRepository in the constructor:

  public function __construct(
    protected NodeRepository $nodeRepository
  ) {}

Proposed resolution

Remove \ infront of Drupal namespace in services file.

CommentFileSizeAuthor
#3 3391901.patch1.53 KBmauro_
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Mauro_ created an issue. See original summary.

mauro_’s picture

Status: Active » Needs review
StatusFileSize
new1.53 KB

Here's a patch

mauro_’s picture

Assigned: mauro_ » Unassigned
jeroent’s picture

Status: Needs review » Fixed

Merged to 2.0.x. Thanks!

jeroent’s picture

  • JeroenT committed 52bdf7de on 2.0.x authored by Mauro_
    Issue #3391901 by Mauro_, JeroenT: Slash prefix prevents autowiring from...

Status: Fixed » Closed (fixed)

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