dbms/app/Controllers/Admin/Equipment/DomainController.php
2025-06-04 13:31:08 +09:00

83 lines
2.9 KiB
PHP

<?php
namespace App\Controllers\Admin\Equipment;
use App\Helpers\Equipment\DomainHelper;
use App\Services\Equipment\DomainService;
use CodeIgniter\HTTP\RedirectResponse;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface;
class DomainController extends EquipmentController
{
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(): DomainService
{
if (!$this->_service) {
$this->_service = new DomainService($this->request);
}
return $this->_service;
}
public function getHelper(): DomainHelper
{
if (!$this->_helper) {
$this->_helper = new DomainHelper($this->request);
}
return $this->_helper;
}
protected function getResultPageByActon(string $action, string $message = MESSAGES["SUCCESS"]): RedirectResponse|string
{
echo "TEST:{$action}";
switch ($action) {
case 'popup':
// $this->getHelper()->setViewDatas($this->getViewDatas());
$result = view($this->view_path . 'popup' . DIRECTORY_SEPARATOR . 'index', ['viewDatas' => $this->getViewDatas()]);
break;
default:
$result = parent::getResultPageByActon($action, $message);
}
return $result;
}
//Index,FieldForm관련
protected function setOrderByForList(): void
{
//OrderBy 처리
$this->getService()->getModel()->orderBy('domain', 'ASC', false);
parent::setOrderByForList();
}
protected function index_process(): array
{
$fields = [
'fields' => ['clientinfo_uid', 'domain', 'status'],
];
$this->init('index', $fields);
return parent::index_process();
}
public function popup(): RedirectResponse|string
{
try {
// 현재 URL을 스택에 저장
$this->getMyAuth()->pushCurrentUrl($this->request->getUri()->getPath() . ($this->request->getUri()->getQuery() ? "?" . $this->request->getUri()->getQuery() : ""));
helper(['form']);
$this->init(__FUNCTION__, ['fields' => ['clientinfo_uid', 'domain', 'price', 'status'],]);
$this->entities = parent::index_process();
return $this->getResultPageByActon($this->action);
} catch (\Exception $e) {
return redirect()->back()->withInput()->with('error', $e->getMessage());
}
}
}