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(): ServiceItemService { if (!$this->_service) { $this->_service = new ServiceItemService($this->request); } return $this->_service; } public function getHelper(): ServiceItemHelper { if (!$this->_helper) { $this->_helper = new ServiceItemHelper($this->request); } // dd($this->_helper); return $this->_helper; } public function getServiceService(): ServiceService { if (!$this->_serviceService) { $this->_serviceService = new ServiceService($this->request); } return $this->_serviceService; } final public function getEquipmentService(string $key): mixed { if (!array_key_exists($key, $this->_equipmentService)) { switch ($key) { case 'SERVER': $this->_equipmentService[$key] = new ServerService(); break; case 'CPU': $this->_equipmentService[$key] = new CpuService(); break; case 'RAM': $this->_equipmentService[$key] = new RamService(); break; case 'STORAGE': $this->_equipmentService[$key] = new StorageService(); break; case 'LINE': $this->_equipmentService[$key] = new LineService(); break; case 'IP': $this->_equipmentService[$key] = new IpService(); break; case 'DEFENCE': $this->_equipmentService[$key] = new DefenceService(); break; case 'SOFTWARE': $this->_equipmentService[$key] = new SoftwareService(); break; case 'DOMAIN': $this->_equipmentService[$key] = new DomainService(); break; default: throw new \Exception(__FUNCTION__ . "에서 사용하지않는 Service를 요청하였습니다.: {$key}"); } } return $this->_equipmentService[$key]; } protected function getFormFieldOption(string $field, array $options): array { switch ($field) { case 'serviceinfo_uid': $temps = []; foreach ($this->getServiceService()->getEntities() as $entity) { $temps[$entity->getPK()] = $entity->getTitle(); } $options[$field] = $temps; // dd($options); break; case 'item_uid': $temps = []; $item_type = $this->request->getVar('item_type'); if (!$item_type) { throw new \Exception(__FUNCTION__ . "에서 item_type이 지정되지 않았습니다."); } // throw new \Exception(__FUNCTION__ . "에서 item_type이 지정되지 않았습니다.->{$item_type}"); foreach ($this->getEquipmentService($item_type)->getEntities() as $entity) { $temps[$entity->getPK()] = $entity->getTitle(); } $options[$field] = $temps; // dd($options); break; default: $options = parent::getFormFieldOption($field, $options); break; } return $options; } protected function getResultPageByActon(string $action, string $message = MESSAGES["SUCCESS"]): RedirectResponse|string { switch ($action) { case 'index': $this->getHelper()->setViewDatas($this->getViewDatas()); $result = view($this->view_path . 'popup' . DIRECTORY_SEPARATOR . $action, ['viewDatas' => $this->getViewDatas()]); break; default: $result = parent::getResultPageByActon($action, $message); break; } return $result; } //Index,FieldForm관련 protected function create_process(): mixed { // dd($this->formDatas); if (!array_key_exists('item_type', $this->formDatas) || !$this->formDatas['item_type']) { throw new \Exception(__METHOD__ . "에서 item_type이 지정되지 않았습니다."); } if (!array_key_exists('item_uid', $this->formDatas) || !$this->formDatas['item_uid']) { throw new \Exception(__METHOD__ . "에서 item_uid가가 지정되지 않았습니다."); } $equipmentEntity = $this->getEquipmentService($this->formDatas['item_type'])->getEntity($this->formDatas['item_uid']); if (!$equipmentEntity) { throw new \Exception(__METHOD__ . "에서 equipmentEntity 정보가 확인되지 않습니다."); } //각 항목의 Price를 Item Price로 전달함 $formDatas = $this->formDatas; $formDatas['price'] = $equipmentEntity->getPrice(); $this->formDatas = $formDatas; return parent::create_process(); } protected function index_process(): array { $fields = [ 'fields' => ['serviceinfo_uid', 'item_type', 'item_uid', 'billing_cycle', 'price', 'amount', 'start_at', 'status'], ]; $this->init('index', $fields); return parent::index_process(); } }