Update to Kirby 4.7.0
This commit is contained in:
parent
02a9ab387c
commit
ba25a9a198
509 changed files with 26604 additions and 14872 deletions
|
@ -18,20 +18,19 @@ class Languages extends Collection
|
|||
{
|
||||
/**
|
||||
* All registered languages methods
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $methods = [];
|
||||
public static array $methods = [];
|
||||
|
||||
/**
|
||||
* Creates a new collection with the given language objects
|
||||
*
|
||||
* @param array $objects `Kirby\Cms\Language` objects
|
||||
* @param null $parent
|
||||
* @throws \Kirby\Exception\DuplicateException
|
||||
*/
|
||||
public function __construct($objects = [], $parent = null)
|
||||
{
|
||||
public function __construct(
|
||||
array $objects = [],
|
||||
$parent = null
|
||||
) {
|
||||
$defaults = array_filter(
|
||||
$objects,
|
||||
fn ($language) => $language->isDefault() === true
|
||||
|
@ -41,48 +40,39 @@ class Languages extends Collection
|
|||
throw new DuplicateException('You cannot have multiple default languages. Please check your language config files.');
|
||||
}
|
||||
|
||||
parent::__construct($objects, $parent);
|
||||
parent::__construct($objects, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all language codes as array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function codes(): array
|
||||
{
|
||||
return $this->keys();
|
||||
return App::instance()->multilang() ? $this->keys() : ['default'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new language with the given props
|
||||
*
|
||||
* @internal
|
||||
* @param array $props
|
||||
* @return \Kirby\Cms\Language
|
||||
*/
|
||||
public function create(array $props)
|
||||
public function create(array $props): Language
|
||||
{
|
||||
return Language::create($props);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the default language
|
||||
*
|
||||
* @return \Kirby\Cms\Language|null
|
||||
*/
|
||||
public function default()
|
||||
public function default(): Language|null
|
||||
{
|
||||
return $this->findBy('isDefault', true) ?? $this->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert all defined languages to a collection
|
||||
*
|
||||
* @internal
|
||||
* @return static
|
||||
*/
|
||||
public static function load()
|
||||
public static function load(): static
|
||||
{
|
||||
$languages = [];
|
||||
$files = glob(App::instance()->root('languages') . '/*.php');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue