Moved config file to config class
This commit is contained in:
parent
2af82d0fe4
commit
40888326cc
11
app/app.php
11
app/app.php
|
@ -1,6 +1,5 @@
|
|||
<?php
|
||||
|
||||
// Init
|
||||
require_once __DIR__.'/init.php';
|
||||
|
||||
global $utopia, $request, $response, $register, $consoleDB, $project;
|
||||
|
@ -21,9 +20,6 @@ use Appwrite\Network\Validator\Origin;
|
|||
/*
|
||||
* Configuration files
|
||||
*/
|
||||
$roles = include __DIR__.'/config/roles.php'; // User roles and scopes
|
||||
$services = include __DIR__.'/config/services.php'; // List of services
|
||||
|
||||
$webhook = new Event('v1-webhooks', 'WebhooksV1');
|
||||
$audit = new Event('v1-audits', 'AuditsV1');
|
||||
$usage = new Event('v1-usage', 'UsageV1');
|
||||
|
@ -54,7 +50,7 @@ $clients = \array_unique(\array_merge($clientsConsole, \array_map(function ($nod
|
|||
return false;
|
||||
}))));
|
||||
|
||||
$utopia->init(function () use ($utopia, $request, $response, &$user, $project, $console, $roles, $webhook, $mail, $audit, $usage, $clients) {
|
||||
$utopia->init(function () use ($utopia, $request, $response, &$user, $project, $console, $webhook, $mail, $audit, $usage, $clients) {
|
||||
|
||||
$route = $utopia->match($request);
|
||||
|
||||
|
@ -142,6 +138,7 @@ $utopia->init(function () use ($utopia, $request, $response, &$user, $project, $
|
|||
}
|
||||
}
|
||||
|
||||
$roles = Config::getParam('roles', []);
|
||||
$scope = $route->getLabel('scope', 'none'); // Allowed scope for chosen route
|
||||
$scopes = $roles[$role]['scopes']; // Allowed scopes for user role
|
||||
|
||||
|
@ -429,8 +426,8 @@ $utopia->get('/.well-known/acme-challenge')
|
|||
include_once __DIR__ . '/controllers/shared/api.php';
|
||||
include_once __DIR__ . '/controllers/shared/web.php';
|
||||
|
||||
foreach($services as $key => $service) {
|
||||
include_once $services[$key]['controller'];
|
||||
foreach(Config::getParam('services', []) as $service) {
|
||||
include_once $service['controller'];
|
||||
}
|
||||
|
||||
$utopia->run($request, $response);
|
|
@ -167,7 +167,9 @@ $utopia->get('/open-api-2.json')
|
|||
->param('extensions', 0, function () {return new Range(0, 1);}, 'Show extra data.', true)
|
||||
->param('tests', 0, function () {return new Range(0, 1);}, 'Include only test services.', true)
|
||||
->action(
|
||||
function ($platform, $extensions, $tests) use ($response, $request, $utopia, $services) {
|
||||
function ($platform, $extensions, $tests) use ($response, $request, $utopia) {
|
||||
$services = Config::getParam('services', []);
|
||||
|
||||
function fromCamelCase($input)
|
||||
{
|
||||
\preg_match_all('!([A-Z][A-Z0-9]*(?=$|[A-Z][a-z0-9])|[A-Za-z][a-z0-9]+)!', $input, $matches);
|
||||
|
|
|
@ -62,6 +62,8 @@ Config::load('providers', __DIR__.'/../app/config/providers.php');
|
|||
Config::load('platforms', __DIR__.'/../app/config/platforms.php');
|
||||
Config::load('locales', __DIR__.'/../app/config/locales.php');
|
||||
Config::load('collections', __DIR__.'/../app/config/collections.php');
|
||||
Config::load('roles', __DIR__.'/../app/config/roles.php'); // User roles and scopes
|
||||
Config::load('services', __DIR__.'/../app/config/services.php'); // List of services
|
||||
|
||||
Config::setParam('env', $utopia->getMode());
|
||||
Config::setParam('domain', $request->getServer('HTTP_HOST', ''));
|
||||
|
|
Loading…
Reference in a new issue