Chris@14: Chris@14: * Chris@14: * For the full copyright and license information, please view the LICENSE Chris@14: * file that was distributed with this source code. Chris@14: */ Chris@14: Chris@14: namespace Symfony\Component\DependencyInjection\Argument; Chris@14: Chris@14: use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; Chris@14: use Symfony\Component\DependencyInjection\Reference; Chris@14: Chris@14: /** Chris@14: * Represents a service wrapped in a memoizing closure. Chris@14: * Chris@14: * @author Nicolas Grekas
Chris@14: */ Chris@14: class ServiceClosureArgument implements ArgumentInterface Chris@14: { Chris@14: private $values; Chris@14: Chris@14: public function __construct(Reference $reference) Chris@14: { Chris@17: $this->values = [$reference]; Chris@14: } Chris@14: Chris@14: /** Chris@14: * {@inheritdoc} Chris@14: */ Chris@14: public function getValues() Chris@14: { Chris@14: return $this->values; Chris@14: } Chris@14: Chris@14: /** Chris@14: * {@inheritdoc} Chris@14: */ Chris@14: public function setValues(array $values) Chris@14: { Chris@17: if ([0] !== array_keys($values) || !($values[0] instanceof Reference || null === $values[0])) { Chris@14: throw new InvalidArgumentException('A ServiceClosureArgument must hold one and only one Reference.'); Chris@14: } Chris@14: Chris@14: $this->values = $values; Chris@14: } Chris@14: }