MergeBuilder.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. /**
  22. * Constructor.
  23. *
  24. * @param NodeDefinition $node The related node
  25. */
  26. public function __construct(NodeDefinition $node)
  27. {
  28. $this->node = $node;
  29. }
  30. /**
  31. * Sets whether the node can be unset.
  32. *
  33. * @param bool $allow
  34. *
  35. * @return $this
  36. */
  37. public function allowUnset($allow = true)
  38. {
  39. $this->allowFalse = $allow;
  40. return $this;
  41. }
  42. /**
  43. * Sets whether the node can be overwritten.
  44. *
  45. * @param bool $deny Whether the overwriting is forbidden or not
  46. *
  47. * @return $this
  48. */
  49. public function denyOverwrite($deny = true)
  50. {
  51. $this->allowOverwrite = !$deny;
  52. return $this;
  53. }
  54. /**
  55. * Returns the related node.
  56. *
  57. * @return NodeDefinition|ArrayNodeDefinition|VariableNodeDefinition
  58. */
  59. public function end()
  60. {
  61. return $this->node;
  62. }
  63. }