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;
|
|
|
|
|
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>
|
2011-07-20 09:50:27 +01:00
|
|
|
*
|
|
|
|
* @api
|
2010-01-04 14:26:20 +00:00
|
|
|
*/
|
|
|
|
interface ContainerInterface
|
|
|
|
{
|
2010-06-27 17:28:29 +01:00
|
|
|
const EXCEPTION_ON_INVALID_REFERENCE = 1;
|
|
|
|
const NULL_ON_INVALID_REFERENCE = 2;
|
|
|
|
const IGNORE_ON_INVALID_REFERENCE = 3;
|
2011-01-17 22:28:59 +00:00
|
|
|
const SCOPE_CONTAINER = 'container';
|
|
|
|
const SCOPE_PROTOTYPE = 'prototype';
|
2010-06-27 17:28:29 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets a service.
|
|
|
|
*
|
|
|
|
* @param string $id The service identifier
|
|
|
|
* @param object $service The service instance
|
2011-01-17 22:28:59 +00:00
|
|
|
* @param string $scope The scope of the service
|
2011-07-20 09:50:27 +01:00
|
|
|
*
|
|
|
|
* @api
|
2010-06-27 17:28:29 +01:00
|
|
|
*/
|
2012-07-09 13:50:58 +01:00
|
|
|
public function set($id, $service, $scope = self::SCOPE_CONTAINER);
|
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
|
|
|
|
*
|
2011-12-04 23:51:22 +00:00
|
|
|
* @throws InvalidArgumentException if the service is not defined
|
2012-09-07 23:56:45 +01:00
|
|
|
* @throws ServiceCircularReferenceException When a circular reference is detected
|
|
|
|
* @throws ServiceNotFoundException When the service is not defined
|
2010-06-27 17:28:29 +01:00
|
|
|
*
|
|
|
|
* @see Reference
|
2011-07-20 09:50:27 +01:00
|
|
|
*
|
|
|
|
* @api
|
2010-06-27 17:28:29 +01:00
|
|
|
*/
|
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
|
|
|
*
|
|
|
|
* @return Boolean true if the service is defined, false otherwise
|
2011-07-20 09:50:27 +01:00
|
|
|
*
|
|
|
|
* @api
|
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
|
|
|
|
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
|
|
|
*
|
|
|
|
* @return mixed The parameter value
|
|
|
|
*
|
2011-12-04 23:51:22 +00:00
|
|
|
* @throws InvalidArgumentException if the parameter is not defined
|
2011-07-20 09:50:27 +01:00
|
|
|
*
|
|
|
|
* @api
|
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
|
|
|
*
|
|
|
|
* @return Boolean The presence of parameter in container
|
2011-07-20 09:50:27 +01:00
|
|
|
*
|
|
|
|
* @api
|
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-07-20 09:50:27 +01:00
|
|
|
*
|
|
|
|
* @api
|
2011-01-27 07:42:22 +00:00
|
|
|
*/
|
2012-07-09 13:50:58 +01:00
|
|
|
public function setParameter($name, $value);
|
2011-01-27 07:42:22 +00:00
|
|
|
|
2011-01-17 22:28:59 +00:00
|
|
|
/**
|
|
|
|
* Enters the given scope
|
|
|
|
*
|
|
|
|
* @param string $name
|
2011-07-20 09:50:27 +01:00
|
|
|
*
|
|
|
|
* @api
|
2011-01-17 22:28:59 +00:00
|
|
|
*/
|
2012-07-09 13:50:58 +01:00
|
|
|
public function enterScope($name);
|
2011-01-17 22:28:59 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Leaves the current scope, and re-enters the parent scope
|
|
|
|
*
|
|
|
|
* @param string $name
|
2011-07-20 09:50:27 +01:00
|
|
|
*
|
|
|
|
* @api
|
2011-01-17 22:28:59 +00:00
|
|
|
*/
|
2012-07-09 13:50:58 +01:00
|
|
|
public function leaveScope($name);
|
2011-01-17 22:28:59 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds a scope to the container
|
|
|
|
*
|
2011-02-13 09:33:53 +00:00
|
|
|
* @param ScopeInterface $scope
|
2011-07-20 09:50:27 +01:00
|
|
|
*
|
|
|
|
* @api
|
2011-01-17 22:28:59 +00:00
|
|
|
*/
|
2012-07-09 13:50:58 +01:00
|
|
|
public function addScope(ScopeInterface $scope);
|
2011-01-17 22:28:59 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether this container has the given scope
|
|
|
|
*
|
|
|
|
* @param string $name
|
2011-12-13 07:50:54 +00:00
|
|
|
*
|
2011-01-17 22:28:59 +00:00
|
|
|
* @return Boolean
|
2011-07-20 09:50:27 +01:00
|
|
|
*
|
|
|
|
* @api
|
2011-01-17 22:28:59 +00:00
|
|
|
*/
|
2012-07-09 13:50:58 +01:00
|
|
|
public function hasScope($name);
|
2011-01-17 22:28:59 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Determines whether the given scope is currently active.
|
|
|
|
*
|
|
|
|
* It does however not check if the scope actually exists.
|
|
|
|
*
|
2011-02-13 18:06:41 +00:00
|
|
|
* @param string $name
|
2011-12-13 07:50:54 +00:00
|
|
|
*
|
2011-01-17 22:28:59 +00:00
|
|
|
* @return Boolean
|
2011-07-20 09:50:27 +01:00
|
|
|
*
|
|
|
|
* @api
|
2011-01-17 22:28:59 +00:00
|
|
|
*/
|
2012-07-09 13:50:58 +01:00
|
|
|
public function isScopeActive($name);
|
2010-01-04 14:26:20 +00:00
|
|
|
}
|