1: <?php
2: /**
3: * This file is part of the Autarky package.
4: *
5: * (c) Andreas Lutro <anlutro@gmail.com>
6: *
7: * For the full copyright and license information, please view the LICENSE
8: * file that was distributed with this source code.
9: */
10:
11: namespace Autarky\Container;
12:
13: /**
14: * Interface for container-aware classes.
15: *
16: * A container-aware class is a class that is aware of the framework's service
17: * container, and can thereby both bind objects onto the container and resolve
18: * items from it.
19: *
20: * Container-aware classes should be used sparingly and usually only at the top
21: * level of your class hierarchy, as they tightly couple your class to this
22: * framework's service container. Web controllers are a common use case for
23: * container-aware classes, as controllers often need to resolve many types of
24: * services - the session, router, templating engine and so on.
25: *
26: * Other parts of the framework can do an "instanceof ContainerAwareInterface"
27: * to determine if the container should be set on the class or not, without
28: * requiring it to be specified in the constructor and without having to
29: * resolve to static/global function calls.
30: */
31: interface ContainerAwareInterface
32: {
33: /**
34: * Set the container instance.
35: *
36: * @param ContainerInterface $container
37: */
38: public function setContainer(ContainerInterface $container);
39: }
40: