Browse Source

Set BaseObject::setApp in App

tags/2018.09
Hypolite Petovan 1 year ago
parent
commit
decfc553f7
7 changed files with 7 additions and 21 deletions
  1. 1
    3
      bin/auth_ejabberd.php
  2. 0
    2
      bin/daemon.php
  3. 0
    1
      bin/worker.php
  4. 1
    8
      boot.php
  5. 0
    2
      index.php
  6. 2
    0
      src/App.php
  7. 3
    5
      src/BaseObject.php

+ 1
- 3
bin/auth_ejabberd.php View File

@@ -33,7 +33,6 @@
33 33
  */
34 34
 
35 35
 use Friendica\App;
36
-use Friendica\BaseObject;
37 36
 use Friendica\Core\Config;
38 37
 use Friendica\Util\ExAuth;
39 38
 
@@ -55,7 +54,6 @@ require_once "boot.php";
55 54
 require_once "include/dba.php";
56 55
 
57 56
 $a = new App(dirname(__DIR__));
58
-BaseObject::setApp($a);
59 57
 
60 58
 @include ".htconfig.php";
61 59
 dba::connect($db_host, $db_user, $db_pass, $db_data);
@@ -63,4 +61,4 @@ unset($db_host, $db_user, $db_pass, $db_data);
63 61
 
64 62
 $oAuth = new ExAuth();
65 63
 
66
-$oAuth->readStdin();
64
+$oAuth->readStdin();

+ 0
- 2
bin/daemon.php View File

@@ -8,7 +8,6 @@
8 8
  */
9 9
 
10 10
 use Friendica\App;
11
-use Friendica\BaseObject;
12 11
 use Friendica\Core\Config;
13 12
 use Friendica\Core\Worker;
14 13
 
@@ -28,7 +27,6 @@ require_once "boot.php";
28 27
 require_once "include/dba.php";
29 28
 
30 29
 $a = new App(dirname(__DIR__));
31
-BaseObject::setApp($a);
32 30
 
33 31
 require_once ".htconfig.php";
34 32
 dba::connect($db_host, $db_user, $db_pass, $db_data);

+ 0
- 1
bin/worker.php View File

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

+ 1
- 8
boot.php View File

@@ -508,14 +508,7 @@ if (!defined('CURLE_OPERATION_TIMEDOUT')) {
508 508
  */
509 509
 function get_app()
510 510
 {
511
-	global $a;
512
-
513
-	if (empty($a)) {
514
-		$a = new App(dirname(__DIR__));
515
-		BaseObject::setApp($a);
516
-	}
517
-
518
-	return $a;
511
+	return BaseObject::getApp();
519 512
 }
520 513
 
521 514
 /**

+ 0
- 2
index.php View File

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

+ 2
- 0
src/App.php View File

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

+ 3
- 5
src/BaseObject.php View File

@@ -24,12 +24,10 @@ class BaseObject
24 24
 	 */
25 25
 	public static function getApp()
26 26
 	{
27
-		if (self::$app) {
28
-			return self::$app;
27
+		if (empty(self::$app)) {
28
+			self::$app = new App(dirname(__DIR__));
29 29
 		}
30 30
 
31
-		self::$app = get_app();
32
-
33 31
 		return self::$app;
34 32
 	}
35 33
 
@@ -40,7 +38,7 @@ class BaseObject
40 38
 	 *
41 39
 	 * @return void
42 40
 	 */
43
-	public static function setApp($app)
41
+	public static function setApp(App $app)
44 42
 	{
45 43
 		self::$app = $app;
46 44
 	}

Loading…
Cancel
Save