friendica-github/src/BaseObject.php

55 lines
908 B
PHP
Raw Normal View History

<?php
/**
* @file src/BaseObject.php
*/
namespace Friendica;
2018-12-30 20:42:56 +00:00
require_once 'boot.php';
use Friendica\Core\Config;
use Friendica\Factory;
use Friendica\Util\BasePath;
2018-12-30 20:42:56 +00: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 21:06:53 +00:00
* @throws \Exception
*/
public static function getApp()
{
2018-06-26 00:44:35 +00:00
if (empty(self::$app)) {
$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);
}
return self::$app;
}
/**
* Set the app
*
2018-11-01 12:44:47 +00:00
* @param App $app App
*
* @return void
*/
2018-06-26 00:44:35 +00:00
public static function setApp(App $app)
{
self::$app = $app;
}
}