]> git.mxchange.org Git - friendica.git/blob - src/BaseObject.php
4deba1ced15eba7df9c3c53f63318970502fa079
[friendica.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\Core\Config;
10 use Friendica\Factory;
11 use Friendica\Util\BasePath;
12
13 /**
14  * Basic object
15  *
16  * Contains what is useful to any object
17  */
18 class BaseObject
19 {
20         private static $app = null;
21
22         /**
23          * Get the app
24          *
25          * Same as get_app from boot.php
26          *
27          * @return App
28          * @throws \Exception
29          */
30         public static function getApp()
31         {
32                 if (empty(self::$app)) {
33                         $basedir = BasePath::create(dirname(__DIR__));
34                         $configLoader = new Config\ConfigCacheLoader($basedir);
35                         $config = Factory\ConfigFactory::createCache($configLoader);
36                         $logger = Factory\LoggerFactory::create('app', $config);
37                         self::$app = new App($config, $logger);
38                 }
39
40                 return self::$app;
41         }
42
43         /**
44          * Set the app
45          *
46          * @param App $app App
47          *
48          * @return void
49          */
50         public static function setApp(App $app)
51         {
52                 self::$app = $app;
53         }
54 }