8000 Merge branch '3.4' into 4.0 · symfony/symfony@767b028 · GitHub
[go: up one dir, main page]

Skip to content

Commit 767b028

Browse files
Merge branch '3.4' into 4.0
* 3.4: Use the PCRE_DOLLAR_ENDONLY modifier in route regexes [Form] Make sure errors are a part of the label on bootstrap 4 - this is a requirement for WCAG2 [Config] Only using filemtime to check file freshness
2 parents 12c1a01 + 5e094e8 commit 767b028

28 files changed

+307
-190
lines changed

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ col-sm-2
2828
{{- form_label(form) -}}
2929
<div class="{{ block('form_group_class') }}">
3030
{{- form_widget(form) -}}
31-
{{- form_errors(form) -}}
3231
</div>
3332
{##}</div>
3433
{%- endif -%}
@@ -40,7 +39,6 @@ col-sm-2
4039
{{- form_label(form) -}}
4140
<div class="{{ block('form_group_class') }}">
4241
{{- form_widget(form) -}}
43-
{{- form_errors(form) -}}
4442
</div>
4543
</div>
4644
{##}</fieldset>

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

Lines changed: 56 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,41 @@
3939
{% set attr = attr|merge({class: (attr.class|default('') ~ ' form-control is-invalid')|trim}) -%}
4040
{% set valid = true %}
4141
{%- endif -%}
42-
{{- parent() -}}
42+
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+
<div class="table-responsive">
49+
<table class="table {{ table_class|default('table-bordered table-condensed table-striped') }}">
50+
<thead>
51+
<tr>
52+
{%- if with_years %}<th>{{ form_label(form.years) }}</th>{% endif -%}
53+
{%- if with_months %}<th>{{ form_label(form.months) }}</th>{% endif -%}
54+
{%- if with_weeks %}<th>{{ form_label(form.weeks) }}</th>{% endif -%}
55+
{%- if with_days %}<th>{{ form_label(form.days) }}</th>{% endif -%}
56+
{%- if with_hours %}<th>{{ form_label(form.hours) }}</th>{% endif -%}
57+
{%- if with_minutes %}<th>{{ form_label(form.minutes) }}</th>{% endif -%}
58+
{%- if with_seconds %}<th>{{ form_label(form.seconds) }}</th>{% endif -%}
59+
</tr>
60+
</thead>
61+
<tbody>
62+
<tr>
63+
{%- if with_years %}<td>{{ form_widget(form.years) }}</td>{% endif -%}
64+
{%- if with_months %}<td>{{ form_widget(form.months) }}</td>{% endif -%}
65+
{%- if with_weeks %}<td>{{ form_widget(form.weeks) }}</td>{% endif -%}
66+
{%- if with_days %}<td>{{ form_widget(form.days) }}</td>{% endif -%}
67+
{%- if with_hours %}<td>{{ form_widget(form.hours) }}</td>{% endif -%}
68+
{%- if with_minutes %}<td>{{ form_widget(form.minutes) }}</td>{% endif -%}
69+
{%- if with_seconds %}<td>{{ form_widget(form.seconds) }}</td>{% endif -%}
70+
</tr>
71+
</tbody>
72+
</table>
73+
</div>
74+
{%- if with_invert %}{{ form_widget(form.invert) }}{% endif -%}
75+
</div>
76+
{%- endif -%}
4377
{%- endblock dateinterval_widget %}
4478

4579
{% block percent_widget -%}
@@ -125,13 +159,28 @@
125159
{# Labels #}
126160

127161
{% block form_label -%}
128-
{%- if compound is defined and compound -%}
129-
{%- set element = 'legend' -%}
130-
{%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' col-form-legend')|trim}) -%}
131-
{%- else -%}
132-
{%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' form-control-label')|trim}) -%}
162+
{% if label is not same as(false) -%}
163+
{%- if compound is defined and compound -%}
164+
{%- set element = 'legend' -%}
165+
{%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' col-form-legend')|trim}) -%}
166+
{%- else -%}
167+
{%- set label_attr = label_attr|merge({for: id, class: (label_attr.class|default('') ~ ' form-control-label')|trim}) -%}
168+
{%- endif -%}
169+
{% if required -%}
170+
{% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' required')|trim}) %}
171+
{%- endif -%}
172+
{% if label is empty -%}
173+
{%- if label_format is not empty -%}
174+
{% set label = label_format|replace({
175+
'%name%': name,
176+
'%id%': id,
177+
}) %}
178+
{%- else -%}
179+
{% set label = name|humanize %}
180+
{%- endif -%}
181+
{%- endif -%}
182+
<{{ element|default('label') }}{% if label_attr %}{% with { attr: label_attr } %}{{ block('attributes') }}{% endwith %}{% endif %}>{{ translation_domain is same as(false) ? label : label|trans({}, translation_domain) }}{% block form_label_errors %}{{- form_errors(form) -}}{% endblock form_label_errors %}</{{ element|default('label') }}>
133183
{%- endif -%}
134-
{{- parent() -}}
135184
{%- endblock form_label %}
136185

137186
{% block checkbox_radio_label -%}
@@ -169,7 +218,6 @@
169218
<{{ element|default('div') }} class="form-group">
170219
{{- form_label(form) -}}
171220
{{- form_widget(form) -}}
172-
{{- form_errors(form) -}}
173221
</{{ element|default('div') }}>
174222
{%- endblock form_row %}
175223

src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/ObjectsProvider.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Symfony\Component\DependencyInjection\Reference;
2020
use Symfony\Component\EventDispatcher\EventDispatcher;
2121
use Symfony\Component\Routing\Route;
22+
use Symfony\Component\Routing\CompiledRoute;
2223
use Symfony\Component\Routing\RouteCollection;
2324

2425
class ObjectsProvider
@@ -36,7 +37,7 @@ public static function getRouteCollections()
3637
public static function getRoutes()
3738
{
3839
return array(
39-
'route_1' => new Route(
40+
'route_1' => new RouteStub(
4041
'/hello/{name}',
4142
array('name' => 'Joseph'),
4243
array('name' => '[a-z]+'),
@@ -45,7 +46,7 @@ public static function getRoutes()
4546
array('http', 'https'),
4647
array('get', 'head')
4748
),
48-
'route_2' => new Route(
49+
'route_2' => new RouteStub(
4950
'/name/add',
5051
array(),
5152
array(),
@@ -187,3 +188,11 @@ public static function staticMethod()
187188
{
188189
}
189190
}
191+
192+
class RouteStub extends Route
193+
{
194+
public function compile()
195+
{
196+
return new CompiledRoute('', '#PATH_REGEX#', array(), array(), '#HOST_REGEX#');
197+
}
198+
}

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_1.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"path": "\/hello\/{name}",
3-
"pathRegex": "#^\/hello(?:\/(?P<name>[a-z]+))?$#s",
3+
"pathRegex": "#PATH_REGEX#",
44
"host": "localhost",
5-
"hostRegex": "#^localhost$#si",
5+
"hostRegex": "#HOST_REGEX#",
66
"scheme": "http|https",
77
"method": "GET|HEAD",
8-
"class": "Symfony\\Component\\Routing\\Route",
8+
"class": "Symfony\\Bundle\\FrameworkBundle\\Tests\\Console\\Descriptor\\RouteStub",
99
"defaults": {
1010
"name": "Joseph"
1111
},

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_1.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
- Path: /hello/{name}
2-
- Path Regex: #^/hello(?:/(?P<name>[a-z]+))?$#s
2+
- Path Regex: #PATH_REGEX#
33
- Host: localhost
4-
- Host Regex: #^localhost$#si
4+
- Host Regex: #HOST_REGEX#
55
- Scheme: http|https
66
- Method: GET|HEAD
7-
- Class: Symfony\Component\Routing\Route
7+
- Class: Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\RouteStub
88
- Defaults:
99
- `name`: Joseph
1010
- Requirements:
Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
+--------------+---------------------------------------------------------+
2-
| Property | Value |
3-
+--------------+---------------------------------------------------------+
4-
| Route Name | |
5-
| Path | /hello/{name} |
6-
| Path Regex | #^/hello(?:/(?P<name>[a-z]+))?$#s |
7-
| Host | localhost |
8-
| Host Regex | #^localhost$#si |
9-
| Scheme | http|https |
10-
| Method | GET|HEAD |
11-
| Requirements | name: [a-z]+ |
12-
| Class | Symfony\Component\Routing\Route |
13-
| Defaults | name: Joseph |
14-
| Options | compiler_class: Symfony\Component\Routing\RouteCompiler |
15-
| | opt1: val1 |
16-
| | opt2: val2 |
17-
+--------------+---------------------------------------------------------+
1+
+--------------+-------------------------------------------------------------------+
2+
| Property | Value |
3+
+--------------+-------------------------------------------------------------------+
4+
| Route Name | |
5+
| Path | /hello/{name} |
6+
| Path Regex | #PATH_REGEX# |
7+
| Host | localhost |
8+
| Host Regex | #HOST_REGEX# |
9+
| Scheme | http|https |
10+
| Method | GET|HEAD |
11+
| Requirements | name: [a-z]+ |
12+
| Class | Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\RouteStub |
13+
| Defaults | name: Joseph |
14+
| Options | compiler_class: Symfony\Component\Routing\RouteCompiler |
15+
| | opt1: val1 |
16+
| | opt2: val2 |
17+
+--------------+-------------------------------------------------------------------+

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_1.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<route class="Symfony\Component\Routing\Route">
3-
<path regex="#^/hello(?:/(?P&lt;name&gt;[a-z]+))?$#s">/hello/{name}</path>
4-
<host regex="#^localhost$#si">localhost</host>
2+
<route class="Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\RouteStub">
3+
<path regex="#PATH_REGEX#">/hello/{name}</path>
4+
<host regex="#HOST_REGEX#">localhost</host>
55
<scheme>http</scheme>
66
<scheme>https</scheme>
77
<method>GET</method>

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_2.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"path": "\/name\/add",
3-
"pathRegex": "#^\/name\/add$#s",
3+
"pathRegex": "#PATH_REGEX#",
44
"host": "localhost",
5-
"hostRegex": "#^localhost$#si",
5+
"hostRegex": "#HOST_REGEX#",
66
"scheme": "http|https",
77
"method": "PUT|POST",
8-
"class": "Symfony\\Component\\Routing\\Route",
8+
"class": "Symfony\\Bundle\\FrameworkBundle\\Tests\\Console\\Descriptor\\RouteStub",
99
"defaults": [],
1010
"requirements": "NO CUSTOM",
1111
"options": {

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_2.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
- Path: /name/add
2-
- Path Regex: #^/name/add$#s
2+
- Path Regex: #PATH_REGEX#
33
- Host: localhost
4-
- Host Regex: #^localhost$#si
4+
- Host Regex: #HOST_REGEX#
55
- Scheme: http|https
66
- Method: PUT|POST
7-
- Class: Symfony\Component\Routing\Route
7+
- Class: Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\RouteStub
88
- Defaults: NONE
99
- Requirements: NO CUSTOM
1010
- Options:
Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
+--------------+---------------------------------------------------------+
2-
| Property | Value |
3-
+--------------+---------------------------------------------------------+
4-
| Route Name | |
5-
| Path | /name/add |
6-
| Path Regex | #^/name/add$#s |
7-
| Host | localhost |
8-
| Host Regex | #^localhost$#si |
9-
| Scheme | http|https |
10-
| Method | PUT|POST |
11-
| Requirements | NO CUSTOM |
12-
| Class | Symfony\Component\Routing\Route |
13-
| Defaults | NONE |
14-
| Options | compiler_class: Symfony\Component\Routing\RouteCompiler |
15-
| | opt1: val1 |
16-
| | opt2: val2 |
17-
+--------------+---------------------------------------------------------+
1+
+--------------+-------------------------------------------------------------------+
2+
| Property | Value |
3+
+--------------+-------------------------------------------------------------------+
4+
| Route Name | |
5+
| Path | /name/add |
6+
| Path Regex | #PATH_REGEX# |
7+
| Host | localhost |
8+
| Host Regex | #HOST_REGEX# |
9+
| Scheme | http|https |
10+
| Method | PUT|POST |
11+
| Requirements | NO CUSTOM |
12+
| Class | Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\RouteStub |
13+
| Defaults | NONE |
14+
| Options | compiler_class: Symfony\Component\Routing\RouteCompiler |
15+
| | opt1: val1 |
16+
| | opt2: val2 |
17+
+--------------+-------------------------------------------------------------------+

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_2.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<route class="Symfony\Component\Routing\Route">
3-
<path regex="#^/name/add$#s">/name/add</path>
4-
<host regex="#^localhost$#si">localhost</host>
2+
<route class="Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\RouteStub">
3+
<path regex="#PATH_REGEX#">/name/add</path>
4+
<host regex="#HOST_REGEX#">localhost</host>
55
<scheme>http</scheme>
66
<scheme>https</scheme>
77
<method>PUT</method>

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_1.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"route_1": {
33
"path": "\/hello\/{name}",
4-
"pathRegex": "#^\/hello(?:\/(?P<name>[a-z]+))?$#s",
4+
"pathRegex": "#PATH_REGEX#",
55
"host": "localhost",
6-
"hostRegex": "#^localhost$#si",
6+
"hostRegex": "#HOST_REGEX#",
77
"scheme": "http|https",
88
"method": "GET|HEAD",
9-
"class": "Symfony\\Component\\Routing\\Route",
9+
"class": "Symfony\\Bundle\\FrameworkBundle\\Tests\\Console\\Descriptor\\RouteStub",
1010
"defaults": {
1111
"name": "Joseph"
1212
},
@@ -21,12 +21,12 @@
2121
},
2222
"route_2": {
2323
"path": "\/name\/add",
24-
"pathRegex": "#^\/name\/add$#s",
24+
"pathRegex": "#PATH_REGEX#",
2525
"host": "localhost",
26-
"hostRegex": "#^localhost$#si",
26+
"hostRegex": "#HOST_REGEX#",
2727
"scheme": "http|https",
2828
"method": "PUT|POST",
29-
"class": "Symfony\\Component\\Routing\\Route",
29+
"class": "Symfony\\Bundle\\FrameworkBundle\\Tests\\Console\\Descriptor\\RouteStub",
3030
"defaults": [],
3131
"requirements": "NO CUSTOM",
3232
"options": {

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_1.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ route_1
22
-------
33

44
- Path: /hello/{name}
5-
- Path Regex: #^/hello(?:/(?P<name>[a-z]+))?$#s
5+
- Path Regex: #PATH_REGEX#
66
- Host: localhost
7-
- Host Regex: #^localhost$#si
7+
- Host Regex: #HOST_REGEX#
88
- Scheme: http|https
99
- Method: GET|HEAD
10-
- Class: Symfony\Component\Routing\Route
10+
- Class: Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\RouteStub
1111
- Defaults:
1212
- `name`: Joseph
1313
- Requirements:
@@ -22,12 +22,12 @@ route_2
2222
-------
2323

2424
- Path: /name/add
25-
- Path Regex: #^/name/add$#s
25+
- Path Regex: #PATH_REGEX#
2626
- Host: localhost
27-
- Host Regex: #^localhost$#si
27+
- Host Regex: #HOST_REGEX#
2828
- Scheme: http|https
2929
- Method: PUT|POST
30-
- Class: Symfony\Component\Routing\Route
30+
- Class: Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\RouteStub
3131
- Defaults: NONE
3232
- Requirements: NO CUSTOM
3333
- Options:

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_1.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<routes>
3-
<route name="route_1" class="Symfony\Component\Routing\Route">
4-
<path regex="#^/hello(?:/(?P&lt;name&gt;[a-z]+))?$#s">/hello/{name}</path>
5-
<host regex="#^localhost$#si">localhost</host>
3+
<route name="route_1" class="Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\RouteStub">
4+
<path regex="#PATH_REGEX#">/hello/{name}</path>
5+
<host regex="#HOST_REGEX#">localhost</host>
66
<scheme>http</scheme>
77
<scheme>https</scheme>
88
<method>GET</method>
@@ -19,9 +19,9 @@
1919
<option key="opt2">val2</option>
2020
</options>
2121
</route>
22-
<route name="route_2" class="Symfony\Component\Routing\Route">
23-
<path regex="#^/name/add$#s">/name/add</path>
24-
<host regex="#^localhost$#si">localhost</host>
22+
<route name="route_2" class="Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\RouteStub">
23+
<path regex="#PATH_REGEX#">/name/add</path>
24+
<host regex="#HOST_REGEX#">localhost</host>
2525
<scheme>http</scheme>
2626
<scheme>https</scheme>
2727
<method>PUT</method>

src/Symfony/Component/Config/Resource/FileResource.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function getResource()
6060
*/
6161
public function isFresh($timestamp)
6262
{
63-
return file_exists($this->resource) && @filemtime($this->resource) <= $timestamp;
63+
return false !== ($filemtime = @filemtime($this->resource)) && $filemtime <= $timestamp;
6464
}
6565

6666
public function serialize()

0 commit comments

Comments
 (0)
0