回答編集履歴
1
調査手順追記
test
CHANGED
@@ -11,3 +11,107 @@
|
|
11
11
|
前のコメントで反応無かったんであえて本回答に書きますが、コードを読むのは面倒くさいだけで特にコツはありません、ただソースを愚直に追うだけです。
|
12
12
|
|
13
13
|
実際に自分もこの質問を見てからの数分程度、vimで追ってみただけです。grepすら使ってません。
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
### dispatchToRouterについて調べた手順
|
18
|
+
|
19
|
+
`vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php`を見ると、
|
20
|
+
|
21
|
+
```ここに言語を入力
|
22
|
+
|
23
|
+
Pipeline->send->through->then(dispatchToRouter())
|
24
|
+
|
25
|
+
```
|
26
|
+
|
27
|
+
という呼び出しと共に使われている事が分かるので、`Pipeline`がどこにあるかをファイル内を検索すると`use Illuminate\Routing\Pipeline;`している事が分かる
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
`vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php`でthenを検索してみるがヒットしないので、extendsしている`BasePipeline`に目星をつけて、BasePipelineを検索すると`use Illuminate\Pipeline\Pipeline as BasePipeline;`している事が分かる
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
`vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php`でthenを検索すると
|
36
|
+
|
37
|
+
```php
|
38
|
+
|
39
|
+
97 public function then(Closure $destination)
|
40
|
+
|
41
|
+
98 {
|
42
|
+
|
43
|
+
99 $pipeline = array_reduce(
|
44
|
+
|
45
|
+
100 array_reverse($this->pipes()), $this->carry(), $this->prepareDestination($destination)
|
46
|
+
|
47
|
+
101 );
|
48
|
+
|
49
|
+
102
|
50
|
+
|
51
|
+
103 return $pipeline($this->passable);
|
52
|
+
|
53
|
+
104 }
|
54
|
+
|
55
|
+
105
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
```
|
60
|
+
|
61
|
+
が見つかり、`$this->prepareDestination($destination)`という呼び出しをしている事が分かる
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
同ファイル内で`prepareDestination`を調べてみると、
|
66
|
+
|
67
|
+
```php
|
68
|
+
|
69
|
+
26 return function ($passable) use ($destination) {
|
70
|
+
|
71
|
+
127 try {
|
72
|
+
|
73
|
+
128 return $destination($passable);
|
74
|
+
|
75
|
+
129 } catch (Throwable $e) {
|
76
|
+
|
77
|
+
130 return $this->handleException($passable, $e);
|
78
|
+
|
79
|
+
131 }
|
80
|
+
|
81
|
+
132 };
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
```
|
86
|
+
|
87
|
+
と使われている事が分かる。
|
88
|
+
|
89
|
+
では$passableが何かという事で同ファイル内をpassable検索すると
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
```ここに言語を入力
|
94
|
+
|
95
|
+
58 public function send($passable)
|
96
|
+
|
97
|
+
59 {
|
98
|
+
|
99
|
+
60 $this->passable = $passable;
|
100
|
+
|
101
|
+
61
|
102
|
+
|
103
|
+
62 return $this;
|
104
|
+
|
105
|
+
63 }
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
```
|
110
|
+
|
111
|
+
が見つかり、sendで渡しているパラメーターだという事が分かる
|
112
|
+
|
113
|
+
そしてsendで渡しているものが何かというと、最初のファイルに戻って`$request`だという事が分かる
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
そしてこれが分かったところでLaravel使う上では全く何の役にも立たないのです。
|