In my application, I do not implemented everything inside the controller.
The controller calls methods on another class, which calls another class, but THAT class wishes to use a service like $this->get('service').
As an example:
public function controllerAction()
{
$obj = new SubClass1();
$obj->method();
}
class SubClass1
{
public function method()
{
$obj = new SubClass2();
$obj->method();
}
}
class SubClass2
{
public function method()
{
//Here I wish to use a Symfony Service.
}
}
Since the Service Container isn't global, both SubClass1 and SubClass2 must be declared as services, so Symfony will inject the services to them, although those classes are not really services in my application (They're being used once).
Do you have another solution to this? Am I holding a design mistake?
Thank you.