Refactor configuration methods into trait

This commit is contained in:
James Cole
2018-08-09 17:50:30 +02:00
parent 9865800e39
commit 2ed433c96d
5 changed files with 262 additions and 211 deletions

View File

@@ -27,6 +27,7 @@ namespace FireflyIII\Http\Controllers\System;
use Artisan;
use Exception;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Support\Http\Controllers\GetConfigurationData;
use Illuminate\Http\JsonResponse;
use Laravel\Passport\Passport;
use Log;
@@ -39,6 +40,7 @@ use phpseclib\Crypt\RSA;
*/
class InstallController extends Controller
{
use GetConfigurationData;
/** @var string Forbidden error */
public const FORBIDDEN_ERROR = 'Internal PHP function "proc_close" is disabled for your installation. Auto-migration is not possible.';
/** @var string Basedir error */
@@ -178,29 +180,5 @@ class InstallController extends Controller
return response()->json(['error' => false, 'message' => 'OK']);
}
/**
* Check if forbidden functions are set.
*
* @return bool
*/
protected function hasForbiddenFunctions(): bool // validate system config
{
$list = ['proc_close'];
$forbidden = explode(',', ini_get('disable_functions'));
$trimmed = array_map(
function (string $value) {
return trim($value);
}, $forbidden
);
foreach ($list as $entry) {
if (\in_array($entry, $trimmed, true)) {
Log::error('Method "%s" is FORBIDDEN, so the console command cannot be executed.');
return true;
}
}
return false;
}
}