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 Psr\Container\ContainerInterface as PsrContainerInterface;
15 use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
16 use Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException;
17 use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
20 * ContainerInterface is the interface implemented by service container classes.
22 * @author Fabien Potencier <fabien@symfony.com>
23 * @author Johannes M. Schmitt <schmittjoh@gmail.com>
25 interface ContainerInterface extends PsrContainerInterface
27 const EXCEPTION_ON_INVALID_REFERENCE = 1;
28 const NULL_ON_INVALID_REFERENCE = 2;
29 const IGNORE_ON_INVALID_REFERENCE = 3;
30 const IGNORE_ON_UNINITIALIZED_REFERENCE = 4;
35 * @param string $id The service identifier
36 * @param object $service The service instance
38 public function set($id, $service);
43 * @param string $id The service identifier
44 * @param int $invalidBehavior The behavior when the service does not exist
46 * @return object The associated service
48 * @throws ServiceCircularReferenceException When a circular reference is detected
49 * @throws ServiceNotFoundException When the service is not defined
53 public function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE);
56 * Returns true if the given service is defined.
58 * @param string $id The service identifier
60 * @return bool true if the service is defined, false otherwise
62 public function has($id);
65 * Check for whether or not a service has been initialized.
69 * @return bool true if the service has been initialized, false otherwise
71 public function initialized($id);
76 * @param string $name The parameter name
78 * @return mixed The parameter value
80 * @throws InvalidArgumentException if the parameter is not defined
82 public function getParameter($name);
85 * Checks if a parameter exists.
87 * @param string $name The parameter name
89 * @return bool The presence of parameter in container
91 public function hasParameter($name);
96 * @param string $name The parameter name
97 * @param mixed $value The parameter value
99 public function setParameter($name, $value);