MergeBuilder.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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\Config\Definition\Builder;
  11. /**
  12. * This class builds merge conditions.
  13. *
  14. * @author Johannes M. Schmitt <schmittjoh@gmail.com>
  15. */
  16. class MergeBuilder
  17. {
  18. protected $node;
  19. public $allowFalse = false;
  20. public $allowOverwrite = true;
  21. public function __construct(NodeDefinition $node)
  22. {
  23. $this->node = $node;
  24. }
  25. /**
  26. * Sets whether the node can be unset.
  27. *
  28. * @return $this
  29. */
  30. public function allowUnset(bool $allow = true)
  31. {
  32. $this->allowFalse = $allow;
  33. return $this;
  34. }
  35. /**
  36. * Sets whether the node can be overwritten.
  37. *
  38. * @return $this
  39. */
  40. public function denyOverwrite(bool $deny = true)
  41. {
  42. $this->allowOverwrite = !$deny;
  43. return $this;
  44. }
  45. /**
  46. * Returns the related node.
  47. *
  48. * @return NodeDefinition|ArrayNodeDefinition|VariableNodeDefinition
  49. */
  50. public function end()
  51. {
  52. return $this->node;
  53. }
  54. }