MergeBuilder.php 1.3 KB

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