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