BaseContainer.php 810 B

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