dbms/app/Controllers/Admin/Equipment/EquipmentController.php
2025-05-22 16:14:07 +09:00

72 lines
2.4 KiB
PHP

<?php
namespace App\Controllers\Admin\Equipment;
use App\Controllers\Admin\AdminController;
use App\Services\Customer\ClientService;
use App\Services\Equipment\LineService;
use App\Services\Equipment\ServerService;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface;
abstract class EquipmentController extends AdminController
{
private ?ClientService $_clientService = null;
private ?LineService $_lineService = null;
private ?ServerService $_serverService = null;
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
parent::initController($request, $response, $logger);
$this->uri_path .= 'equipment/';
// $this->view_path .= "equipment" . DIRECTORY_SEPARATOR;
}
final public function getClientService(): ClientService
{
if (!$this->_clientService) {
$this->_clientService = new ClientService($this->request);
}
return $this->_clientService;
}
final public function getLineService(): LineService
{
if (!$this->_lineService) {
$this->_lineService = new LineService($this->request);
}
return $this->_lineService;
}
final public function getServerService(): ServerService
{
if (!$this->_serverService) {
$this->_serverService = new ServerService($this->request);
}
return $this->_serverService;
}
protected function getFormFieldOption(string $field, array $options): array
{
switch ($field) {
case 'clientinfo_uid':
$temps = [];
foreach ($this->getClientService()->getEntities() as $entity) {
$temps[$entity->getPK()] = $entity->getTitle();
}
$options[$field] = $temps;
// dd($options);
case 'lineinfo_uid':
$temps = [];
foreach ($this->getLineService()->getEntities() as $entity) {
$temps[$entity->getPK()] = $entity->getTitle();
}
$options[$field] = $temps;
// dd($options);
default:
$options = parent::getFormFieldOption($field, $options);
break;
}
return $options;
}
//Index,FieldForm관련
}