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
|
|
|
/**
|
|
|
|
* Reference represents a service reference.
|
|
|
|
*
|
2011-03-06 11:40:06 +00:00
|
|
|
* @author Fabien Potencier <fabien@symfony.com>
|
2010-01-04 14:26:20 +00:00
|
|
|
*/
|
|
|
|
class Reference
|
|
|
|
{
|
2011-03-11 13:50:46 +00:00
|
|
|
private $id;
|
|
|
|
private $invalidBehavior;
|
2010-01-04 14:26:20 +00:00
|
|
|
|
2010-05-06 12:25:53 +01:00
|
|
|
/**
|
2014-11-30 13:33:44 +00:00
|
|
|
* @param string $id The service identifier
|
|
|
|
* @param int $invalidBehavior The behavior when the service does not exist
|
2010-05-06 12:25:53 +01:00
|
|
|
*
|
|
|
|
* @see Container
|
|
|
|
*/
|
2015-09-04 20:54:37 +01:00
|
|
|
public function __construct($id, $invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE)
|
2010-05-06 12:25:53 +01:00
|
|
|
{
|
2017-03-27 18:51:07 +01:00
|
|
|
$this->id = (string) $id;
|
2010-05-06 12:25:53 +01:00
|
|
|
$this->invalidBehavior = $invalidBehavior;
|
|
|
|
}
|
2010-01-04 14:26:20 +00:00
|
|
|
|
2010-05-06 12:25:53 +01:00
|
|
|
/**
|
|
|
|
* @return string The service identifier
|
|
|
|
*/
|
|
|
|
public function __toString()
|
|
|
|
{
|
2013-06-05 00:48:30 +01:00
|
|
|
return $this->id;
|
2010-05-06 12:25:53 +01:00
|
|
|
}
|
2010-01-04 14:26:20 +00:00
|
|
|
|
2011-02-13 18:06:41 +00:00
|
|
|
/**
|
|
|
|
* Returns the behavior to be used when the service does not exist.
|
|
|
|
*
|
|
|
|
* @return int
|
|
|
|
*/
|
2010-05-06 12:25:53 +01:00
|
|
|
public function getInvalidBehavior()
|
|
|
|
{
|
|
|
|
return $this->invalidBehavior;
|
|
|
|
}
|
2010-01-04 14:26:20 +00:00
|
|
|
}
|