This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/src/Symfony/Component/DependencyInjection/ContainerInterface.php

159 lines
3.5 KiB
PHP
Raw Normal View History

2010-01-04 14:26:20 +00:00
<?php
/*
* This file is part of the Symfony package.
2010-01-04 14:26:20 +00:00
*
* (c) Fabien Potencier <fabien@symfony.com>
2010-01-04 14:26:20 +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
*/
namespace Symfony\Component\DependencyInjection;
2010-01-04 14:26:20 +00:00
/**
* ContainerInterface is the interface implemented by service container classes.
*
* @author Fabien Potencier <fabien@symfony.com>
2011-01-17 22:28:59 +00:00
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
*
* @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
*
* @api
2010-06-27 17:28:29 +01:00
*/
2012-07-09 13:38:28 +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 17:56:32 +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
*
* @throws \InvalidArgumentException if the service is not defined
*
* @see Reference
*
* @api
2010-06-27 17:28:29 +01:00
*/
2012-07-09 13:38:28 +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 17:56:32 +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
*
* @api
2010-06-27 17:28:29 +01:00
*/
2012-07-09 13:38:28 +01:00
public function has($id);
2011-01-17 22:28:59 +00:00
/**
* Gets a parameter.
*
2012-05-15 17:56:32 +01:00
* @param string $name The parameter name
*
* @return mixed The parameter value
*
* @throws \InvalidArgumentException if the parameter is not defined
*
* @api
*/
2012-07-09 13:38:28 +01:00
public function getParameter($name);
/**
* Checks if a parameter exists.
*
2012-05-15 17:56:32 +01:00
* @param string $name The parameter name
*
* @return Boolean The presence of parameter in container
*
* @api
*/
2012-07-09 13:38:28 +01:00
public 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
*
* @api
*/
2012-07-09 13:38:28 +01:00
public 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
*
* @api
2011-01-17 22:28:59 +00:00
*/
2012-07-09 13:38:28 +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-12-13 07:50:54 +00:00
*
2011-01-17 22:28:59 +00:00
* @return void
*
* @api
2011-01-17 22:28:59 +00:00
*/
2012-07-09 13:38:28 +01:00
public function leaveScope($name);
2011-01-17 22:28:59 +00:00
/**
* Adds a scope to the container
*
* @param ScopeInterface $scope
2011-12-13 07:50:54 +00:00
*
2011-01-17 22:28:59 +00:00
* @return void
*
* @api
2011-01-17 22:28:59 +00:00
*/
2012-07-09 13:38:28 +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
*
* @api
2011-01-17 22:28:59 +00:00
*/
2012-07-09 13:38:28 +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
*
* @api
2011-01-17 22:28:59 +00:00
*/
2012-07-09 13:38:28 +01:00
public function isScopeActive($name);
2010-01-04 14:26:20 +00:00
}