1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- <?php
- declare(strict_types=1);
- namespace think;
- class Facade
- {
-
- protected static $alwaysNewInstance;
- protected static $instance;
-
- protected static function getFacadeClass()
- {}
-
- protected static function createFacade(bool $newInstance = false)
- {
- $class = static::getFacadeClass() ?: 'think\DbManager';
- if (static::$alwaysNewInstance) {
- $newInstance = true;
- }
- if ($newInstance) {
- return new $class();
- }
- if (!self::$instance) {
- self::$instance = new $class();
- }
- return self::$instance;
- }
-
- public static function __callStatic($method, $params)
- {
- return call_user_func_array([static::createFacade(), $method], $params);
- }
- }
|