質問編集履歴
3
RuntimeLoaderの詳細を追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -143,3 +143,21 @@
|
|
143
143
|
|
144
144
|
|
145
145
|
エラー発生時、そのプロパティ runtimeLoaders は1つオブジェクトが登録されていますが、``$loader->load($class)`` の結果は null になっているようでした。
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
RuntimeLoader の mapping には下の2つが登録されています。
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
```php
|
154
|
+
|
155
|
+
"Symfony\Bridge\Twig\Extension\HttpKernelRuntime" => "twig.runtime.httpkernel"
|
156
|
+
|
157
|
+
"Symfony\Bridge\Twig\Form\TwigRenderer" => "twig.form.renderer"
|
158
|
+
|
159
|
+
```
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
しかし、``getRuntime($class)`` での第1引数には ``Symfony\Component\Form\FormRenderer`` が入っており、mapping 内に存在しないためロードに失敗しています。本来なら``Symfony\Bridge\Twig\Form\TwigRenderer``が指定されていなければいけないように見えます。
|
2
getRuntime() メソッドに関する補足を追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -89,3 +89,57 @@
|
|
89
89
|
|
90
90
|
|
91
91
|
何が問題なのでしょうか?
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
---
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
【追記】
|
100
|
+
|
101
|
+
さらに根本を辿っていくと発生位置は Twig_Environment クラスの getRuntime() メソッドのようです。
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
```php
|
106
|
+
|
107
|
+
public function getRuntime($class)
|
108
|
+
|
109
|
+
{
|
110
|
+
|
111
|
+
// エラー時 $this->runtimes は空の配列でした
|
112
|
+
|
113
|
+
if (isset($this->runtimes[$class])) {
|
114
|
+
|
115
|
+
return $this->runtimes[$class];
|
116
|
+
|
117
|
+
}
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
// 通常はここで load() が成功しますが結果は null でした
|
122
|
+
|
123
|
+
// runtimeLoaders には1つの RuntimeLoader オブジェクトがセットされていました
|
124
|
+
|
125
|
+
foreach ($this->runtimeLoaders as $loader) {
|
126
|
+
|
127
|
+
if (null !== $runtime = $loader->load($class)) {
|
128
|
+
|
129
|
+
return $this->runtimes[$class] = $runtime;
|
130
|
+
|
131
|
+
}
|
132
|
+
|
133
|
+
}
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
throw new Twig_Error_Runtime(sprintf('Unable to load the "%s" runtime.', $class));
|
138
|
+
|
139
|
+
}
|
140
|
+
|
141
|
+
```
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
エラー発生時、そのプロパティ runtimeLoaders は1つオブジェクトが登録されていますが、``$loader->load($class)`` の結果は null になっているようでした。
|
1
$data が欠けていたので追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -46,6 +46,16 @@
|
|
46
46
|
|
47
47
|
|
48
48
|
|
49
|
+
$data = array(
|
50
|
+
|
51
|
+
'name' => 'Your name',
|
52
|
+
|
53
|
+
'email' => 'Your email',
|
54
|
+
|
55
|
+
);
|
56
|
+
|
57
|
+
|
58
|
+
|
49
59
|
$form = $app['form.factory']->createBuilder(FormType::class, $data)
|
50
60
|
|
51
61
|
->add('name')
|