| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- <?php
- namespace ModulesGarden\Servers\ProxmoxVps\Core\UI\Traits;
- use \ModulesGarden\Servers\ProxmoxVps\Core\ServiceLocator;
- trait DatatableActionButtons
- {
- protected $actionButtons = [];
- public function addActionButton($button)
- {
- if (is_string($button))
- {
- $button = ServiceLocator::call($button);
- }
- $button->setMainContainer($this->mainContainer);
- $id = $button->getId();
- if (!isset($this->actionButtons[$id]))
- {
- $this->actionButtons[$id] = $button;
- if ($button instanceof \ModulesGarden\Servers\ProxmoxVps\Core\UI\Interfaces\AjaxElementInterface)
- {
- $this->mainContainer->addAjaxElement($this->actionButtons[$id]);
- }
- }
- return $this;
- }
- public function insertActionButton($buttonId)
- {
- if (!$this->actionButtons[$buttonId])
- {
- //add exception
- }
- else
- {
- $button = $this->actionButtons[$buttonId];
- return $button->getHtml();
- }
- return '';
- }
- public function hasActionButtons()
- {
- return (count($this->actionButtons) > 0) ? true : false;
- }
- public function getActionButtons()
- {
- return $this->actionButtons;
- }
- }
|