ContainerInjectionInterface.php 942 B

12345678910111213141516171819202122232425262728
  1. <?php
  2. namespace Drupal\Core\DependencyInjection;
  3. use Symfony\Component\DependencyInjection\ContainerInterface;
  4. /**
  5. * Defines a common interface for dependency container injection.
  6. *
  7. * This interface gives classes who need services a factory method for
  8. * instantiation rather than defining a new service.
  9. */
  10. interface ContainerInjectionInterface {
  11. /**
  12. * Instantiates a new instance of this class.
  13. *
  14. * This is a factory method that returns a new instance of this class. The
  15. * factory should pass any needed dependencies into the constructor of this
  16. * class, but not the container itself. Every call to this method must return
  17. * a new instance of this class; that is, it may not implement a singleton.
  18. *
  19. * @param \Symfony\Component\DependencyInjection\ContainerInterface $container
  20. * The service container this instance should use.
  21. */
  22. public static function create(ContainerInterface $container);
  23. }