dbmsv2/app/Controllers/Admin/Equipment/ServerPartController.php
2025-09-05 10:02:18 +09:00

53 lines
1.6 KiB
PHP

<?php
namespace App\Controllers\Admin\Equipment;
use App\Helpers\Equipment\ServerPartHelper;
use App\Services\Equipment\ServerPartService;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface;
class ServerPartController 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(): ServerPartService
{
if (!$this->_service) {
$this->_service = new ServerPartService();
}
return $this->_service;
}
public function getHelper(): ServerPartHelper
{
if (!$this->_helper) {
$this->_helper = new ServerPartHelper();
}
return $this->_helper;
}
//Index,FieldForm관련
public function getFormOption(string $field, array $options = []): array
{
switch ($field) {
case 'part_uid':
$options = $this->getService()->getFormOption($this->request->getVar('type'));
break;
default:
$options = parent::getFormOption($field, $options);
break;
}
if (!is_array($options)) {
throw new \Exception(__FUNCTION__ . "에서 {$field}의 options 값이 array가 아닙니다.\n" . var_export($options, true));
}
return $options;
}
}