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;
|
|
|
|
|
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
|
|
|
*/
|
2011-01-17 22:28:59 +00:00
|
|
|
function set($id, $service, $scope = self::SCOPE_CONTAINER);
|
2010-06-27 17:28:29 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets a service.
|
|
|
|
*
|
|
|
|
* @param string $id The service identifier
|
|
|
|
* @param int $invalidBehavior The behavior when the service does not exist
|
|
|
|
*
|
|
|
|
* @return object The associated service
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException if the service is not defined
|
|
|
|
*
|
|
|
|
* @see Reference
|
2011-07-20 09:50:27 +01:00
|
|
|
*
|
|
|
|
* @api
|
2010-06-27 17:28:29 +01:00
|
|
|
*/
|
2010-10-17 12:39:51 +01:00
|
|
|
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.
|
|
|
|
*
|
|
|
|
* @param string $id The service identifier
|
|
|
|
*
|
|
|
|
* @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
|
|
|
*/
|
2010-10-17 12:39:51 +01:00
|
|
|
function has($id);
|
2011-01-17 22:28:59 +00:00
|
|
|
|
2011-01-27 07:42:22 +00:00
|
|
|
/**
|
|
|
|
* Gets a parameter.
|
|
|
|
*
|
|
|
|
* @param string $name The parameter name
|
|
|
|
*
|
|
|
|
* @return mixed The parameter value
|
|
|
|
*
|
|
|
|
* @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
|
|
|
*/
|
|
|
|
function getParameter($name);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks if a parameter exists.
|
|
|
|
*
|
|
|
|
* @param string $name The parameter name
|
|
|
|
*
|
|
|
|
* @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
|
|
|
*/
|
|
|
|
function hasParameter($name);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
*/
|
|
|
|
function setParameter($name, $value);
|
|
|
|
|
2011-01-17 22:28:59 +00:00
|
|
|
/**
|
|
|
|
* Enters the given scope
|
|
|
|
*
|
|
|
|
* @param string $name
|
2011-12-13 07:50:54 +00:00
|
|
|
*
|
2011-01-17 22:28:59 +00:00
|
|
|
* @return void
|
2011-07-20 09:50:27 +01:00
|
|
|
*
|
|
|
|
* @api
|
2011-01-17 22:28:59 +00:00
|
|
|
*/
|
|
|
|
function enterScope($name);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Leaves the current scope, and re-enters the parent scope
|
|
|
|
*
|
|
|
|
* @param string $name
|
2011-12-13 07:50:54 +00:00
|
|
|
*
|
2011-01-17 22:28:59 +00:00
|
|
|
* @return void
|
2011-07-20 09:50:27 +01:00
|
|
|
*
|
|
|
|
* @api
|
2011-01-17 22:28:59 +00:00
|
|
|
*/
|
|
|
|
function leaveScope($name);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds a scope to the container
|
|
|
|
*
|
2011-02-13 09:33:53 +00:00
|
|
|
* @param ScopeInterface $scope
|
2011-12-13 07:50:54 +00:00
|
|
|
*
|
2011-01-17 22:28:59 +00:00
|
|
|
* @return void
|
2011-07-20 09:50:27 +01:00
|
|
|
*
|
|
|
|
* @api
|
2011-01-17 22:28:59 +00:00
|
|
|
*/
|
2011-02-13 09:33:53 +00:00
|
|
|
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
|
|
|
*/
|
|
|
|
function hasScope($name);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
*/
|
|
|
|
function isScopeActive($name);
|
2010-01-04 14:26:20 +00:00
|
|
|
}
|