]> git.mxchange.org Git - friendica.git/blob - src/BaseObject.php
There are no dead nodes anymore
[friendica.git] / src / BaseObject.php
1 <?php
2 /**
3  * @file src/BaseObject.php
4  */
5 namespace Friendica;
6
7 require_once __DIR__ . '/../boot.php';
8
9 use Friendica\Network\HTTPException\InternalServerErrorException;
10
11 /**
12  * Basic object
13  *
14  * Contains what is useful to any object
15  */
16 class BaseObject
17 {
18         /**
19          * @var App
20          */
21         private static $app = null;
22
23         /**
24          * Get the app
25          *
26          * Same as get_app from boot.php
27          *
28          * @return App
29          * @throws \Exception
30          */
31         public static function getApp()
32         {
33                 if (empty(self::$app)) {
34                         throw new InternalServerErrorException('App isn\'t initialized.');
35                 }
36
37                 return self::$app;
38         }
39
40         /**
41          * Set the app
42          *
43          * @param App $app App
44          *
45          * @return void
46          */
47         public static function setApp(App $app)
48         {
49                 self::$app = $app;
50         }
51 }