languageService = $languageService; $this->languageBaseService = $languageBaseService ; } public function getAllLanguages($param) { $response = ['status' => false, 'message' => '', 'data' => null, 'statusCode' => 500 ]; try { if($param === "all"){ $languageCriteria = [ 'criteria' => [ ['field' => 'status' , 'condition' => '=', 'value' => 1 ] ] , "orderBy" => [ ["field" => "name", "value" => "ASC"] ] ]; }elseif ($param === "app"){ $languageCriteria = [ 'criteria' => [ ['field' => 'status' , 'condition' => '=', 'value' => 1 ], ['field' => 'is_application' , 'condition' => '=', 'value' => 1 ], ['field' => 'is_published' , 'condition' => '=', 'value' => 1 ] ] , "orderBy" => [ ["field" => "name", "value" => "ASC"] ] ]; }else{ throw new ApiErrorException(lang('Parameter Error.')); } $languages = $this->languageService->getAllLanguages($languageCriteria, ['id','code','name','status', 'language_key']); if ($languages['status'] != 'success') { throw new ApiErrorException($languages['message']); } $response = ['status' => 1, 'statusCode' => 200, 'message' => null,'data' => $languages['data'] ]; } catch (ApiErrorException $e) { $response['message'] = implode(', ', $e->getMessageArr()); $response['statusCode'] = 400; } catch (Exception $e) { $message = $e->getFile() . " " . $e->getLine() . " " . $e->getMessage(); Log::error($message); $response['message'] = $e->getMessage(); $response['statusCode'] = 500; } return apiResponse($response['status'], $response['message'], $response['data'], $response['statusCode']); } public function createApplicationLanguageFiles() { $response = ['status' => false, 'message' => '', 'data' => null, 'statusCode' => 500 ]; try { $languageBaseResponse = $this->languageBaseService->createApplicationLanguageFiles() ; if ($languageBaseResponse['status'] != 'success') { throw new ApiErrorException($languageBaseResponse['message']); } $response = ['status' => 1, 'statusCode' => 200, 'message' => null,'data' => null ]; } catch (ApiErrorException $e) { $response['message'] = implode(', ', $e->getMessageArr()); $response['statusCode'] = 400; } catch (Exception $e) { $message = $e->getFile() . " " . $e->getLine() . " " . $e->getMessage(); Log::error($message); $response['message'] = $e->getMessage(); $response['statusCode'] = 500; } return apiResponse($response['status'], $response['message'], $response['data'], $response['statusCode']); } public function getNullDescriptions() { $response = ['status' => false, 'message' => '', 'data' => null, 'statusCode' => 500 ]; try { $applicationLanguages = $this->languageService->getApplicationLanguages(); $applicationLanguages = $applicationLanguages['data']; $responseLangTitle = [] ; foreach ($applicationLanguages as $applicationLanguage) { $langKey = $applicationLanguage['code']; $responseLangTitle[] = [ 'language_code' => $langKey, 'description' => isset($titleLangContents[$langKey]) ? $titleLangContents[$langKey] : null ]; } $response = ['status' => 1, 'statusCode' => 200, 'message' => null,'data' => $responseLangTitle ]; } catch (ApiErrorException $e) { $response['message'] = implode(', ', $e->getMessageArr()); $response['statusCode'] = 400; } catch (Exception $e) { $message = $e->getFile() . " " . $e->getLine() . " " . $e->getMessage(); Log::error($message); $response['message'] = $e->getMessage(); $response['statusCode'] = 500; } return apiResponse($response['status'], $response['message'], $response['data'], $response['statusCode']); } }