Friendica Communications Platform (please note that this is a clone of the repository at github, issues are handled there) https://friendi.ca
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
908B

  1. <?php
  2. /**
  3. * @file src/BaseObject.php
  4. */
  5. namespace Friendica;
  6. require_once 'boot.php';
  7. use Friendica\Core\Config;
  8. use Friendica\Factory;
  9. use Friendica\Util\BasePath;
  10. /**
  11. * Basic object
  12. *
  13. * Contains what is useful to any object
  14. */
  15. class BaseObject
  16. {
  17. private static $app = null;
  18. /**
  19. * Get the app
  20. *
  21. * Same as get_app from boot.php
  22. *
  23. * @return App
  24. * @throws \Exception
  25. */
  26. public static function getApp()
  27. {
  28. if (empty(self::$app)) {
  29. $basedir = BasePath::create(dirname(__DIR__));
  30. $configLoader = new Config\ConfigCacheLoader($basedir);
  31. $config = Factory\ConfigFactory::createCache($configLoader);
  32. $logger = Factory\LoggerFactory::create('app', $config);
  33. self::$app = new App($config, $logger);
  34. }
  35. return self::$app;
  36. }
  37. /**
  38. * Set the app
  39. *
  40. * @param App $app App
  41. *
  42. * @return void
  43. */
  44. public static function setApp(App $app)
  45. {
  46. self::$app = $app;
  47. }
  48. }