Upgrade to 3.4.3

This commit is contained in:
Bastian Allgeier
2020-09-15 10:25:09 +02:00
parent 54b9ba3047
commit d8e797dd9b
108 changed files with 1750 additions and 523 deletions

View File

@@ -17,6 +17,13 @@ use Kirby\Toolkit\Str;
*/
class LanguageRules
{
/**
* Validates if the language can be created
*
* @param \Kirby\Cms\Language $language
* @return bool
* @throws \Kirby\Exception\DuplicateException If the language already exists
*/
public static function create(Language $language): bool
{
static::validLanguageCode($language);
@@ -34,12 +41,24 @@ class LanguageRules
return true;
}
/**
* Validates if the language can be updated
*
* @param \Kirby\Cms\Language $language
*/
public static function update(Language $language)
{
static::validLanguageCode($language);
static::validLanguageName($language);
}
/**
* Validates if the language code is formatted correctly
*
* @param \Kirby\Cms\Language $language
* @return bool
* @throws \Kirby\Exception\InvalidArgumentException If the language code is not valid
*/
public static function validLanguageCode(Language $language): bool
{
if (Str::length($language->code()) < 2) {
@@ -55,6 +74,13 @@ class LanguageRules
return true;
}
/**
* Validates if the language name is formatted correctly
*
* @param \Kirby\Cms\Language $language
* @return bool
* @throws \Kirby\Exception\InvalidArgumentException If the language name is invalid
*/
public static function validLanguageName(Language $language): bool
{
if (Str::length($language->name()) < 1) {