protected function createComponentTable() { $_this = $this; $admin = new AdminGrid(); $deploymentManager = $this->deploymentManager; // columns $table = $admin->getTable(); $table->setModel(new ArraySource($this->getBackups())); $table->setTranslator($this->translator); $table->addColumnText('name', 'Name')->setCustomRender(function ($items) use($_this) { return $items['name'] ?: $_this->translator->translate('untitled'); })->setSortable()->getCellPrototype()->width = '80%'; $table->addColumnDate('date', 'Date', 'd.m.Y - H:i:s')->setSortable()->getCellPrototype()->width = '20%'; // actions if ($this->isAuthorized('edit')) { // Toolbar $toolbar = $admin->getNavbar(); $toolbar->addSection('new', 'Create backup', 'file')->onClick[] = function () use($_this, $deploymentManager, $admin, $table) { $deploymentManager->createBackup($_this->getBackupName()); $admin->invalidateControl('table'); $_this->payload->url = $_this->link('this'); $table->setModel(new ArraySource($_this->getBackups())); }; $table->addAction('load', 'Load')->getElementPrototype()->class[] = 'ajax'; $table->getAction('load')->onClick[] = function ($button, $id) use($_this, $deploymentManager, $admin, $table) { $deploymentManager->loadBackup($id); $_this->redirect('this'); }; } if ($this->isAuthorized('remove')) { $table->addAction('delete', 'Delete')->getElementPrototype()->class[] = 'ajax'; $table->getAction('delete')->onClick[] = function ($button, $id) use($_this, $deploymentManager, $admin, $table) { $deploymentManager->removeBackup($id); $admin->invalidateControl('table'); $_this->payload->url = $_this->link('this'); $table->setModel(new ArraySource($_this->getBackups())); }; } return $admin; }