106 lines
3.8 KiB
PHP
106 lines
3.8 KiB
PHP
<?php
|
|
|
|
namespace App\Controllers\Admin;
|
|
|
|
use App\Entities\MylogEntity;
|
|
use CodeIgniter\HTTP\RequestInterface;
|
|
use CodeIgniter\HTTP\ResponseInterface;
|
|
use Psr\Log\LoggerInterface;
|
|
|
|
class MylogController extends AdminController
|
|
{
|
|
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
|
{
|
|
parent::initController($request, $response, $logger);
|
|
if ($this->service === null) {
|
|
$this->service = service('mylogservice');
|
|
}
|
|
}
|
|
protected function action_init_process(string $action): void
|
|
{
|
|
$fields = ['title', 'content'];
|
|
$filters = [];
|
|
$batchjobFilters = $filters;
|
|
parent::action_init_process($action);
|
|
switch ($action) {
|
|
case 'create':
|
|
case 'create_form':
|
|
case 'modify':
|
|
case 'modify_form':
|
|
break;
|
|
case 'view':
|
|
$fields = [...$fields, 'created_at'];
|
|
break;
|
|
case 'index':
|
|
case 'download':
|
|
$fields = [...$fields, 'created_at'];
|
|
break;
|
|
default:
|
|
throw new \Exception("[{$action}] 지원하지 않는 action입니다.");
|
|
// break;
|
|
}
|
|
$this->service->getFormService()->setFormFields($fields);
|
|
$this->service->getFormService()->setFormRules($action, $fields);
|
|
$this->service->getFormService()->setFormFilters($filters);
|
|
$this->service->getFormService()->setFormOptions($filters);
|
|
$this->service->getFormService()->setBatchjobFilters($batchjobFilters);
|
|
parent::action_init_process($action);
|
|
}
|
|
protected function create_process(): MylogEntity
|
|
{
|
|
$entity = parent::create_process();
|
|
if (!$entity instanceof MylogEntity) {
|
|
throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 MylogEntity만 가능");
|
|
}
|
|
return $entity;
|
|
}
|
|
protected function modify_form_process($uid): MylogEntity
|
|
{
|
|
$entity = parent::modify_form_process($uid);
|
|
if (!$entity instanceof MylogEntity) {
|
|
throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 MylogEntity만 가능");
|
|
}
|
|
return $entity;
|
|
}
|
|
protected function modify_process($uid): MylogEntity
|
|
{
|
|
$entity = parent::modify_process($uid);
|
|
if (!$entity instanceof MylogEntity) {
|
|
throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 MylogEntity만 가능");
|
|
}
|
|
return $entity;
|
|
}
|
|
protected function delete_process($uid): MylogEntity
|
|
{
|
|
$entity = parent::delete_process($uid);
|
|
if (!$entity instanceof MylogEntity) {
|
|
throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 MylogEntity만 가능");
|
|
}
|
|
return $entity;
|
|
}
|
|
protected function view_process($uid): MylogEntity
|
|
{
|
|
$entity = parent::view_process($uid);
|
|
if (!$entity instanceof MylogEntity) {
|
|
throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 MylogEntity만 가능");
|
|
}
|
|
return $entity;
|
|
}
|
|
protected function batchjob_process($uid, array $formDatas): MylogEntity
|
|
{
|
|
$entity = parent::batchjob_process($uid, $formDatas);
|
|
if (!$entity instanceof MylogEntity) {
|
|
throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 MylogEntity만 가능");
|
|
}
|
|
return $entity;
|
|
}
|
|
protected function batchjob_delete_process($uid): MylogEntity
|
|
{
|
|
$entity = $this->service->delete($uid);
|
|
if (!$entity instanceof MylogEntity) {
|
|
throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 MylogEntity만 가능");
|
|
}
|
|
return $entity;
|
|
}
|
|
}
|