Skip to main content
3 of 5
edited title
avpaderno
  • 97.9k
  • 15
  • 164
  • 284

How do I inject services in class that implements an interface

How do I inject services in a class that implements an interface.

class RoleNegotiator implements ThemeNegotiatorInterface {

  public static function create(ContainerInterface $interface) {
    return new static(
      $interface->get('router.admin_context')
    );
  }
  public function __construct(RouteMatchInterface $route) {
    $this->route = $route;
  }
}

The above code throws an error.

harsh_behl_0007
  • 1.2k
  • 1
  • 11
  • 21