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/Reference.php

71 lines
1.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
/**
* Reference represents a service reference.
*
* @author Fabien Potencier <fabien@symfony.com>
2010-01-04 14:26:20 +00:00
*/
class Reference
{
private $id;
private $invalidBehavior;
private $strict;
2010-01-04 14:26:20 +00:00
/**
* Constructor.
*
2011-01-17 22:28:59 +00:00
* @param string $id The service identifier
* @param int $invalidBehavior The behavior when the service does not exist
* @param Boolean $strict Sets how this reference is validated
*
* @see Container
*/
2011-01-17 22:28:59 +00:00
public function __construct($id, $invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, $strict = true)
{
$this->id = $id;
$this->invalidBehavior = $invalidBehavior;
2011-01-17 22:28:59 +00:00
$this->strict = $strict;
}
2010-01-04 14:26:20 +00:00
/**
* __toString.
*
* @return string The service identifier
*/
public function __toString()
{
return (string) $this->id;
}
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
*/
public function getInvalidBehavior()
{
return $this->invalidBehavior;
}
2011-01-17 22:28:59 +00:00
2011-02-13 18:06:41 +00:00
/**
* Returns true when this Reference is strict
*
* @return boolean
*/
2011-01-17 22:28:59 +00:00
public function isStrict()
{
return $this->strict;
}
2010-01-04 14:26:20 +00:00
}