85 lines
3.0 KiB
PHP
85 lines
3.0 KiB
PHP
<?php
|
|
|
|
namespace App\Controllers\Admin\Equipment;
|
|
|
|
use App\Entities\Equipment\ServerEntity;
|
|
use CodeIgniter\HTTP\RequestInterface;
|
|
use CodeIgniter\HTTP\ResponseInterface;
|
|
use Psr\Log\LoggerInterface;
|
|
use CodeIgniter\Validation\Validation;
|
|
|
|
use App\Helpers\Equipment\ServerHelper;
|
|
use App\Services\Equipment\ServerService;
|
|
use App\Services\Equipment\PartService;
|
|
use App\Services\Equipment\ServerPartService;
|
|
use App\Entities\Equipment\ServerPartEntity;
|
|
|
|
class ServerController extends EquipmentController
|
|
{
|
|
private ?PartService $_partService = null;
|
|
private ?ServerPartService $_serverPartService = null;
|
|
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
|
{
|
|
parent::initController($request, $response, $logger);
|
|
$this->uri_path .= strtolower($this->getService()->getClassName()) . '/';
|
|
// $this->view_path .= strtolower($this->getService()->getClassName()) . DIRECTORY_SEPARATOR;
|
|
$this->class_path = $this->getService()->getClassPath();
|
|
$this->title = lang("{$this->getService()->getClassPath()}.title");
|
|
$this->helper = $this->getHelper();
|
|
$this->individualStylesheets = ['server_partinfo.css'];
|
|
$this->individualScripts = ['server_partinfo.js'];
|
|
}
|
|
public function getService(): ServerService
|
|
{
|
|
if (!$this->_service) {
|
|
$this->_service = new ServerService($this->request);
|
|
}
|
|
return $this->_service;
|
|
}
|
|
public function getHelper(): mixed
|
|
{
|
|
if (!$this->_helper) {
|
|
$this->_helper = new ServerHelper($this->request);
|
|
}
|
|
return $this->_helper;
|
|
}
|
|
final public function getPartService(): PartService
|
|
{
|
|
if (!$this->_partService) {
|
|
$this->_partService = new PartService($this->request);
|
|
}
|
|
return $this->_partService;
|
|
}
|
|
final public function getServerPartService(): ServerPartService
|
|
{
|
|
if (!$this->_serverPartService) {
|
|
$this->_serverPartService = new ServerPartService($this->request);
|
|
}
|
|
return $this->_serverPartService;
|
|
}
|
|
//Index,FieldForm관련
|
|
private function setPartEntity(ServerEntity $entity): ServerEntity
|
|
{
|
|
foreach ($this->getServerPartService()->getEntities(['serverinfo_uid' => $entity->getPK()]) as $serverPartEntity) {
|
|
$partEntity = $this->getPartService()->getEntity($serverPartEntity->getPartInfo());
|
|
if ($partEntity) {
|
|
$entity->addPartEntity($partEntity->getType(), $partEntity);
|
|
}
|
|
}
|
|
return $entity;
|
|
}
|
|
protected function index_process(): array
|
|
{
|
|
$fields = [
|
|
'fields' => ['code', 'type', 'model', 'CPU', 'RAM', 'DISK', 'status'],
|
|
];
|
|
$this->init('index', $fields);
|
|
$this->modal_type = 'modal_iframe';
|
|
$entities = [];
|
|
foreach (parent::index_process() as $entity) {
|
|
$entities[] = $this->setPartEntity($entity);
|
|
}
|
|
return $entities;
|
|
}
|
|
}
|