RequestFormDataHandler.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. namespace ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Traits;
  3. /**
  4. * Adds methods to handle requests form data
  5. * Requires using \ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Traits\RequestObjectHandler
  6. */
  7. trait RequestFormDataHandler
  8. {
  9. /**
  10. * list of form data passed in formData variable
  11. * @var array
  12. */
  13. protected $formData = null;
  14. protected $actionElementId = null;
  15. /**
  16. * loads form data from request object
  17. */
  18. protected function loadFormDataFromRequest()
  19. {
  20. $this->loadRequestObj();
  21. $this->getFormDataValues();
  22. $this->getActionElementIdValue();
  23. $this->getMassActionsValues();
  24. return $this;
  25. }
  26. /**
  27. * loads 'formData' from request object
  28. */
  29. protected function getFormDataValues()
  30. {
  31. if ($this->formData === null)
  32. {
  33. $this->formData = $this->getRequestValue('formData', []);
  34. }
  35. return $this->formData;
  36. }
  37. /**
  38. * loads 'actionElementId' from request object
  39. */
  40. protected function getActionElementIdValue()
  41. {
  42. if ($this->actionElementId === null)
  43. {
  44. $this->actionElementId = $this->getRequestValue('actionElementId', null);
  45. }
  46. return $this->actionElementId;
  47. }
  48. /**
  49. * loads 'massActions' from request object
  50. */
  51. protected function getMassActionsValues()
  52. {
  53. if ($this->massActions === null)
  54. {
  55. $this->massActions = $this->getRequestValue('massActions', []);
  56. }
  57. return $this->massActions;
  58. }
  59. }