Browse Source

Dont fail hard

mscherer 6 years ago
parent
commit
84829c79ae
1 changed files with 3 additions and 6 deletions
  1. 3 6
      src/Mailer/Mailer.php

+ 3 - 6
src/Mailer/Mailer.php

@@ -107,7 +107,7 @@ class Mailer extends CakeMailer {
 			return;
 		}
 
-		$primaryLocale = $this->getPrimaryLocale();
+		$primaryLocale = $this->detectPrimaryLocale();
 		if ($primaryLocale) {
 			I18n::setLocale($primaryLocale);
 		}
@@ -128,18 +128,15 @@ class Mailer extends CakeMailer {
 	 * Can be based on the primary language and the allowed languages (whitelist).
 	 *
 	 * @throws \RuntimeException
-	 * @return string
+	 * @return string|null
 	 */
-	protected function getPrimaryLocale(): string {
+	protected function detectPrimaryLocale(): ?string {
 		if (Configure::read('Config.defaultLocale')) {
 			return Configure::read('Config.defaultLocale');
 		}
 
 		$primaryLanguage = Configure::read('Config.defaultLanguage');
 		$primaryLocale = Configure::read('Config.allowedLanguages.' . $primaryLanguage . '.locale');
-		if (!$primaryLocale) {
-			throw new RuntimeException('No primary locale found, make sure you configured Configure keys `Config.defaultLocale` or `Config.defaultLanguage`+`Config.allowedLanguages`.');
-		}
 
 		return $primaryLocale;
 	}