1
0
mirror of https://github.com/flarum/core.git synced 2025-10-12 07:24:27 +02:00

Merge branch 'master' into 1236-database-changes

This commit is contained in:
Toby Zerner
2018-08-24 17:03:50 +09:30
26 changed files with 263 additions and 143 deletions

View File

@@ -40,6 +40,7 @@ class InstallServiceProvider extends AbstractServiceProvider
'mbstring',
'openssl',
'pdo_mysql',
'tokenizer',
]),
new WritablePaths([
base_path(),
@@ -53,8 +54,6 @@ class InstallServiceProvider extends AbstractServiceProvider
$this->app->singleton('flarum.install.routes', function () {
return new RouteCollection;
});
$this->loadViewsFrom(__DIR__.'/../../views/install', 'flarum.install');
}
/**
@@ -62,6 +61,8 @@ class InstallServiceProvider extends AbstractServiceProvider
*/
public function boot()
{
$this->loadViewsFrom(__DIR__.'/../../views/install', 'flarum.install');
$this->populateRoutes($this->app->make('flarum.install.routes'));
}

View File

@@ -23,12 +23,37 @@ class WritablePaths extends AbstractPrerequisite
public function check()
{
foreach ($this->paths as $path) {
if (! is_writable($path)) {
if (! file_exists($path)) {
$this->errors[] = [
'message' => 'The '.realpath($path).' directory is not writable.',
'message' => 'The '.$this->getAbsolutePath($path).' directory doesn\'t exist',
'detail' => 'This directory is necessary for the installation. Please create the folder.',
];
} elseif (! is_writable($path)) {
$this->errors[] = [
'message' => 'The '.$this->getAbsolutePath($path).' directory is not writable.',
'detail' => 'Please chmod this directory'.($path !== public_path() ? ' and its contents' : '').' to 0775.'
];
}
}
}
private function getAbsolutePath($path)
{
$path = str_replace(['/', '\\'], DIRECTORY_SEPARATOR, $path);
$parts = array_filter(explode(DIRECTORY_SEPARATOR, $path), 'strlen');
$absolutes = [];
foreach ($parts as $part) {
if ('.' == $part) {
continue;
}
if ('..' == $part) {
array_pop($absolutes);
} else {
$absolutes[] = $part;
}
}
return (substr($path, 0, 1) == '/' ? '/' : '').implode(DIRECTORY_SEPARATOR, $absolutes);
}
}