MergeBuilder.php 1.4 KB

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