3 * @file src/BaseObject.php
7 require_once __DIR__ . '/../boot.php';
10 use Friendica\Network\HTTPException\InternalServerErrorException;
15 * Contains what is useful to any object
17 * Act's like a global registry for classes
22 * @var Dice The Dependency Injection library
27 * Set's the dependency injection library for a global usage
29 * @param Dice $dice The dependency injection library
31 public static function setDependencyInjection(Dice $dice)
39 * Same as get_app from boot.php
43 public static function getApp()
45 return self::getClass(App::class);
49 * Returns the initialized class based on it's name
51 * @param string $name The name of the class
53 * @return object The initialized name
55 * @throws InternalServerErrorException
57 protected static function getClass(string $name)
59 if (empty(self::$dice)) {
60 throw new InternalServerErrorException('DICE isn\'t initialized.');
63 if (class_exists($name) || interface_exists($name)) {
64 return self::$dice->create($name);
66 throw new InternalServerErrorException('Class \'' . $name . '\' isn\'t valid.');