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;
33 * @param string $id The service identifier
34 * @param object $service The service instance
36 public function set($id, $service);
41 * @param string $id The service identifier
42 * @param int $invalidBehavior The behavior when the service does not exist
44 * @return object The associated service
46 * @throws ServiceCircularReferenceException When a circular reference is detected
47 * @throws ServiceNotFoundException When the service is not defined
51 public function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE);
54 * Returns true if the given service is defined.
56 * @param string $id The service identifier
58 * @return bool true if the service is defined, false otherwise
60 public function has($id);
63 * Check for whether or not a service has been initialized.
67 * @return bool true if the service has been initialized, false otherwise
69 public function initialized($id);
74 * @param string $name The parameter name
76 * @return mixed The parameter value
78 * @throws InvalidArgumentException if the parameter is not defined
80 public function getParameter($name);
83 * Checks if a parameter exists.
85 * @param string $name The parameter name
87 * @return bool The presence of parameter in container
89 public function hasParameter($name);
94 * @param string $name The parameter name
95 * @param mixed $value The parameter value
97 public function setParameter($name, $value);