Skip to content

Commit 03f38ff

Browse files
committed
Update Facade.php
1 parent 0e16f21 commit 03f38ff

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

src/Help/Facade.php

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,33 @@
66
*/
77
namespace Evas\Base\Help;
88

9+
use Evas\Base\Help\HooksTrait;
10+
911
class Facade
1012
{
11-
/** @static static объект обёрнутый в фасад */
12-
protected static $latestObject;
13+
/**
14+
* Подключаем трейт хуков.
15+
*/
16+
use HooksTrait;
17+
18+
/** @static static объект монтированный в фасад */
19+
protected static $mountedObject;
1320

1421
/**
1522
* Конструктор.
1623
*/
1724
public function __construct()
1825
{
19-
static::switch($this);
26+
static::mount($this);
2027
}
2128

2229
/**
23-
* Переключение содержимого фасада.
30+
* Монтирование содержимого фасада.
2431
* @param static объект
2532
*/
26-
public static function switch(Facade &$object)
33+
public static function mount(Facade &$object)
2734
{
28-
static::$latestObject = &$object;
35+
static::$mountedObject = &$object;
2936
}
3037

3138
/**
@@ -42,7 +49,7 @@ public function __call(string $name, array $args = null)
4249
'Facade entity %s not has method %s', __CLASS__, $name
4350
));
4451
}
45-
static::switch($this);
52+
static::mount($this);
4653
return $this->$name(...$args ?? []);
4754
}
4855

@@ -60,9 +67,12 @@ public static function __callStatic(string $name, array $args = null)
6067
'Facade entity %s not has method %s', __CLASS__, $name
6168
));
6269
}
63-
if (!static::$latestObject) {
70+
if (!static::$mountedObject) {
71+
static::staticHook('mountDefault');
72+
}
73+
if (!static::$mountedObject) {
6474
throw new \BadMethodCallException(sprintf('Facade %s not has entity', __CLASS__));
6575
}
66-
return static::$latestObject->$name(...$args ?? []);
76+
return static::$mountedObject->$name(...$args ?? []);
6777
}
6878
}

0 commit comments

Comments
 (0)