Problem/Motivation

I use Drupal 11.3.
I created a Hook handler class, which is auto-wiring dependencies by default.
I don't need to declare the Hook service in the services.yml.
In my custom service I was not able to auto-wire the spamspan service.

Steps to reproduce

Create a custom service, and dependency inject the spamspan service.

Cannot autowire service: argument "$spamspan" of method "__construct()" references class "Drupal\spamspan\SpamspanService" but no such service exists. You should maybe alias this class to the existing "spamspan" service.

Proposed resolution

I found the solution here:
https://symfony.com/doc/3.x/service_container/autowiring.html#using-alia...

services:
  Drupal\spamspan\SpamspanService: '@spamspan'

Remaining tasks

I will create a merge request.

Issue fork spamspan-3570600

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

imre.horjan created an issue. See original summary.

imre.horjan’s picture

Title: Cannot autowire the spamspan service » Cannot auto-wire the spamspan service
Status: Needs work » Needs review
joevagyok’s picture

Status: Needs review » Reviewed & tested by the community

Thank you!

joevagyok’s picture

Status: Reviewed & tested by the community » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • imre.horjan committed 4d6308a1 on 3.x
    Issue #3570600: Alias classes to services for auto-wiring.
    

Status: Fixed » Closed (fixed)

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