I’m new to drupal 8. I would like to extend the user login form by deleting the username field and adding the email field. So I created a custom module, I implemented an Event Subscriber and declared it as a service :
services: mdmuser.route_subscriber: class: Drupalmdm_userRoutingRouteSubscriber tags: - {name: event_subscriber }
And here’s my class RouteSubscriber
<?php /** * @file * Contains Drupalmdm_userRoutingRouteSubscriber. */ namespace Drupalmdm_userRouting; use DrupalCoreRoutingRouteSubscriberBase; use SymfonyComponentRoutingRouteCollection; /** * Listens to the dynamic route events. */ class RouteSubscriber extends RouteSubscriberBase { protected function alterRoutes(RouteCollection $collection) { if ($route = $collection->get('user.login')) { $route->setDefault('_form', 'Drupalmdm_userFormUserLoginForm'); $collection->add('user.login', $route); } } }
I have this error when I want to install my new module :
ReflectionException: Class Drupalmdm_userRoutingRouteSubscriber does not exist in ReflectionClass->__construct() (line 31 of core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterEventSubscribersPass.php).
Any idea is appreciated !
Thanks
Sponsored by SupremePR