, ( ) .
Symfony\Bundle\FrameworkBundle\Controller, , forward() Request, HttpKernel. HttpKernel, .
, , :
$controller = new Your\Controller();
$controller->yourAction();
, :
$request = Symfony\Component\HttpFoundation\Request::createFromGlobals();
$controller = new Your\Controller();
$controller->setContainer($this->getContainer());
$controller->yourAction($request);
, , :
- Include your controller in the service, this is described in the cookbook and will mean that your controller and action can be called directly from the container that your command is (possibly) configured. This manages the dependencies your controller and actions may have.
- Separate the functionality you need from your action into your class or service. This is the best way forward, as if you were invoking the same bit of code in two places, it makes sense to centralize it somewhere.
source
share