- Issue created by @angelamnr
Drupal has been expanding its support of services that can have their arguments autowired. One exciting new example of this is the ability to use object-oriented hooks in Drupal 11.
When adding the externalauth.authmap service to an autowired hook class, I ran into this error:
Cannot autowire service "Drupal\custom_module\Hook\MyCustomHooks": argument "$authmap" of method "__construct()" references interface "Drupal\externalauth\AuthmapInterface" but no such service exists. You should maybe alias this interface to the existing "externalauth.authmap" service.
<?php
namespace Drupal\custom_module\Hook;
use Drupal\externalauth\AuthmapInterface;
class MyCustomHooks {
public function __construct(
private AuthmapInterface $authmap,
) {}
...
}
Create aliases for externalauth.authmap and externalauth.externalauth in externalauth.services.yml.
Active
2.0
Code