<?php
 namespace Modules\Admin\ActivityDomainCategories; class Controller extends \App\Mvc\Controller\Window\PaginatedListing\PaginatedEntityListing { protected $useSqlTransaction = true; protected $listOrderingColumns = ['name', 'addTime']; protected function initialize() { parent::initialize(); $this->actionsCfg['insert'] = []; $this->actionsCfg['update'] = []; $this->actionsCfg['delete'] = []; } protected function insert_createEntityObject($formData) { $entityObj = \Entity\ActivityDomainCategory::insert(); $entityObj->name = $formData['name']; return $entityObj; } protected function update_getDefaultFormData($idEntity) { $category = \Entity\ActivityDomainCategory::select($idEntity); if (!$category->recordExists()) { return null; } $formData = []; $formData['name'] = $category->name; return $formData; } protected function update_createEntityObject($formData) { $entityObj = \Entity\ActivityDomainCategory::update($this->updateIdRecord); $entityObj->name = $formData['name']; return $entityObj; } protected function delete_createEntityObject($idRecord) { return \Entity\ActivityDomainCategory::delete($idRecord); } protected function optionDefineParams(\App\Mvc\View\Utils\RowOptions\Option\Option $option, $selection) { switch($option->getId()){ case 'insert': case 'addDomain': break; case 'update': foreach ($selection as $selectedItem) { if (!$option->determineOperationAvailability(\Entity\ActivityDomainCategory::update($selectedItem))) { break; } } break; case 'delete': foreach ($selection as $selectedItem) { if (!$option->determineOperationAvailability(\Entity\ActivityDomainCategory::delete($selectedItem))){ break; } } break; default: return false; } return true; } protected function optionGetEntityName($id) { return \Entity\ActivityDomainCategory::select($id)->name; } } 