Moved includes to own file
This commit is contained in:
parent
e55d5c7c15
commit
e727b367cc
|
@ -0,0 +1,77 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Engelsystem\Application;
|
||||||
|
use Engelsystem\Config\Config;
|
||||||
|
use Engelsystem\Exceptions\Handler as ExceptionHandler;
|
||||||
|
use Engelsystem\Http\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\Session\Session;
|
||||||
|
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
|
||||||
|
use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This file includes all needed functions, connects to the db etc.
|
||||||
|
*/
|
||||||
|
require_once __DIR__ . '/autoload.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize and bootstrap the application
|
||||||
|
*/
|
||||||
|
$app = new Application(realpath(__DIR__ . DIRECTORY_SEPARATOR . '..'));
|
||||||
|
$appConfig = $app->make(Config::class);
|
||||||
|
$appConfig->set(require config_path('app.php'));
|
||||||
|
$app->bootstrap($appConfig);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configure application
|
||||||
|
*/
|
||||||
|
date_default_timezone_set($app->get('config')->get('timezone'));
|
||||||
|
|
||||||
|
if (config('environment') == 'development') {
|
||||||
|
$errorHandler = $app->get('error.handler');
|
||||||
|
$errorHandler->setEnvironment(ExceptionHandler::ENV_DEVELOPMENT);
|
||||||
|
ini_set('display_errors', true);
|
||||||
|
error_reporting(E_ALL);
|
||||||
|
} else {
|
||||||
|
ini_set('display_errors', false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check for maintenance
|
||||||
|
*/
|
||||||
|
if ($app->get('config')->get('maintenance')) {
|
||||||
|
echo file_get_contents(__DIR__ . '/../templates/maintenance.html');
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize Request
|
||||||
|
*
|
||||||
|
* @var Request $request
|
||||||
|
*/
|
||||||
|
$request = Request::createFromGlobals();
|
||||||
|
$app->instance('request', $request);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Include legacy code
|
||||||
|
*/
|
||||||
|
require __DIR__ . '/includes.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Init application
|
||||||
|
*/
|
||||||
|
$sessionStorage = (PHP_SAPI != 'cli' ? new NativeSessionStorage(['cookie_httponly' => true]) : new MockArraySessionStorage());
|
||||||
|
$session = new Session($sessionStorage);
|
||||||
|
$app->instance('session', $session);
|
||||||
|
$session->start();
|
||||||
|
$request->setSession($session);
|
||||||
|
|
||||||
|
|
||||||
|
gettext_init();
|
||||||
|
|
||||||
|
load_auth();
|
|
@ -1,61 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Engelsystem\Application;
|
|
||||||
use Engelsystem\Config\Config;
|
|
||||||
use Engelsystem\Exceptions\Handler as ExceptionHandler;
|
|
||||||
use Engelsystem\Http\Request;
|
|
||||||
use Symfony\Component\HttpFoundation\Session\Session;
|
|
||||||
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
|
|
||||||
use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This file includes all needed functions, connects to the db etc.
|
|
||||||
*/
|
|
||||||
require_once __DIR__ . '/autoload.php';
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialize and bootstrap the application
|
|
||||||
*/
|
|
||||||
$app = new Application(realpath(__DIR__ . DIRECTORY_SEPARATOR . '..'));
|
|
||||||
$appConfig = $app->make(Config::class);
|
|
||||||
$appConfig->set(require config_path('app.php'));
|
|
||||||
$app->bootstrap($appConfig);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Configure application
|
|
||||||
*/
|
|
||||||
date_default_timezone_set($app->get('config')->get('timezone'));
|
|
||||||
|
|
||||||
if (config('environment') == 'development') {
|
|
||||||
$errorHandler = $app->get('error.handler');
|
|
||||||
$errorHandler->setEnvironment(ExceptionHandler::ENV_DEVELOPMENT);
|
|
||||||
ini_set('display_errors', true);
|
|
||||||
error_reporting(E_ALL);
|
|
||||||
} else {
|
|
||||||
ini_set('display_errors', false);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check for maintenance
|
|
||||||
*/
|
|
||||||
if ($app->get('config')->get('maintenance')) {
|
|
||||||
echo file_get_contents(__DIR__ . '/../templates/maintenance.html');
|
|
||||||
die();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialize Request
|
|
||||||
*
|
|
||||||
* @var Request $request
|
|
||||||
*/
|
|
||||||
$request = Request::createFromGlobals();
|
|
||||||
$app->instance('request', $request);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Include legacy code
|
* Include legacy code
|
||||||
*/
|
*/
|
||||||
|
@ -140,17 +84,3 @@ $includeFiles = [
|
||||||
foreach ($includeFiles as $file) {
|
foreach ($includeFiles as $file) {
|
||||||
require_once realpath($file);
|
require_once realpath($file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Init application
|
|
||||||
*/
|
|
||||||
$sessionStorage = (PHP_SAPI != 'cli' ? new NativeSessionStorage(['cookie_httponly' => true]) : new MockArraySessionStorage());
|
|
||||||
$session = new Session($sessionStorage);
|
|
||||||
$app->instance('session', $session);
|
|
||||||
$session->start();
|
|
||||||
$request->setSession($session);
|
|
||||||
|
|
||||||
gettext_init();
|
|
||||||
|
|
||||||
load_auth();
|
|
|
@ -1,6 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once realpath(__DIR__ . '/../includes/engelsystem_provider.php');
|
use Engelsystem\Http\Request;
|
||||||
|
|
||||||
|
require_once realpath(__DIR__ . '/../includes/engelsystem.php');
|
||||||
|
|
||||||
$free_pages = [
|
$free_pages = [
|
||||||
'admin_event_config',
|
'admin_event_config',
|
||||||
|
@ -25,6 +27,8 @@ $page = '';
|
||||||
$title = '';
|
$title = '';
|
||||||
$content = '';
|
$content = '';
|
||||||
|
|
||||||
|
/** @var Request $request */
|
||||||
|
$request = $app->get('request');
|
||||||
$page = $request->query->get('p');
|
$page = $request->query->get('p');
|
||||||
if (empty($page)) {
|
if (empty($page)) {
|
||||||
$page = $request->path();
|
$page = $request->path();
|
||||||
|
|
|
@ -12,7 +12,7 @@ class EngelsystemLoggerTest extends TestCase
|
||||||
{
|
{
|
||||||
public static function setUpBeforeClass()
|
public static function setUpBeforeClass()
|
||||||
{
|
{
|
||||||
require_once __DIR__ . '/../../../includes/engelsystem_provider.php';
|
require_once __DIR__ . '/../../../includes/engelsystem.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -9,7 +9,7 @@ class LogEntriesModelTest extends TestCase
|
||||||
{
|
{
|
||||||
public static function setUpBeforeClass()
|
public static function setUpBeforeClass()
|
||||||
{
|
{
|
||||||
require_once __DIR__ . '/../../../includes/engelsystem_provider.php';
|
require_once __DIR__ . '/../../../includes/engelsystem.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCreateLogEntry()
|
public function testCreateLogEntry()
|
||||||
|
|
|
@ -10,7 +10,7 @@ class RoomModelTest extends TestCase
|
||||||
|
|
||||||
public static function setUpBeforeClass()
|
public static function setUpBeforeClass()
|
||||||
{
|
{
|
||||||
require_once __DIR__ . '/../../../includes/engelsystem_provider.php';
|
require_once __DIR__ . '/../../../includes/engelsystem.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function create_Room()
|
public function create_Room()
|
||||||
|
|
Loading…
Reference in New Issue