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; $this->serverpartinfo_cnt_range = array_combine(range(0, 10), range(0, 10)); $this->serverpartinfo_extra_options = array_merge(["" => "RAID 선택"], lang("{$this->getService()->getClassName()}.EXTRAS")); } public function getService(): ServerService { if (!$this->_service) { $this->_service = new ServerService(); } return $this->_service; } public function getHelper(): ServerHelper { if (!$this->_helper) { $this->_helper = new ServerHelper(); } return $this->_helper; } final public function getServerPartService(): ServerPartService { if (!$this->_serverPartService) { $this->_serverPartService = new ServerPartService(); } return $this->_serverPartService; } //Index,FieldForm관련 //생성 protected function create_form_process(): void { $format = env("Server.Prefix.code.format", false); if (!$format) { throw new \Exception(__METHOD__ . "에서 code의 format[Server.Prefix.code.format]이 정의되지 않았습니다."); } $this->setFieldDefaultValue('code', $this->getService()->getLastestCode($format, (int)env("Server.Default.code", 0))); parent::create_form_process(); } //추가 파트정보 생성 private function createServerParts(ServerEntity $entity): array { $serverPartEntities = []; foreach (ServerPartService::BaseParts as $basePart) { $formDatas = [ "partinfo_uid" => $this->request->getPost(["serverpartinfo_{$basePart}_uid"]), "serverinfo_uid" => $entity->getPK(), "serviceinfo_uid" => $entity->getServiceInfoUID(), "billing" => ServerPartENtity::DEFAULT_BILLING, "amount" => $this->request->getPost("amount") ?? 0, "cnt" => $this->request->getPost("serverpartinfo_{$basePart}_uid_cnt") ?? 1, "extra" => $this->request->getPost("serverpartinfo_{$basePart}_uid_extra") ?? "" ]; $serverPartEntities[] = $this->getServerPartService()->create($formDatas); } return $serverPartEntities; } protected function create_process(array $formDatas): ServerEntity { //코드 패턴체크 $pattern = env("Server.Prefix.code.pattern", false); if (!$pattern) { throw new \Exception(__METHOD__ . "에서 code의 prefix[Server.Prefix.code.pattern]가 정의되지 않았습니다."); } if (!array_key_exists('code', $formDatas)) { throw new \Exception("Server코드가 정의되지 않았습니다"); } if (!preg_match($pattern, $formDatas['code'])) { throw new \Exception("Server코드[{$formDatas['code']}의 형식이 맞지않습니다"); } $entity = parent::create_process($formDatas); //추가 파트정보 생성 후 ServerEntity 에 설정 $entity->setServerParts($this->createServerParts($entity)); return $entity; } protected function index_process(array $entities = []): array { foreach (parent::index_process($entities) as $entity) { //서버 부품정보 정의 $entity->setServerParts($this->getServerPartService()->getEntities(['serverinfo_uid' => $entity->getPK()])); //서버 IP정보 정의 //서버 CS정보 정의 $entities[] = $entity; } return $entities; } }