Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6e95c2a

Browse files
Merge branch '4.0'
* 4.0: (24 commits) moved Twig runtime to proper class fixed deprecated messages in tests add PHP errors options to XML schema definition [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 Import InvalidArgumentException in PdoAdapter [DI] Do not suggest writing an implementation when multiple exist [Intl] Update ICU data to 61.1 Use 3rd person verb form in command description [Validator] Add Japanese translation Support phpdbg SAPI in Debug::enable() [HttpKernel] DumpDataCollector: do not flush when a dumper is provided [DI] Fix hardcoded cache dir for warmups [Routing] fix tests [Routing] Fixed the importing of files using glob patterns that match multiple resources [Ldap] cast to string when checking empty passwords [Validator] sync validator translation id [WebProfilerBundle] use the router to resolve file links no type errors with invalid submitted data types ...
2 parents b3fc3b5 + a5a4447 commit 6e95c2a

File tree

899 files changed

+4198
-1609
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

899 files changed

+4198
-1609
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ public function getFilters()
6464
{
6565
return array(
6666
new TwigFilter('humanize', array('Symfony\Component\Form\FormRenderer', 'humanize')),
67+
new TwigFilter('form_encode_currency', array('Symfony\Component\Form\FormRenderer', 'encodeCurrency'), array('is_safe' => array('html'), 'needs_environment' => true)),
6768
);
6869
}
6970

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

Lines 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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@
181181
{%- endblock integer_widget -%}
182182

183183
{%- block money_widget -%}
184-
{{ money_pattern|replace({ '{{ widget }}': block('form_widget_simple') })|raw }}
184+
{{ money_pattern|form_encode_currency(block('form_widget_simple')) }}
185185
{%- endblock money_widget -%}
186186

187187
{%- block url_widget -%}
@@ -350,7 +350,7 @@
350350
{%- else -%}
351351
{% set form_method = "POST" %}
352352
{%- endif -%}
353-
<form name="{{ name }}" method="{{ form_method|lower }}"{% if action != '' %} action="{{ action }}"{% endif %}{% for attrname, attrvalue in attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}{% if multipart %} enctype="multipart/form-data"{% endif %}>
353+
<form{% if name != '' %} name="{{ name }}"{% endif %} method="{{ form_method|lower }}"{% if action != '' %} action="{{ action }}"{% endif %}{% for attrname, attrvalue in attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}{% if multipart %} enctype="multipart/form-data"{% endif %}>
354354
{%- if form_method != method -%}
355355
<input type="hidden" name="_method" value="{{ method }}" />
356356
{%- endif -%}

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

Lines 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

Lines 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);

src/Symfony/Bundle/FrameworkBundle/Command/CachePoolPruneCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function __construct(iterable $pools)
4444
protected function configure()
4545
{
4646
$this
47-
->setDescription('Prune cache pools')
47+
->setDescription('Prunes cache pools')
4848
->setHelp(<<<'EOF'
4949
The <info>%command.name%</info> command deletes all expired items from all pruneable pools.
5050

src/Symfony/Bundle/FrameworkBundle/HttpCache/HttpCache.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
*
2424
* @author Fabien Potencier <[email protected]>
2525
*/
26-
class HttpCache extends BaseHttpCache
26+
abstract class HttpCache extends BaseHttpCache
2727
{
2828
protected $cacheDir;
2929
protected $kernel;

src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
<xsd:element name="property-info" type="property_info" minOccurs="0" maxOccurs="1" />
3030
<xsd:element name="cache" type="cache" minOccurs="0" maxOccurs="1" />
3131
<xsd:element name="workflow" type="workflow" minOccurs="0" maxOccurs="unbounded" />
32+
<xsd:element name="php-errors" type="php-errors" minOccurs="0" maxOccurs="1" />
3233
<xsd:element name="lock" type="lock" minOccurs="0" maxOccurs="1" />
3334
<xsd:element name="messenger" type="messenger" minOccurs="0" maxOccurs="1" />
3435
</xsd:choice>
@@ -285,6 +286,11 @@
285286
<xsd:attribute name="enabled" type="xsd:boolean" />
286287
</xsd:complexType>
287288

289+
<xsd:complexType name="php-errors">
290+
<xsd:attribute name="log" type="xsd:boolean" />
291+
<xsd:attribute name="throw" type="xsd:boolean" />
292+
</xsd:complexType>
293+
288294
<xsd:complexType name="marking_store">
289295
<xsd:sequence>
290296
<xsd:element name="argument" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
Lines 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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,4 +252,20 @@ public function humanize($text)
252252
{
253253
return $this->renderer->humanize($text);
254254
}
255+
256+
/**
257+
* @internal
258+
*/
259+
public function formEncodeCurrency($text, $widget = '')
260+
{
261+
if ('UTF-8' === $charset = $this->getCharset()) {
262+
$text = htmlspecialchars($text, ENT_QUOTES | (\defined('ENT_SUBSTITUTE') ? ENT_SUBSTITUTE : 0), 'UTF-8');
263+
} else {
264+
$text = htmlentities($text, ENT_QUOTES | (\defined('ENT_SUBSTITUTE') ? ENT_SUBSTITUTE : 0), 'UTF-8');
265+
$text = iconv('UTF-8', $charset, $text);
266+
$widget = iconv('UTF-8', $charset, $widget);
267+
}
268+
269+
return str_replace('{{ widget }}', $widget, $text);
270+
}
255271
}

0 commit comments

Comments
 (0)