BaseContainer.php 793 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace ModulesGarden\Servers\ProxmoxVps\Core\UI\Builder;
  3. /**
  4. * Base Container element. Every UI element should extend this.
  5. *
  6. * @author inbs
  7. */
  8. class BaseContainer extends Context {
  9. protected $data = [];
  10. /**
  11. * @param array $data
  12. * @return $this
  13. */
  14. public function setData(array $data = [])
  15. {
  16. $this->data = $data;
  17. $this->updateData();
  18. return $this;
  19. }
  20. public function getData()
  21. {
  22. return $this->data;
  23. }
  24. protected function updateData()
  25. {
  26. foreach ($this->data as $key => $value)
  27. {
  28. if (property_exists($this, $key))
  29. {
  30. $this->$key = $value;
  31. }
  32. }
  33. $this->data = [];
  34. return $this;
  35. }
  36. }