dbms/app/Controllers/Admin/Customer/ServicePaymentController.php
2025-06-12 19:09:31 +09:00

72 lines
2.5 KiB
PHP

<?php
namespace App\Controllers\Admin\Customer;
use CodeIgniter\HTTP\RedirectResponse;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface;
use App\Helpers\Customer\ServicePaymentHelper;
use App\Services\Customer\ServicePaymentService;
use App\Services\Customer\ServiceService;
class ServicePaymentController extends CustomerController
{
private ?ServiceService $_serviceService = null;
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(): ServicePaymentService
{
if (!$this->_service) {
$this->_service = new ServicePaymentService($this->request);
}
return $this->_service;
}
public function getHelper(): ServicePaymentHelper
{
if (!$this->_helper) {
$this->_helper = new ServicePaymentHelper($this->request);
}
return $this->_helper;
}
public function getServiceService(): ServiceService
{
if (!$this->_serviceService) {
$this->_serviceService = new ServiceService($this->request);
}
return $this->_serviceService;
}
protected function initAction(string $action): void
{
//$item_type(CPU,RAM,STORAGE등)에 따라 선언된 getFormFieldOption용 사용됨 (initAction보다 먼저 호출해야 됨)
$this->initServiceItemOptions();
parent::initAction($action);
}
protected function getFormFieldOption(string $field, array $options = []): array
{
switch ($field) {
case 'serviceinfo_uid':
foreach ($this->getServiceService()->getEntities() as $entity) {
$options[$entity->getPK()] = $entity->getTitle();
}
break;
case 'item_uid':
$options = [];
break;
default:
$options = parent::getFormFieldOption($field, $options);
break;
}
return $options;
}
//Index,FieldForm관련
}