Model 里的 $dispather 属性,是如何在实例化之前就有 默认值了?没有看到在哪里去设置这个值的
我在 Illuminate\Database\Eloquent\Model 里 var_dump(static::$dispatcher)
public function __construct(array $attributes = [])
{
var_dump(static::$dispatcher);
$this->bootIfNotBooted();
$this->syncOriginal();
$this->fill($attributes);
}
构造函数并没有去设置 $dispatcher 这个值
但在页面上可以得到这个值
/home/vagrant/Code/blog/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:152:
object(Illuminate\Events\Dispatcher)[23]
protected 'container' =>
object(Illuminate\Foundation\Application)[3]
protected 'basePath' => string '/home/vagrant/Code/blog' (length=23)
protected 'hasBeenBootstrapped' => boolean true
protected 'booted' => boolean false
protected 'bootingCallbacks' =>
array (size=2)
0 =>
object(Closure)[158]
...
1 =>
object(Closure)[180]
...
protected 'bootedCallbacks' =>
array (size=1)
0 =>
object(Closure)[123]
请问这个值是在哪一步给设置进去了
https://github.com/laravel/framework/blob/...
恩 现在知道是这里设置了,但在哪里谁去调用它了,需要去找到主体
我把
注释掉发现
然后在 Illuminate\Database\DatabaseServiceProvider 发现
顺藤摸瓜 终于找到它了 又 get 到了一个知识点:+1: @leo
@jc91715 请学会用 PHPStorm,右键目标类/方法/属性等等,Find Usage