mirror of
https://github.com/flarum/framework.git
synced 2025-02-10 22:47:31 +08:00
Use Collection class rather than collect() helper
This commit is contained in:
parent
4d1411e2a8
commit
1a9f1f7a3d
|
@ -34,7 +34,7 @@ class Composite implements PrerequisiteInterface
|
||||||
function (Collection $errors, PrerequisiteInterface $condition) {
|
function (Collection $errors, PrerequisiteInterface $condition) {
|
||||||
return $errors->concat($condition->problems());
|
return $errors->concat($condition->problems());
|
||||||
},
|
},
|
||||||
collect()
|
new Collection
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ class PhpExtensions implements PrerequisiteInterface
|
||||||
|
|
||||||
public function problems(): Collection
|
public function problems(): Collection
|
||||||
{
|
{
|
||||||
return collect($this->extensions)
|
return (new Collection($this->extensions))
|
||||||
->reject(function ($extension) {
|
->reject(function ($extension) {
|
||||||
return extension_loaded($extension);
|
return extension_loaded($extension);
|
||||||
})->map(function ($extension) {
|
})->map(function ($extension) {
|
||||||
|
|
|
@ -24,13 +24,15 @@ class PhpVersion implements PrerequisiteInterface
|
||||||
|
|
||||||
public function problems(): Collection
|
public function problems(): Collection
|
||||||
{
|
{
|
||||||
|
$collection = new Collection;
|
||||||
|
|
||||||
if (version_compare(PHP_VERSION, $this->minVersion, '<')) {
|
if (version_compare(PHP_VERSION, $this->minVersion, '<')) {
|
||||||
return collect()->push([
|
$collection->push([
|
||||||
'message' => "PHP $this->minVersion is required.",
|
'message' => "PHP $this->minVersion is required.",
|
||||||
'detail' => 'You are running version '.PHP_VERSION.'. You might want to talk to your system administrator about upgrading to the latest PHP version.',
|
'detail' => 'You are running version '.PHP_VERSION.'. You might want to talk to your system administrator about upgrading to the latest PHP version.',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return collect();
|
return $collection;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ class WritablePaths implements PrerequisiteInterface
|
||||||
|
|
||||||
private function getMissingPaths(): Collection
|
private function getMissingPaths(): Collection
|
||||||
{
|
{
|
||||||
return collect($this->paths)
|
return (new Collection($this->paths))
|
||||||
->reject(function ($path) {
|
->reject(function ($path) {
|
||||||
return file_exists($path);
|
return file_exists($path);
|
||||||
})->map(function ($path) {
|
})->map(function ($path) {
|
||||||
|
@ -43,7 +43,7 @@ class WritablePaths implements PrerequisiteInterface
|
||||||
|
|
||||||
private function getNonWritablePaths(): Collection
|
private function getNonWritablePaths(): Collection
|
||||||
{
|
{
|
||||||
return collect($this->paths)
|
return (new Collection($this->paths))
|
||||||
->filter(function ($path) {
|
->filter(function ($path) {
|
||||||
return file_exists($path) && ! is_writable($path);
|
return file_exists($path) && ! is_writable($path);
|
||||||
})->map(function ($path) {
|
})->map(function ($path) {
|
||||||
|
|
|
@ -18,6 +18,7 @@ use Flarum\Install\Step;
|
||||||
use Flarum\Settings\DatabaseSettingsRepository;
|
use Flarum\Settings\DatabaseSettingsRepository;
|
||||||
use Illuminate\Database\ConnectionInterface;
|
use Illuminate\Database\ConnectionInterface;
|
||||||
use Illuminate\Support\Arr;
|
use Illuminate\Support\Arr;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
use League\Flysystem\Adapter\Local;
|
use League\Flysystem\Adapter\Local;
|
||||||
use League\Flysystem\Filesystem;
|
use League\Flysystem\Filesystem;
|
||||||
|
|
||||||
|
@ -91,7 +92,7 @@ class EnableBundledExtensions implements Step
|
||||||
{
|
{
|
||||||
$json = file_get_contents("$this->basePath/vendor/composer/installed.json");
|
$json = file_get_contents("$this->basePath/vendor/composer/installed.json");
|
||||||
|
|
||||||
return collect(json_decode($json, true))
|
return (new Collection(json_decode($json, true)))
|
||||||
->filter(function ($package) {
|
->filter(function ($package) {
|
||||||
return Arr::get($package, 'type') == 'flarum-extension';
|
return Arr::get($package, 'type') == 'flarum-extension';
|
||||||
})->filter(function ($package) {
|
})->filter(function ($package) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user