Yaffs site version 1.1
[yaffs-website] / vendor / symfony / dependency-injection / ContainerInterface.php
1 <?php
2
3 /*
4  * This file is part of the Symfony package.
5  *
6  * (c) Fabien Potencier <fabien@symfony.com>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11
12 namespace Symfony\Component\DependencyInjection;
13
14 use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
15 use Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException;
16 use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
17
18 /**
19  * ContainerInterface is the interface implemented by service container classes.
20  *
21  * @author Fabien Potencier <fabien@symfony.com>
22  * @author Johannes M. Schmitt <schmittjoh@gmail.com>
23  */
24 interface ContainerInterface
25 {
26     const EXCEPTION_ON_INVALID_REFERENCE = 1;
27     const NULL_ON_INVALID_REFERENCE = 2;
28     const IGNORE_ON_INVALID_REFERENCE = 3;
29     const SCOPE_CONTAINER = 'container';
30     const SCOPE_PROTOTYPE = 'prototype';
31
32     /**
33      * Sets a service.
34      *
35      * Note: The $scope parameter is deprecated since version 2.8 and will be removed in 3.0.
36      *
37      * @param string $id      The service identifier
38      * @param object $service The service instance
39      * @param string $scope   The scope of the service
40      */
41     public function set($id, $service, $scope = self::SCOPE_CONTAINER);
42
43     /**
44      * Gets a service.
45      *
46      * @param string $id              The service identifier
47      * @param int    $invalidBehavior The behavior when the service does not exist
48      *
49      * @return object The associated service
50      *
51      * @throws ServiceCircularReferenceException When a circular reference is detected
52      * @throws ServiceNotFoundException          When the service is not defined
53      *
54      * @see Reference
55      */
56     public function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE);
57
58     /**
59      * Returns true if the given service is defined.
60      *
61      * @param string $id The service identifier
62      *
63      * @return bool true if the service is defined, false otherwise
64      */
65     public function has($id);
66
67     /**
68      * Gets a parameter.
69      *
70      * @param string $name The parameter name
71      *
72      * @return mixed The parameter value
73      *
74      * @throws InvalidArgumentException if the parameter is not defined
75      */
76     public function getParameter($name);
77
78     /**
79      * Checks if a parameter exists.
80      *
81      * @param string $name The parameter name
82      *
83      * @return bool The presence of parameter in container
84      */
85     public function hasParameter($name);
86
87     /**
88      * Sets a parameter.
89      *
90      * @param string $name  The parameter name
91      * @param mixed  $value The parameter value
92      */
93     public function setParameter($name, $value);
94
95     /**
96      * Enters the given scope.
97      *
98      * @param string $name
99      *
100      * @deprecated since version 2.8, to be removed in 3.0.
101      */
102     public function enterScope($name);
103
104     /**
105      * Leaves the current scope, and re-enters the parent scope.
106      *
107      * @param string $name
108      *
109      * @deprecated since version 2.8, to be removed in 3.0.
110      */
111     public function leaveScope($name);
112
113     /**
114      * Adds a scope to the container.
115      *
116      * @param ScopeInterface $scope
117      *
118      * @deprecated since version 2.8, to be removed in 3.0.
119      */
120     public function addScope(ScopeInterface $scope);
121
122     /**
123      * Whether this container has the given scope.
124      *
125      * @param string $name
126      *
127      * @return bool
128      *
129      * @deprecated since version 2.8, to be removed in 3.0.
130      */
131     public function hasScope($name);
132
133     /**
134      * Determines whether the given scope is currently active.
135      *
136      * It does however not check if the scope actually exists.
137      *
138      * @param string $name
139      *
140      * @return bool
141      *
142      * @deprecated since version 2.8, to be removed in 3.0.
143      */
144     public function isScopeActive($name);
145 }