InstanceofConfigurator.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\DependencyInjection\Loader\Configurator;
  11. use Symfony\Component\DependencyInjection\Definition;
  12. /**
  13. * @author Nicolas Grekas <p@tchwork.com>
  14. */
  15. class InstanceofConfigurator extends AbstractServiceConfigurator
  16. {
  17. public const FACTORY = 'instanceof';
  18. use Traits\AutowireTrait;
  19. use Traits\BindTrait;
  20. use Traits\CallTrait;
  21. use Traits\ConfiguratorTrait;
  22. use Traits\LazyTrait;
  23. use Traits\PropertyTrait;
  24. use Traits\PublicTrait;
  25. use Traits\ShareTrait;
  26. use Traits\TagTrait;
  27. private $path;
  28. public function __construct(ServicesConfigurator $parent, Definition $definition, string $id, string $path = null)
  29. {
  30. parent::__construct($parent, $definition, $id, []);
  31. $this->path = $path;
  32. }
  33. /**
  34. * Defines an instanceof-conditional to be applied to following service definitions.
  35. */
  36. final public function instanceof(string $fqcn): self
  37. {
  38. return $this->parent->instanceof($fqcn);
  39. }
  40. }