Issue #2105693 by cilefen | jhodgdon: Fixed ContainerInjectionInterface docs need update.

8.0.x
Alex Pott 2014-11-08 12:44:46 -08:00
parent 0506d2cb3b
commit 957078ec26
1 changed files with 8 additions and 15 deletions

View File

@ -10,30 +10,23 @@ namespace Drupal\Core\DependencyInjection;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Defines a common interface for route controllers.
* Defines a common interface for dependency container injection.
*
* This interface gives controller classes a factory method for instantiation
* rather than relying on a services.yml entry. However, it may result in
* a lot of boilerplate code in the class. As an alternative, controllers that
* contain only limited glue code ("thin" controllers) should instead extend
* ControllerBase as that allows direct access to the container. That renders
* the controller very difficult to unit test so should only be used for
* controllers that are trivial in complexity.
*
* @ingroup menu
* This interface gives classes who need services a factory method for
* instantiation rather than defining a new service.
*/
interface ContainerInjectionInterface {
/**
* Instantiates a new instance of this controller.
* Instantiates a new instance of this class.
*
* This is a factory method that returns a new instance of this object. The
* This is a factory method that returns a new instance of this class. The
* factory should pass any needed dependencies into the constructor of this
* object, but not the container itself. Every call to this method must return
* a new instance of this object; that is, it may not implement a singleton.
* class, but not the container itself. Every call to this method must return
* a new instance of this class; that is, it may not implement a singleton.
*
* @param \Symfony\Component\DependencyInjection\ContainerInterface $container
* The service container this object should use.
* The service container this instance should use.
*/
public static function create(ContainerInterface $container);
}