ArrayConfig.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /**
  3. *
  4. * Cube Framework $Id$ /ZVI1gYKXMUOCygiAIbmFBSYJEeWQnG+letDA9Usx6I=
  5. *
  6. * @link http://codecu.be/framework
  7. * @copyright Copyright (c) 2015 CodeCube SRL
  8. * @license http://codecu.be/framework/license Commercial License
  9. *
  10. * @version 1.4
  11. */
  12. /**
  13. * array config object creator class
  14. */
  15. namespace Cube\Config;
  16. class ArrayConfig extends AbstractConfig
  17. {
  18. /**
  19. *
  20. * class constructor
  21. *
  22. * load file and set the data in the container
  23. *
  24. * @param string $data
  25. * @param string $node
  26. */
  27. public function __construct($data = null, $node = null)
  28. {
  29. if (file_exists($data)) {
  30. $data = include $data;
  31. }
  32. parent::__construct($data, $node);
  33. }
  34. /**
  35. *
  36. * add data
  37. *
  38. * @param array $data
  39. *
  40. * @return $this
  41. */
  42. public function addData($data)
  43. {
  44. $this->_data = array_replace_recursive(
  45. array_merge_recursive($this->_data, $data), $data);
  46. return $this;
  47. }
  48. }