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(): ServerService { if (!$this->_service) { $this->_service = new ServerService($this->request); } return $this->_service; } public function getHelper(): ServerHelper { if (!$this->_helper) { $this->_helper = new ServerHelper($this->request); } return $this->_helper; } final public function getAdapterService(string $key): mixed { if (!array_key_exists($key, $this->_adapterService)) { switch ($key) { case 'CPU': $this->_adapterService[$key] = new CpuService(); break; case 'RAM': $this->_adapterService[$key] = new RamService(); break; case 'DISK': $this->_adapterService[$key] = new DiskService(); break; case 'LINE': $this->_adapterService[$key] = new LineService(); break; case 'IP': $this->_adapterService[$key] = new IpService(); break; case 'DEFENCE': $this->_adapterService[$key] = new DefenceService(); break; case 'SOFTWARE': $this->_adapterService[$key] = new SoftwareService(); break; default: throw new \Exception("Unknown adapter service key: {$key}"); } } return $this->_adapterService[$key]; } 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 . 'server' . DIRECTORY_SEPARATOR . $action, ['viewDatas' => $this->getViewDatas()]); break; default: $result = parent::getResultPageByActon($action, $message); break; } return $result; } //Index,FieldForm관련 protected function index_process(): array { $fields = [ 'fields' => ['code', 'switch', 'type', 'model', 'price', "raid", 'status', 'manufactur_at', 'created_at'], ]; $this->init('index', $fields); // $this->modal_type = 'modal_fetch_v2'; //기본은 modal_iframe임 $this->adapterFields = ['LINE', 'IP', 'CPU', 'RAM', 'DISK', 'DEFENCE', 'SOFTWARE']; $entities = []; foreach (parent::index_process() as $entity) { foreach ($this->adapterFields as $field) { $entity->setPartEntities($field, $this->getAdapterService($field)->getAdapterEntities($entity)); } $entities[] = $entity; } return $entities; } }