2017-11-16 19:05:41 +01:00
|
|
|
<?php
|
|
|
|
/**
|
2017-11-19 22:50:49 +01:00
|
|
|
* @file src/BaseObject.php
|
2017-11-16 19:05:41 +01:00
|
|
|
*/
|
2017-11-19 22:50:49 +01:00
|
|
|
namespace Friendica;
|
2017-11-16 19:05:41 +01:00
|
|
|
|
2018-12-30 21:42:56 +01:00
|
|
|
require_once 'boot.php';
|
|
|
|
|
2019-02-03 22:46:50 +01:00
|
|
|
use Friendica\Core\Config;
|
|
|
|
use Friendica\Factory;
|
|
|
|
use Friendica\Util\BasePath;
|
2018-12-30 21:42:56 +01:00
|
|
|
|
2017-11-16 19:05:41 +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
|
2017-11-19 20:15:25 +01:00
|
|
|
*
|
2017-12-17 17:34:43 +01:00
|
|
|
* @return App
|
2019-01-06 22:06:53 +01:00
|
|
|
* @throws \Exception
|
2017-11-16 19:05:41 +01:00
|
|
|
*/
|
2017-11-19 22:50:49 +01:00
|
|
|
public static function getApp()
|
2017-11-16 19:05:41 +01:00
|
|
|
{
|
2018-06-26 02:44:35 +02:00
|
|
|
if (empty(self::$app)) {
|
2019-02-03 22:46:50 +01:00
|
|
|
$basedir = BasePath::create(dirname(__DIR__));
|
|
|
|
$configLoader = new Config\ConfigCacheLoader($basedir);
|
|
|
|
$config = Factory\ConfigFactory::createCache($configLoader);
|
|
|
|
$logger = Factory\LoggerFactory::create('app', $config);
|
|
|
|
self::$app = new App($config, $logger);
|
2017-11-16 19:05:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return self::$app;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the app
|
|
|
|
*
|
2018-11-01 13:44:47 +01:00
|
|
|
* @param App $app App
|
2017-11-19 20:15:25 +01:00
|
|
|
*
|
|
|
|
* @return void
|
2017-11-16 19:05:41 +01:00
|
|
|
*/
|
2018-06-26 02:44:35 +02:00
|
|
|
public static function setApp(App $app)
|
2017-11-16 19:05:41 +01:00
|
|
|
{
|
|
|
|
self::$app = $app;
|
|
|
|
}
|
|
|
|
}
|