Upgrade to 3.4.3
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user