49 lines
1.6 KiB
PHP
49 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Controllers\Admin\Equipment;
|
|
|
|
use CodeIgniter\HTTP\RedirectResponse;
|
|
use CodeIgniter\HTTP\RequestInterface;
|
|
use CodeIgniter\HTTP\ResponseInterface;
|
|
use Psr\Log\LoggerInterface;
|
|
use RuntimeException;
|
|
|
|
class ServerController extends EquipmentController
|
|
{
|
|
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
|
{
|
|
parent::initController($request, $response, $logger);
|
|
if ($this->service === null) {
|
|
$this->service = service('equipment_serverservice');
|
|
}
|
|
$this->addActionPaths('server');
|
|
$this->layouts['footerScripts'][] = '<script src="/js/admin/clipboard.js"></script>';
|
|
}
|
|
//기본 함수 작업
|
|
//Custom 추가 함수
|
|
public function create_form_process(array $formDatas = []): array
|
|
{
|
|
$formDatas = parent::create_form_process($formDatas);
|
|
$formDatas['code'] = sprintf("%d%dXX-M%d", date("y"), ceil((int) date("m") / 3), $this->service->getNextPK());
|
|
return $formDatas;
|
|
}
|
|
|
|
protected function modify_form_result_process(string $action): string|RedirectResponse
|
|
{
|
|
return $this->action_render_process($action, $this->getViewDatas(), $this->request->getVar('ActionTemplate') ?? 'server');
|
|
}
|
|
|
|
public function console(int $uid): string
|
|
{
|
|
$entity = $this->service->getEntity($uid);
|
|
if (!$entity instanceof ServerEntity) {
|
|
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: {$uid} 서버 정보를 찾을수 없습니다.");
|
|
}
|
|
$viewDatas = [
|
|
'entity' => $entity,
|
|
'title' => $entity->getTitle(),
|
|
];
|
|
return view('admin/server/console', $viewDatas);
|
|
}
|
|
}
|