Buttons.php 990 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. namespace ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Traits;
  3. trait Buttons
  4. {
  5. protected $buttons = [];
  6. public function addButton($button)
  7. {
  8. $this->addElement($button, 'buttons');
  9. return $this;
  10. }
  11. public function insertButton($buttonId)
  12. {
  13. if (!$this->buttons[$buttonId])
  14. {
  15. //add exception
  16. }
  17. else
  18. {
  19. $button = $this->buttons[$buttonId];
  20. return $button->getHtml();
  21. }
  22. return '';
  23. }
  24. public function getButtons()
  25. {
  26. return $this->buttons;
  27. }
  28. /**
  29. * @param $buttonId
  30. * @return mixed|null
  31. */
  32. public function getButton($buttonId)
  33. {
  34. return isset($this->buttons[$buttonId]) ? $this->buttons[$buttonId] : null;
  35. }
  36. public function getButtonsCount()
  37. {
  38. return count($this->buttons);
  39. }
  40. public function hasButtons()
  41. {
  42. return count($this->buttons) > 0;
  43. }
  44. }