2010-01-04 14:26:20 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
2011-01-15 13:29:43 +00:00
|
|
|
* This file is part of the Symfony package.
|
2010-01-04 14:26:20 +00:00
|
|
|
*
|
2011-03-06 11:40:06 +00:00
|
|
|
* (c) Fabien Potencier <fabien@symfony.com>
|
2010-01-04 14:26:20 +00:00
|
|
|
*
|
2011-01-15 13:29:43 +00:00
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
2010-01-04 14:26:20 +00:00
|
|
|
*/
|
|
|
|
|
2011-01-15 13:29:43 +00:00
|
|
|
namespace Symfony\Component\DependencyInjection;
|
|
|
|
|
2017-01-12 22:20:30 +00:00
|
|
|
use Psr\Container\ContainerInterface as PsrContainerInterface;
|
2011-12-05 17:52:25 +00:00
|
|
|
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
|
2012-09-07 23:56:45 +01:00
|
|
|
use Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException;
|
|
|
|
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
|
2011-12-05 17:52:25 +00:00
|
|
|
|
2010-01-04 14:26:20 +00:00
|
|
|
/**
|
|
|
|
* ContainerInterface is the interface implemented by service container classes.
|
|
|
|
*
|
2011-03-06 11:40:06 +00:00
|
|
|
* @author Fabien Potencier <fabien@symfony.com>
|
2011-01-17 22:28:59 +00:00
|
|
|
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
2010-01-04 14:26:20 +00:00
|
|
|
*/
|
2017-01-12 22:20:30 +00:00
|
|
|
interface ContainerInterface extends PsrContainerInterface
|
2010-01-04 14:26:20 +00:00
|
|
|
{
|
2010-06-27 17:28:29 +01:00
|
|
|
const EXCEPTION_ON_INVALID_REFERENCE = 1;
|
2014-10-22 19:27:13 +01:00
|
|
|
const NULL_ON_INVALID_REFERENCE = 2;
|
|
|
|
const IGNORE_ON_INVALID_REFERENCE = 3;
|
2017-08-30 08:27:55 +01:00
|
|
|
const IGNORE_ON_UNINITIALIZED_REFERENCE = 4;
|
2010-06-27 17:28:29 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets a service.
|
|
|
|
*
|
|
|
|
* @param string $id The service identifier
|
|
|
|
* @param object $service The service instance
|
|
|
|
*/
|
2015-09-04 20:54:37 +01:00
|
|
|
public function set($id, $service);
|
2010-06-27 17:28:29 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets a service.
|
|
|
|
*
|
2012-05-15 21:19:31 +01:00
|
|
|
* @param string $id The service identifier
|
|
|
|
* @param int $invalidBehavior The behavior when the service does not exist
|
2010-06-27 17:28:29 +01:00
|
|
|
*
|
|
|
|
* @return object The associated service
|
|
|
|
*
|
2012-09-07 23:56:45 +01:00
|
|
|
* @throws ServiceCircularReferenceException When a circular reference is detected
|
2014-11-30 13:33:44 +00:00
|
|
|
* @throws ServiceNotFoundException When the service is not defined
|
2010-06-27 17:28:29 +01:00
|
|
|
*
|
|
|
|
* @see Reference
|
|
|
|
*/
|
2012-07-09 13:50:58 +01:00
|
|
|
public function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE);
|
2010-06-27 17:28:29 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if the given service is defined.
|
|
|
|
*
|
2012-05-15 21:19:31 +01:00
|
|
|
* @param string $id The service identifier
|
2010-06-27 17:28:29 +01:00
|
|
|
*
|
2014-11-30 13:33:44 +00:00
|
|
|
* @return bool true if the service is defined, false otherwise
|
2010-06-27 17:28:29 +01:00
|
|
|
*/
|
2012-07-09 13:50:58 +01:00
|
|
|
public function has($id);
|
2011-01-17 22:28:59 +00:00
|
|
|
|
2015-07-23 11:18:12 +01:00
|
|
|
/**
|
|
|
|
* Check for whether or not a service has been initialized.
|
|
|
|
*
|
|
|
|
* @param string $id
|
|
|
|
*
|
|
|
|
* @return bool true if the service has been initialized, false otherwise
|
|
|
|
*/
|
|
|
|
public function initialized($id);
|
|
|
|
|
2011-01-27 07:42:22 +00:00
|
|
|
/**
|
|
|
|
* Gets a parameter.
|
|
|
|
*
|
2012-05-15 21:19:31 +01:00
|
|
|
* @param string $name The parameter name
|
2011-01-27 07:42:22 +00:00
|
|
|
*
|
2014-11-30 13:33:44 +00:00
|
|
|
* @return mixed The parameter value
|
2011-01-27 07:42:22 +00:00
|
|
|
*
|
2011-12-04 23:51:22 +00:00
|
|
|
* @throws InvalidArgumentException if the parameter is not defined
|
2011-01-27 07:42:22 +00:00
|
|
|
*/
|
2012-07-09 13:50:58 +01:00
|
|
|
public function getParameter($name);
|
2011-01-27 07:42:22 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks if a parameter exists.
|
|
|
|
*
|
2012-05-15 21:19:31 +01:00
|
|
|
* @param string $name The parameter name
|
2011-01-27 07:42:22 +00:00
|
|
|
*
|
2014-11-30 13:33:44 +00:00
|
|
|
* @return bool The presence of parameter in container
|
2011-01-27 07:42:22 +00:00
|
|
|
*/
|
2012-07-09 13:50:58 +01:00
|
|
|
public function hasParameter($name);
|
2011-01-27 07:42:22 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets a parameter.
|
|
|
|
*
|
2011-04-23 16:05:44 +01:00
|
|
|
* @param string $name The parameter name
|
|
|
|
* @param mixed $value The parameter value
|
2011-01-27 07:42:22 +00:00
|
|
|
*/
|
2012-07-09 13:50:58 +01:00
|
|
|
public function setParameter($name, $value);
|
2010-01-04 14:26:20 +00:00
|
|
|
}
|