dbmsv2/app/Controllers/Admin/Equipment/ServerController.php
2025-08-20 11:19:44 +09:00

65 lines
2.0 KiB
PHP

<?php
namespace App\Controllers\Admin\Equipment;
use App\Helpers\Equipment\ServerHelper;
use App\Services\Equipment\ServerService;
use CodeIgniter\HTTP\RedirectResponse;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface;
class ServerController extends EquipmentController
{
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
parent::initController($request, $response, $logger);
$this->content_title = lang("{$this->getService()->getClassName()}.title");
$this->class_path .= $this->getService()->getClassName();
$this->uri_path .= strtolower($this->getService()->getClassName('/')) . '/';
// $this->view_path .= strtolower($this->getService()->getClassName()) . DIRECTORY_SEPARATOR;
}
public function getService(): ServerService
{
if (!$this->_service) {
$this->_service = new ServerService();
}
return $this->_service;
}
public function getHelper(): ServerHelper
{
if (!$this->_helper) {
$this->_helper = new ServerHelper();
}
return $this->_helper;
}
//Index,FieldForm관련
protected function getResultSuccess(string $message = MESSAGES["SUCCESS"], ?string $actionTemplate = null): RedirectResponse|string
{
switch ($this->getAction()) {
case 'index':
case 'view':
$result = parent::getResultSuccess($message, $this->request->getVar('ActionTemplate') ?? $actionTemplate ?? 'server');
break;
default:
$result = parent::getResultSuccess($message, $actionTemplate);
break;
}
return $result;
}
//View부분
protected function view_process(mixed $entity): void
{
foreach (SERVICE_ITEM_TYPES as $item_type => $label) {
$entity->setItemEntities(
$item_type,
$this->getService()->getEntities(['serviceinfo_uid' => $entity->getPK(), 'item_type' => $item_type])
);
}
//부모처리
parent::view_process($entity);
}
}