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\Loader\Configurator; Chris@14: Chris@14: use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; Chris@14: Chris@14: /** Chris@14: * @author Nicolas Grekas
Chris@14: * Chris@14: * @method InstanceofConfigurator instanceof(string $fqcn) Chris@14: */ Chris@14: class DefaultsConfigurator extends AbstractServiceConfigurator Chris@14: { Chris@14: const FACTORY = 'defaults'; Chris@14: Chris@14: use Traits\AutoconfigureTrait; Chris@14: use Traits\AutowireTrait; Chris@14: use Traits\BindTrait; Chris@14: use Traits\PublicTrait; Chris@14: Chris@14: /** Chris@14: * Adds a tag for this definition. Chris@14: * Chris@14: * @param string $name The tag name Chris@14: * @param array $attributes An array of attributes Chris@14: * Chris@14: * @return $this Chris@14: * Chris@14: * @throws InvalidArgumentException when an invalid tag name or attribute is provided Chris@14: */ Chris@17: final public function tag($name, array $attributes = []) Chris@14: { Chris@17: if (!\is_string($name) || '' === $name) { Chris@14: throw new InvalidArgumentException('The tag name in "_defaults" must be a non-empty string.'); Chris@14: } Chris@14: Chris@14: foreach ($attributes as $attribute => $value) { Chris@14: if (!is_scalar($value) && null !== $value) { Chris@14: throw new InvalidArgumentException(sprintf('Tag "%s", attribute "%s" in "_defaults" must be of a scalar-type.', $name, $attribute)); Chris@14: } Chris@14: } Chris@14: Chris@14: $this->definition->addTag($name, $attributes); Chris@14: Chris@14: return $this; Chris@14: } Chris@14: Chris@14: /** Chris@14: * Defines an instanceof-conditional to be applied to following service definitions. Chris@14: * Chris@14: * @param string $fqcn Chris@14: * Chris@14: * @return InstanceofConfigurator Chris@14: */ Chris@14: final protected function setInstanceof($fqcn) Chris@14: { Chris@14: return $this->parent->instanceof($fqcn); Chris@14: } Chris@14: }