82 lines
2.8 KiB
PHP
82 lines
2.8 KiB
PHP
<?php
|
|
|
|
namespace App\Controllers\Admin\Equipment;
|
|
|
|
use CodeIgniter\HTTP\RequestInterface;
|
|
use CodeIgniter\HTTP\ResponseInterface;
|
|
use Psr\Log\LoggerInterface;
|
|
|
|
use App\Helpers\Equipment\ServerHelper;
|
|
use App\Services\Equipment\ServerService;
|
|
use App\Services\Equipment\Link\CpuService;
|
|
use App\Services\Equipment\Link\RamService;
|
|
use App\Services\Equipment\Link\DiskService;
|
|
|
|
class ServerController extends EquipmentController
|
|
{
|
|
private ?CpuService $_cpuService = null;
|
|
private ?RamService $_ramService = null;
|
|
private ?DiskService $_diskService = null;
|
|
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
|
{
|
|
parent::initController($request, $response, $logger);
|
|
$this->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($this->request);
|
|
}
|
|
return $this->_service;
|
|
}
|
|
public function getHelper(): ServerHelper
|
|
{
|
|
if (!$this->_helper) {
|
|
$this->_helper = new ServerHelper($this->request);
|
|
}
|
|
return $this->_helper;
|
|
}
|
|
final public function getCpuService(): CpuService
|
|
{
|
|
if (!$this->_cpuService) {
|
|
$this->_cpuService = new CpuService($this->request);
|
|
}
|
|
return $this->_cpuService;
|
|
}
|
|
final public function getRamService(): RamService
|
|
{
|
|
if (!$this->_ramService) {
|
|
$this->_ramService = new RamService($this->request);
|
|
}
|
|
return $this->_ramService;
|
|
}
|
|
final public function getDiskService(): DiskService
|
|
{
|
|
if (!$this->_diskService) {
|
|
$this->_diskService = new DiskService($this->request);
|
|
}
|
|
return $this->_diskService;
|
|
}
|
|
//Index,FieldForm관련
|
|
protected function index_process(): array
|
|
{
|
|
$fields = [
|
|
'fields' => ['code', 'type', 'model', 'CPU', 'RAM', 'DISK', 'status'],
|
|
];
|
|
$this->init('index', $fields);
|
|
// $this->modal_type = 'modal_fetch_v2'; //기본은 modal_iframe임
|
|
$entities = [];
|
|
foreach (parent::index_process() as $entity) {
|
|
$entity->setPartEntities("CPU", $this->getCpuService()->getPartEntities($entity));
|
|
$entity->setPartEntities("RAM", $this->getRamService()->getPartEntities($entity));
|
|
$entity->setPartEntities("DISK", $this->getDiskService()->getPartEntities($entity));
|
|
$entities[] = $entity;
|
|
}
|
|
return $entities;
|
|
}
|
|
}
|