mirror of
https://github.com/friendica/friendica
synced 2025-05-06 11:04:12 +02:00
Introduce new DI container
- Adding Friendica\DI class for getting dynamic classes - Replacing BaseObject::getApp() with this class
This commit is contained in:
parent
a9220aa83b
commit
1de3f186d7
132 changed files with 377 additions and 270 deletions
33
src/DI.php
Normal file
33
src/DI.php
Normal file
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
namespace Friendica;
|
||||
|
||||
use Dice\Dice;
|
||||
|
||||
/**
|
||||
* This class is capable of getting all dynamic created classes
|
||||
*
|
||||
* There has to be a "method" phpDoc for each new class, containing result class for a proper matching
|
||||
*
|
||||
* @method static App app()
|
||||
*/
|
||||
class DI
|
||||
{
|
||||
/** @var Dice */
|
||||
private static $dice;
|
||||
|
||||
public static function init(Dice $dice)
|
||||
{
|
||||
self::$dice = $dice;
|
||||
}
|
||||
|
||||
public static function __callStatic($name, $arguments)
|
||||
{
|
||||
switch ($name) {
|
||||
case 'app':
|
||||
return self::$dice->create(App::class, $arguments);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue