friendica_2021.01_tupambae_.../src/BaseObject.php

49 lines
703 B
PHP
Raw Normal View History

<?php
/**
* @file src/BaseObject.php
*/
namespace Friendica;
require_once __DIR__ . '/../boot.php';
2018-12-30 21:42:56 +01:00
use Friendica\Network\HTTPException\InternalServerErrorException;
2018-12-30 21:42:56 +01:00
/**
* Basic object
*
* Contains what is useful to any object
*/
class BaseObject
{
private static $app = null;
/**
* Get the app
*
* Same as get_app from boot.php
*
* @return App
2019-01-06 22:06:53 +01:00
* @throws \Exception
*/
public static function getApp()
{
2018-06-26 02:44:35 +02:00
if (empty(self::$app)) {
2019-02-05 22:56:57 +01:00
throw new InternalServerErrorException('App isn\'t initialized.');
}
return self::$app;
}
/**
* Set the app
*
2018-11-01 13:44:47 +01:00
* @param App $app App
*
* @return void
*/
2018-06-26 02:44:35 +02:00
public static function setApp(App $app)
{
self::$app = $app;
}
}