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

Appearance settings

Commit 62eebd7

Browse filesBrowse files
committed
Merge branch '2.8' into 3.4
* 2.8: fixed deprecated messages in tests [HttpCache] Unlink tmp file on error Added LB translation for #26327 (Errors sign for people that do not see colors) [TwigBridge] Fix rendering of currency by MoneyType [HttpKernel] DumpDataCollector: do not flush when a dumper is provided
2 parents c48af7c + 92322f1 commit 62eebd7
Copy full SHA for 62eebd7

File tree

Expand file treeCollapse file tree

13 files changed

+202
-4
lines changed
Filter options
Expand file treeCollapse file tree

13 files changed

+202
-4
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Extension/FormExtension.php
+17Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ public function getFilters()
9696
{
9797
return array(
9898
new TwigFilter('humanize', array('Symfony\Component\Form\FormRenderer', 'humanize')),
99+
new TwigFilter('form_encode_currency', array($this, 'encodeCurrency'), array('is_safe' => array('html'), 'needs_environment' => true)),
99100
);
100101
}
101102

@@ -166,6 +167,22 @@ public function __unset($name)
166167
unset($this->$name);
167168
}
168169

170+
/**
171+
* @internal
172+
*/
173+
public function encodeCurrency(Environment $environment, $text, $widget = '')
174+
{
175+
if ('UTF-8' === $charset = $environment->getCharset()) {
176+
$text = htmlspecialchars($text, ENT_QUOTES | (\defined('ENT_SUBSTITUTE') ? ENT_SUBSTITUTE : 0), 'UTF-8');
177+
} else {
178+
$text = htmlentities($text, ENT_QUOTES | (\defined('ENT_SUBSTITUTE') ? ENT_SUBSTITUTE : 0), 'UTF-8');
179+
$text = iconv('UTF-8', $charset, $text);
180+
$widget = iconv('UTF-8', $charset, $widget);
181+
}
182+
183+
return str_replace('{{ widget }}', $widget, $text);
184+
}
185+
169186
/**
170187
* {@inheritdoc}
171188
*/

‎src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_layout.html.twig

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_layout.html.twig
+77Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,83 @@
1414
{{- parent() -}}
1515
{%- endblock button_widget %}
1616

17+
{% block money_widget -%}
18+
{% set prepend = not (money_pattern starts with '{{') %}
19+
{% set append = not (money_pattern ends with '}}') %}
20+
{% if prepend or append %}
21+
<div class="input-group">
22+
{% if prepend %}
23+
<span class="input-group-addon">{{ money_pattern|form_encode_currency }}</span>
24+
{% endif %}
25+
{{- block('form_widget_simple') -}}
26+
{% if append %}
27+
<span class="input-group-addon">{{ money_pattern|form_encode_currency }}</span>
28+
{% endif %}
29+
</div>
30+
{% else %}
31+
{{- block('form_widget_simple') -}}
32+
{% endif %}
33+
{%- endblock money_widget %}
34+
35+
{% block percent_widget -%}
36+
<div class="input-group">
37+
{{- block('form_widget_simple') -}}
38+
<span class="input-group-addon">%</span>
39+
</div>
40+
{%- endblock percent_widget %}
41+
42+
{% block datetime_widget -%}
43+
{% if widget == 'single_text' %}
44+
{{- block('form_widget_simple') -}}
45+
{% else -%}
46+
{% set attr = attr|merge({class: (attr.class|default('') ~ ' form-inline')|trim}) -%}
47+
<div {{ block('widget_container_attributes') }}>
48+
{{- form_errors(form.date) -}}
49+
{{- form_errors(form.time) -}}
50+
{{- form_widget(form.date, { datetime: true } ) -}}
51+
{{- form_widget(form.time, { datetime: true } ) -}}
52+
</div>
53+
{%- endif %}
54+
{%- endblock datetime_widget %}
55+
56+
{% block date_widget -%}
57+
{% if widget == 'single_text' %}
58+
{{- block('form_widget_simple') -}}
59+
{% else -%}
60+
{% set attr = attr|merge({class: (attr.class|default('') ~ ' form-inline')|trim}) -%}
61+
{% if datetime is not defined or not datetime -%}
62+
<div {{ block('widget_container_attributes') -}}>
63+
{%- endif %}
64+
{{- date_pattern|replace({
65+
'{{ year }}': form_widget(form.year),
66+
'{{ month }}': form_widget(form.month),
67+
'{{ day }}': form_widget(form.day),
68+
})|raw -}}
69+
{% if datetime is not defined or not datetime -%}
70+
</div>
71+
{%- endif -%}
72+
{% endif %}
73+
{%- endblock date_widget %}
74+
75+
{% block time_widget -%}
76+
{% if widget == 'single_text' %}
77+
{{- block('form_widget_simple') -}}
78+
{% else -%}
79+
{% set attr = attr|merge({class: (attr.class|default('') ~ ' form-inline')|trim}) -%}
80+
{% if datetime is not defined or false == datetime -%}
81+
<div {{ block('widget_container_attributes') -}}>
82+
{%- endif -%}
83+
{{- form_widget(form.hour) }}{% if with_minutes %}:{{ form_widget(form.minute) }}{% endif %}{% if with_seconds %}:{{ form_widget(form.second) }}{% endif %}
84+
{% if datetime is not defined or false == datetime -%}
85+
</div>
86+
{%- endif -%}
87+
{% endif %}
88+
{%- endblock time_widget %}
89+
90+
{% block choice_widget_collapsed -%}
91+
{% set attr = attr|merge({class: (attr.class|default('') ~ ' form-control')|trim}) %}
92+
{%- endblock choice_widget_collapsed %}
93+
1794
{% block checkbox_widget -%}
1895
{%- set parent_label_class = parent_label_class|default(label_attr.class|default('')) -%}
1996
{% if 'checkbox-inline' in parent_label_class %}

‎src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@
177177
{%- endblock integer_widget -%}
178178

179179
{%- block money_widget -%}
180-
{{ money_pattern|replace({ '{{ widget }}': block('form_widget_simple') })|raw }}
180+
{{ money_pattern|form_encode_currency(block('form_widget_simple')) }}
181181
{%- endblock money_widget -%}
182182

183183
{%- block url_widget -%}

‎src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3LayoutTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3LayoutTest.php
+25Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,31 @@ public function testStartTagHasActionAttributeWhenActionIsZero()
7575
$this->assertSame('<form name="form" method="get" action="0">', $html);
7676
}
7777

78+
public function testMoneyWidgetInIso()
79+
{
80+
$environment = new Environment(new StubFilesystemLoader(array(
81+
__DIR__.'/../../Resources/views/Form',
82+
__DIR__.'/Fixtures/templates/form',
83+
)), array('strict_variables' => true));
84+
$environment->addExtension(new TranslationExtension(new StubTranslator()));
85+
$environment->addExtension($this->extension);
86+
$environment->setCharset('ISO-8859-1');
87+
88+
$this->extension->initRuntime($environment);
89+
90+
$view = $this->factory
91+
->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\MoneyType')
92+
->createView()
93+
;
94+
95+
$this->assertSame(<<<'HTML'
96+
<div class="input-group">
97+
<span class="input-group-addon">&euro; </span>
98+
<input type="text" id="name" name="name" required="required" class="form-control" /> </div>
99+
HTML
100+
, trim($this->renderWidget($view)));
101+
}
102+
78103
protected function renderForm(FormView $view, array $vars = array())
79104
{
80105
return (string) $this->renderer->renderBlock($view, 'form', $vars);

‎src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php
+20Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,26 @@ public function testIsRootForm($expected, FormView $formView)
165165
$this->assertSame($expected, \Symfony\Bridge\Twig\Extension\twig_is_root_form($formView));
166166
}
167167

168+
public function testMoneyWidgetInIso()
169+
{
170+
$environment = new Environment(new StubFilesystemLoader(array(
171+
__DIR__.'/../../Resources/views/Form',
172+
__DIR__.'/Fixtures/templates/form',
173+
)), array('strict_variables' => true));
174+
$environment->addExtension(new TranslationExtension(new StubTranslator()));
175+
$environment->addExtension($this->extension);
176+
$environment->setCharset('ISO-8859-1');
177+
178+
$this->extension->initRuntime($environment);
179+
180+
$view = $this->factory
181+
->createNamed('name', 'money')
182+
->createView()
183+
;
184+
185+
$this->assertSame('&euro; <input type="text" id="name" name="name" required="required" />', $this->renderWidget($view));
186+
}
187+
168188
protected function renderForm(FormView $view, array $vars = array())
169189
{
170190
return (string) $this->renderer->renderBlock($view, 'form', $vars);
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?php echo str_replace('{{ widget }}', $view['form']->block($form, 'form_widget_simple'), $money_pattern) ?>
1+
<?php echo $view['form']->formEncodeCurrency($money_pattern, $view['form']->block($form, 'form_widget_simple')) ?>

‎src/Symfony/Bundle/FrameworkBundle/Templating/Helper/FormHelper.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Templating/Helper/FormHelper.php
+16Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,4 +240,20 @@ public function humanize($text)
240240
{
241241
return $this->renderer->humanize($text);
242242
}
243+
244+
/**
245+
* @internal
246+
*/
247+
public function formEncodeCurrency($text, $widget = '')
248+
{
249+
if ('UTF-8' === $charset = $this->getCharset()) {
250+
$text = htmlspecialchars($text, ENT_QUOTES | (\defined('ENT_SUBSTITUTE') ? ENT_SUBSTITUTE : 0), 'UTF-8');
251+
} else {
252+
$text = htmlentities($text, ENT_QUOTES | (\defined('ENT_SUBSTITUTE') ? ENT_SUBSTITUTE : 0), 'UTF-8');
253+
$text = iconv('UTF-8', $charset, $text);
254+
$widget = iconv('UTF-8', $charset, $widget);
255+
}
256+
257+
return str_replace('{{ widget }}', $widget, $text);
258+
}
243259
}

‎src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/FormHelperDivLayoutTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/FormHelperDivLayoutTest.php
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,18 @@ public function testStartTagHasActionAttributeWhenActionIsZero()
8181
$this->assertSame('<form name="form" method="get" action="0">', $html);
8282
}
8383

84+
public function testMoneyWidgetInIso()
85+
{
86+
$this->engine->setCharset('ISO-8859-1');
87+
88+
$view = $this->factory
89+
->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\MoneyType')
90+
->createView()
91+
;
92+
93+
$this->assertSame('&euro; <input type="text" id="name" name="name" required="required" />', $this->renderWidget($view));
94+
}
95+
8496
protected function renderForm(FormView $view, array $vars = array())
8597
{
8698
return (string) $this->engine->get('form')->form($view, $vars);

‎src/Symfony/Component/Form/Extension/Core/Type/MoneyType.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Extension/Core/Type/MoneyType.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function getBlockPrefix()
7070
}
7171

7272
/**
73-
* Returns the pattern for this locale.
73+
* Returns the pattern for this locale in UTF-8.
7474
*
7575
* The pattern contains the placeholder "{{ widget }}" where the HTML tag should
7676
* be inserted

‎src/Symfony/Component/HttpKernel/DataCollector/DumpDataCollector.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/DataCollector/DumpDataCollector.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function dump(Data $data)
6767
if ($this->stopwatch) {
6868
$this->stopwatch->start('dump');
6969
}
70-
if ($this->isCollected) {
70+
if ($this->isCollected && !$this->dumper) {
7171
$this->isCollected = false;
7272
}
7373

‎src/Symfony/Component/HttpKernel/HttpCache/Store.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/HttpCache/Store.php
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,16 +387,22 @@ private function save($key, $data)
387387

388388
$tmpFile = tempnam(dirname($path), basename($path));
389389
if (false === $fp = @fopen($tmpFile, 'wb')) {
390+
@unlink($tmpFile);
391+
390392
return false;
391393
}
392394
@fwrite($fp, $data);
393395
@fclose($fp);
394396

395397
if ($data != file_get_contents($tmpFile)) {
398+
@unlink($tmpFile);
399+
396400
return false;
397401
}
398402

399403
if (false === @rename($tmpFile, $path)) {
404+
@unlink($tmpFile);
405+
400406
return false;
401407
}
402408
}

‎src/Symfony/Component/HttpKernel/Tests/DataCollector/DumpDataCollectorTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/Tests/DataCollector/DumpDataCollectorTest.php
+21Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Symfony\Component\HttpFoundation\Request;
1717
use Symfony\Component\HttpFoundation\Response;
1818
use Symfony\Component\VarDumper\Cloner\Data;
19+
use Symfony\Component\VarDumper\Dumper\CliDumper;
1920

2021
/**
2122
* @author Nicolas Grekas <p@tchwork.com>
@@ -112,4 +113,24 @@ public function testFlush()
112113
$collector->__destruct();
113114
$this->assertSame("DumpDataCollectorTest.php on line {$line}:\n456\n", ob_get_clean());
114115
}
116+
117+
public function testFlushNothingWhenDataDumperIsProvided()
118+
{
119+
$data = new Data(array(array(456)));
120+
$dumper = new CliDumper('php://output');
121+
$collector = new DumpDataCollector(null, null, null, null, $dumper);
122+
123+
ob_start();
124+
$collector->dump($data);
125+
$line = __LINE__ - 1;
126+
if (\PHP_VERSION_ID >= 50400) {
127+
$this->assertSame("DumpDataCollectorTest.php on line {$line}:\n456\n", ob_get_clean());
128+
} else {
129+
$this->assertSame("\"DumpDataCollectorTest.php on line {$line}:\"\n456\n", ob_get_clean());
130+
}
131+
132+
ob_start();
133+
$collector->__destruct();
134+
$this->assertEmpty(ob_get_clean());
135+
}
115136
}

‎src/Symfony/Component/Validator/Resources/translations/validators.lb.xlf

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Resources/translations/validators.lb.xlf
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,10 @@
314314
<source>This is not a valid Business Identifier Code (BIC).</source>
315315
<target>Dëst ass kee gëltege "Business Identifier Code" (BIC).</target>
316316
</trans-unit>
317+
<trans-unit id="82">
318+
<source>Error</source>
319+
<target>Feeler</target>
320+
</trans-unit>
317321
</body>
318322
</file>
319323
</xliff>

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.