Closed
Description
This type of injection is especially useful for code that is container aware (especially controllers).
<?php
abstract class MyController
{
/**
* @MethodInjection
* @return Symfony\Component\HttpFoundation\Request
*/
abstract function getRequest();
}
The abstract method would be implemented by the service container behind the scenes:
<?php
class ConcreteController extends MyController
{
private $container;
public function getRequest()
{
return $this->container->get('request');
}
}
The benefit is less code to write, IDE autocompletion, and no container dependency in the abstract class.