4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\DependencyInjection;
14 use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
15 use Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException;
16 use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
19 * ContainerInterface is the interface implemented by service container classes.
21 * @author Fabien Potencier <fabien@symfony.com>
22 * @author Johannes M. Schmitt <schmittjoh@gmail.com>
24 interface ContainerInterface
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';
35 * Note: The $scope parameter is deprecated since version 2.8 and will be removed in 3.0.
37 * @param string $id The service identifier
38 * @param object $service The service instance
39 * @param string $scope The scope of the service
41 public function set($id, $service, $scope = self::SCOPE_CONTAINER);
46 * @param string $id The service identifier
47 * @param int $invalidBehavior The behavior when the service does not exist
49 * @return object The associated service
51 * @throws ServiceCircularReferenceException When a circular reference is detected
52 * @throws ServiceNotFoundException When the service is not defined
56 public function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE);
59 * Returns true if the given service is defined.
61 * @param string $id The service identifier
63 * @return bool true if the service is defined, false otherwise
65 public function has($id);
70 * @param string $name The parameter name
72 * @return mixed The parameter value
74 * @throws InvalidArgumentException if the parameter is not defined
76 public function getParameter($name);
79 * Checks if a parameter exists.
81 * @param string $name The parameter name
83 * @return bool The presence of parameter in container
85 public function hasParameter($name);
90 * @param string $name The parameter name
91 * @param mixed $value The parameter value
93 public function setParameter($name, $value);
96 * Enters the given scope.
100 * @deprecated since version 2.8, to be removed in 3.0.
102 public function enterScope($name);
105 * Leaves the current scope, and re-enters the parent scope.
107 * @param string $name
109 * @deprecated since version 2.8, to be removed in 3.0.
111 public function leaveScope($name);
114 * Adds a scope to the container.
116 * @param ScopeInterface $scope
118 * @deprecated since version 2.8, to be removed in 3.0.
120 public function addScope(ScopeInterface $scope);
123 * Whether this container has the given scope.
125 * @param string $name
129 * @deprecated since version 2.8, to be removed in 3.0.
131 public function hasScope($name);
134 * Determines whether the given scope is currently active.
136 * It does however not check if the scope actually exists.
138 * @param string $name
142 * @deprecated since version 2.8, to be removed in 3.0.
144 public function isScopeActive($name);