i am in the process of upgrading a large application to 4.2
and the $this->get(".....")
from inside the controller is deprecated and one should use AutoWire instead.
i am running into the problem that i have 2 services, which are in fact from the same class (just diffrent constructor args).
services.yml
services:
service.a:
class: Namespace\MyClass
arguments: [ "argument1" ]
service.b:
class: Namespace\MyClass
arguments: [ "argument2" ]
controller:
public function demoAction() {
$serviceA = $this->get("service.a");
$serviceB = $this->get("service.b");
}
and the problematic result:
public function demoAction(MyClass $serviceA, MyClass $serviceB) {
}
we can use alias to service definitions like:
MyClass: '@service.a'
but i cannot use a virtual/fake class like (without an existing one):
MyPseudClass: '@service.b'
how do you handle cases like this in autowire mode?
i could create "pseudo" classes, that extend from the base, just to get different classnames, but that feels weird.