Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit10b9db2

Browse files
[TwigBundle] Give some love to exception pages
1 parente4e6380 commit10b9db2

File tree

4 files changed

+27
-7
lines changed

4 files changed

+27
-7
lines changed

‎src/Symfony/Bridge/Twig/Extension/CodeExtension.php‎

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public function getFilters()
5151
new \Twig_SimpleFilter('file_excerpt',array($this,'fileExcerpt'),array('is_safe' =>array('html'))),
5252
new \Twig_SimpleFilter('format_file',array($this,'formatFile'),array('is_safe' =>array('html'))),
5353
new \Twig_SimpleFilter('format_file_from_text',array($this,'formatFileFromText'),array('is_safe' =>array('html'))),
54+
new \Twig_SimpleFilter('format_log_message',array($this,'formatLogMessage'),array('is_safe' =>array('html'))),
5455
new \Twig_SimpleFilter('file_link',array($this,'getFileLink')),
5556
);
5657
}
@@ -151,7 +152,7 @@ public function fileExcerpt($file, $line, $srcContext = 3)
151152
}
152153

153154
for ($i =max($line -$srcContext,1),$max =min($line +$srcContext,count($content));$i <=$max; ++$i) {
154-
$lines[] ='<li'.($i ==$line ?'' :'').'><divpl-s1">$i.'"></div><code>'.self::fixCodeMarkup($content[$i -1]).'</code></li>';
155+
$lines[] ='<li'.($i ==$line ?'' :'').'><spanpl-s1">$i.'"></span><code>'.self::fixCodeMarkup($content[$i -1]).'</code></li>';
155156
}
156157

157158
return'<ol start="'.max($line -$srcContext,1).'">'.implode("\n",$lines).'</ol>';
@@ -183,9 +184,7 @@ public function formatFile($file, $line, $text = null)
183184
$text ="$text at line$line";
184185

185186
if (false !==$link =$this->getFileLink($file,$line)) {
186-
$flags =ENT_COMPAT |ENT_SUBSTITUTE;
187-
188-
returnsprintf('<a href="%s" title="Click to open this file" class="file_link">%s</a>',htmlspecialchars($link,$flags,$this->charset),$text);
187+
returnsprintf('<a href="%s" title="Click to open this file" class="file_link">%s</a>',htmlspecialchars($link,ENT_COMPAT |ENT_SUBSTITUTE,$this->charset),$text);
189188
}
190189

191190
return$text;
@@ -215,6 +214,27 @@ public function formatFileFromText($text)
215214
},$text);
216215
}
217216

217+
/**
218+
* @internal
219+
*/
220+
publicfunctionformatLogMessage($message,array$context)
221+
{
222+
if ($context &&false !==strpos($message,'{')) {
223+
$replacements =array();
224+
foreach ($contextas$key =>$val) {
225+
if (is_scalar($val)) {
226+
$replacements['{'.$key.'}'] =$val;
227+
}
228+
}
229+
230+
if ($replacements) {
231+
$message =strtr($message,$replacements);
232+
}
233+
}
234+
235+
returnhtmlspecialchars($message,ENT_COMPAT |ENT_SUBSTITUTE,$this->charset);
236+
}
237+
218238
/**
219239
* {@inheritdoc}
220240
*/
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<olclass="traces logs">
22
{%forloginlogs %}
33
<li{%iflog.priority>=400 %}class="error"{%elseiflog.priority>=300 %}class="warning"{%endif %}>
4-
{{log.priorityName }} - {{log.message }}
4+
{{log.priorityName }} - {{log.message|format_log_message(log.context) }}
55
</li>
66
{%endfor %}
77
</ol>

‎src/Symfony/Component/VarDumper/Caster/ClassStub.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function __construct($identifier, $callable = null)
6464

6565
if ($f =$r->getFileName()) {
6666
$this->attr['file'] =$f;
67-
$this->attr['line'] =$r->getStartLine() -substr_count($r->getDocComment(),"\n");
67+
$this->attr['line'] =$r->getStartLine();
6868
}
6969
}
7070

‎src/Symfony/Component/VarDumper/Tests/Caster/StubCasterTest.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public function testClassStub()
119119

120120
$expectedDump = <<<'EODUMP'
121121
<foo></foo><bar><span class=sf-dump-note>array:1</span> [<samp>
122-
<span class=sf-dump-index>0</span> => "<a href="%sFooInterface.php:8"><span class=sf-dump-str title="5 characters">hello</span></a>"
122+
<span class=sf-dump-index>0</span> => "<a href="%sFooInterface.php:10"><span class=sf-dump-str title="5 characters">hello</span></a>"
123123
</samp>]
124124
</bar>
125125
EODUMP;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp