_targetDB === null) { $this->_targetDB = \Config\Database::connect('default'); } return $this->_targetDB; } /** * 공통 마이그레이션 처리 로직 */ private function processMigration(MigrationProcessInterface $processor, array $rows, string $functionName): void { $this->getTargetDB()->transStart(); try { $cnt = 1; foreach ($rows as $row) { $processor->process($row, $cnt); $cnt++; } echo "{$functionName} 작업을 완료하였습니다."; $this->getTargetDB()->transCommit(); } catch (\Exception $e) { $this->getTargetDB()->transRollback(); echo "{$functionName} 작업을 실패하였습니다.\n--------------\n" . $e->getMessage() . "\n--------------\n"; } } final public function client(): void { $this->processMigration( new ClientProcess($this->getTargetDB()), $this->getClient(), __FUNCTION__ ); } final public function line(): void { $this->processMigration( new LineProcess($this->getTargetDB()), $this->getLine(), __FUNCTION__ ); } final public function servercode(): void { $this->processMigration( new ServerCodeProcess($this->getTargetDB()), $this->getServerCode(), __FUNCTION__ ); } final public function switchcode(): void { $this->processMigration( new SwitchCodeProcess($this->getTargetDB()), $this->getSwitchCode(), __FUNCTION__ ); } }