Set BaseObject::setApp in App

This commit is contained in:
Hypolite Petovan 2018-06-25 20:44:35 -04:00
parent e952d6677b
commit decfc553f7
7 changed files with 7 additions and 21 deletions

View file

@ -33,7 +33,6 @@
*/ */
use Friendica\App; use Friendica\App;
use Friendica\BaseObject;
use Friendica\Core\Config; use Friendica\Core\Config;
use Friendica\Util\ExAuth; use Friendica\Util\ExAuth;
@ -55,7 +54,6 @@ require_once "boot.php";
require_once "include/dba.php"; require_once "include/dba.php";
$a = new App(dirname(__DIR__)); $a = new App(dirname(__DIR__));
BaseObject::setApp($a);
@include ".htconfig.php"; @include ".htconfig.php";
dba::connect($db_host, $db_user, $db_pass, $db_data); dba::connect($db_host, $db_user, $db_pass, $db_data);
@ -63,4 +61,4 @@ unset($db_host, $db_user, $db_pass, $db_data);
$oAuth = new ExAuth(); $oAuth = new ExAuth();
$oAuth->readStdin(); $oAuth->readStdin();

View file

@ -8,7 +8,6 @@
*/ */
use Friendica\App; use Friendica\App;
use Friendica\BaseObject;
use Friendica\Core\Config; use Friendica\Core\Config;
use Friendica\Core\Worker; use Friendica\Core\Worker;
@ -28,7 +27,6 @@ require_once "boot.php";
require_once "include/dba.php"; require_once "include/dba.php";
$a = new App(dirname(__DIR__)); $a = new App(dirname(__DIR__));
BaseObject::setApp($a);
require_once ".htconfig.php"; require_once ".htconfig.php";
dba::connect($db_host, $db_user, $db_pass, $db_data); dba::connect($db_host, $db_user, $db_pass, $db_data);

View file

@ -27,7 +27,6 @@ require_once "boot.php";
require_once "include/dba.php"; require_once "include/dba.php";
$a = new App(dirname(__DIR__)); $a = new App(dirname(__DIR__));
BaseObject::setApp($a);
require_once ".htconfig.php"; require_once ".htconfig.php";
dba::connect($db_host, $db_user, $db_pass, $db_data); dba::connect($db_host, $db_user, $db_pass, $db_data);

View file

@ -508,14 +508,7 @@ if (!defined('CURLE_OPERATION_TIMEDOUT')) {
*/ */
function get_app() function get_app()
{ {
global $a; return BaseObject::getApp();
if (empty($a)) {
$a = new App(dirname(__DIR__));
BaseObject::setApp($a);
}
return $a;
} }
/** /**

View file

@ -9,7 +9,6 @@
*/ */
use Friendica\App; use Friendica\App;
use Friendica\BaseObject;
use Friendica\Content\Nav; use Friendica\Content\Nav;
use Friendica\Core\Addon; use Friendica\Core\Addon;
use Friendica\Core\Config; use Friendica\Core\Config;
@ -25,7 +24,6 @@ use Friendica\Module\Login;
require_once 'boot.php'; require_once 'boot.php';
$a = new App(__DIR__); $a = new App(__DIR__);
BaseObject::setApp($a);
// We assume that the index.php is called by a frontend process // We assume that the index.php is called by a frontend process
// The value is set to "true" by default in boot.php // The value is set to "true" by default in boot.php

View file

@ -139,6 +139,8 @@ class App
throw new Exception('Basepath ' . $basepath . ' isn\'t usable.'); throw new Exception('Basepath ' . $basepath . ' isn\'t usable.');
} }
BaseObject::setApp($this);
$this->basepath = rtrim($basepath, DIRECTORY_SEPARATOR); $this->basepath = rtrim($basepath, DIRECTORY_SEPARATOR);
$this->determineUrlPath(); $this->determineUrlPath();

View file

@ -24,12 +24,10 @@ class BaseObject
*/ */
public static function getApp() public static function getApp()
{ {
if (self::$app) { if (empty(self::$app)) {
return self::$app; self::$app = new App(dirname(__DIR__));
} }
self::$app = get_app();
return self::$app; return self::$app;
} }
@ -40,7 +38,7 @@ class BaseObject
* *
* @return void * @return void
*/ */
public static function setApp($app) public static function setApp(App $app)
{ {
self::$app = $app; self::$app = $app;
} }