UpdateForm.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. /* * ********************************************************************
  3. * ProxmoxVPS Product developed. (27.03.19)
  4. * *
  5. *
  6. * CREATED BY MODULESGARDEN -> http://modulesgarden.com
  7. * CONTACT -> contact@modulesgarden.com
  8. *
  9. *
  10. * This software is furnished under a license and may be used and copied
  11. * only in accordance with the terms of such license and with the
  12. * inclusion of the above copyright notice. This software or any other
  13. * copies thereof may not be provided or otherwise made available to any
  14. * other person. No title to and ownership of the software is hereby
  15. * transferred.
  16. *
  17. *
  18. * ******************************************************************** */
  19. namespace ModulesGarden\Servers\ProxmoxCloudVps\App\UI\Disk\Forms;
  20. use ModulesGarden\ProxmoxAddon\App\Services\Cloud\ProductService;
  21. use ModulesGarden\ProxmoxAddon\App\Services\Cloud\ResourceManager;
  22. use ModulesGarden\Servers\ProxmoxCloudVps\App\UI\Disk\Providers\DiskProvider;
  23. use ModulesGarden\Servers\ProxmoxCloudVps\App\UI\Disk\Validators\DiskSizeValidator;
  24. use ModulesGarden\Servers\ProxmoxCloudVps\App\UI\Validators\NumberValidator;
  25. use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Interfaces\ClientArea;
  26. use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Widget\Forms\BaseForm;
  27. use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Widget\Forms\Fields\Hidden;
  28. use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Widget\Forms\Fields\Switcher;
  29. use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Widget\Forms\Fields\Text;
  30. class UpdateForm extends BaseForm implements ClientArea
  31. {
  32. use ProductService;
  33. public function initContent()
  34. {
  35. $this->initIds('updateDiskForm');
  36. $this->setFormType('update');
  37. $this->setProvider(new DiskProvider());
  38. $this->initFields();
  39. $this->loadDataToForm();
  40. }
  41. public function getAllowedActions()
  42. {
  43. return ['update'];
  44. }
  45. private function initFields()
  46. {
  47. //entity id
  48. $this->addField(new Hidden("id"));
  49. //size
  50. $field = new Text('size');
  51. $resourceManager = new ResourceManager();
  52. /**
  53. * @todo $resourceManager->disk()->free() + current disk size
  54. */
  55. $field->addValidator(new DiskSizeValidator());
  56. $this->addField($field);
  57. //backup
  58. if ($this->configuration()->isPermissionAdditionalDiskBackup())
  59. {
  60. $field = new Switcher('backup');
  61. $this->addField($field);
  62. }
  63. }
  64. }