2) Refactor App->config[] into Core\PConfig
[friendica.git/.git] / src / BaseObject.php
1 <?php
2 /**
3  * @file src/BaseObject.php
4  */
5 namespace Friendica;
6
7 require_once 'boot.php';
8
9 use Friendica\Util\LoggerFactory;
10
11 /**
12  * Basic object
13  *
14  * Contains what is useful to any object
15  */
16 class BaseObject
17 {
18         private static $app = null;
19
20         /**
21          * Get the app
22          *
23          * Same as get_app from boot.php
24          *
25          * @return App
26          * @throws \Exception
27          */
28         public static function getApp()
29         {
30                 if (empty(self::$app)) {
31                         $logger = $logger = LoggerFactory::create('app');
32                         self::$app = new App(dirname(__DIR__), $logger);
33                 }
34
35                 return self::$app;
36         }
37
38         /**
39          * Set the app
40          *
41          * @param App $app App
42          *
43          * @return void
44          */
45         public static function setApp(App $app)
46         {
47                 self::$app = $app;
48         }
49 }