Skip to content

Commit 18ba2a8

Browse files
committed
Merge branch '4.1'
* 4.1: fixed typo [FrameworkBundle] fixed brackets position in method calls Add placeholder support in bootstrap 4 file fields [Form] Improve rendering of `file` field in bootstrap 4 [Form] Fix PHPDoc for FormConfigBuilder $dataClass argument [Security] Update user phpdoc on tokens [WebProfilerBundle] Fixed icon alignment issue using Bootstrap 4.1.2 suppress side effects in 'get' or 'has' methods of NamespacedAttributeBag [HttpFoundation] reset callback on StreamedResponse when setNotModified() is called [HttpFoundation] Fixed phpdoc for get method of HeaderBag fix typo in ContainerBuilder docblock [Form/Profiler] Massively reducing memory footprint of form profiling pages by removing redundant 'form' variable from view variables. [Console] correctly return parameter's default value on "--" [DependencyInjection] add missing test for symfony#27710 [EventDispatcher] Clear orphaned events on TraceableEventDispatcher::reset Fix serialization of abstract items with groups across multiple entities
2 parents cc170eb + 6fd9d54 commit 18ba2a8

File tree

24 files changed

+220
-59
lines changed

24 files changed

+220
-59
lines changed

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

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,20 @@
114114
</div>
115115
{%- endblock percent_widget %}
116116

117+
{% block file_widget -%}
118+
<div class="form-group">
119+
<{{ element|default('div') }} class="custom-file">
120+
{%- set type = type|default('file') -%}
121+
{{- block('form_widget_simple') -}}
122+
<label for="{{ form.vars.id }}" class="custom-file-label">
123+
{%- if attr.placeholder is defined -%}
124+
{{- translation_domain is same as(false) ? attr.placeholder : attr.placeholder|trans({}, translation_domain) -}}
125+
{%- endif -%}
126+
</label>
127+
</{{ element|default('div') }}>
128+
</div>
129+
{% endblock %}
130+
117131
{% block form_widget_simple -%}
118132
{% if type is not defined or type != 'hidden' %}
119133
{%- set attr = attr|merge({class: (attr.class|default('') ~ (type|default('') == 'file' ? ' custom-file-input' : ' form-control'))|trim}) -%}
@@ -186,8 +200,6 @@
186200
{%- if compound is defined and compound -%}
187201
{%- set element = 'legend' -%}
188202
{%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' col-form-label')|trim}) -%}
189-
{% elseif type is defined and type == 'file' %}
190-
{%- set label_attr = label_attr|merge({for: id, class: (label_attr.class|default('') ~ ' custom-file-label')|trim}) -%}
191203
{%- else -%}
192204
{%- set label_attr = label_attr|merge({for: id}) -%}
193205
{%- endif -%}
@@ -269,15 +281,6 @@
269281
</{{ element|default('div') }}>
270282
{%- endblock form_row %}
271283

272-
{% block file_row -%}
273-
<div class="form-group">
274-
<{{ element|default('div') }} class="custom-file">
275-
{{- form_widget(form) -}}
276-
{{- form_label(form) -}}
277-
</{{ element|default('div') }}>
278-
</div>
279-
{% endblock %}
280-
281284
{# Errors #}
282285

283286
{% block form_errors -%}

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ public function testWorkflows()
268268
$this->assertInstanceOf(Reference::class, $markingStoreRef);
269269
$this->assertEquals('workflow_service', (string) $markingStoreRef);
270270

271-
$this->assertTrue($container->hasDefinition('workflow.registry', 'Workflow registry is registered as a service'));
271+
$this->assertTrue($container->hasDefinition('workflow.registry'), 'Workflow registry is registered as a service');
272272
$registryDefinition = $container->getDefinition('workflow.registry');
273273
$this->assertGreaterThan(0, count($registryDefinition->getMethodCalls()));
274274
}
@@ -313,8 +313,8 @@ public function testWorkflowMultipleTransitionsWithSameName()
313313
{
314314
$container = $this->createContainerFromFile('workflow_with_multiple_transitions_with_same_name');
315315

316-
$this->assertTrue($container->hasDefinition('workflow.article', 'Workflow is registered as a service'));
317-
$this->assertTrue($container->hasDefinition('workflow.article.definition', 'Workflow definition is registered as a service'));
316+
$this->assertTrue($container->hasDefinition('workflow.article'), 'Workflow is registered as a service');
317+
$this->assertTrue($container->hasDefinition('workflow.article.definition'), 'Workflow definition is registered as a service');
318318

319319
$workflowDefinition = $container->getDefinition('workflow.article.definition');
320320

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ div.sf-toolbar .sf-toolbar-block a:hover {
292292
border-width: 0;
293293
position: relative;
294294
top: 8px;
295+
vertical-align: baseline;
295296
}
296297

297298
.sf-toolbar-block .sf-toolbar-icon img + span,

src/Symfony/Component/Console/Input/ArgvInput.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ public function getParameterOption($values, $default = false, $onlyParams = fals
301301
while (0 < count($tokens)) {
302302
$token = array_shift($tokens);
303303
if ($onlyParams && '--' === $token) {
304-
return false;
304+
return $default;
305305
}
306306

307307
foreach ($values as $value) {

src/Symfony/Component/Console/Input/ArrayInput.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public function getParameterOption($values, $default = false, $onlyParams = fals
8181

8282
foreach ($this->parameters as $k => $v) {
8383
if ($onlyParams && ('--' === $k || (is_int($k) && '--' === $v))) {
84-
return false;
84+
return $default;
8585
}
8686

8787
if (is_int($k)) {

src/Symfony/Component/Console/Tests/Input/ArgvInputTest.php

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -395,25 +395,26 @@ public function testToString()
395395
/**
396396
* @dataProvider provideGetParameterOptionValues
397397
*/
398-
public function testGetParameterOptionEqualSign($argv, $key, $onlyParams, $expected)
398+
public function testGetParameterOptionEqualSign($argv, $key, $default, $onlyParams, $expected)
399399
{
400400
$input = new ArgvInput($argv);
401-
$this->assertEquals($expected, $input->getParameterOption($key, false, $onlyParams), '->getParameterOption() returns the expected value');
401+
$this->assertEquals($expected, $input->getParameterOption($key, $default, $onlyParams), '->getParameterOption() returns the expected value');
402402
}
403403

404404
public function provideGetParameterOptionValues()
405405
{
406406
return array(
407-
array(array('app/console', 'foo:bar', '-e', 'dev'), '-e', false, 'dev'),
408-
array(array('app/console', 'foo:bar', '--env=dev'), '--env', false, 'dev'),
409-
array(array('app/console', 'foo:bar', '-e', 'dev'), array('-e', '--env'), false, 'dev'),
410-
array(array('app/console', 'foo:bar', '--env=dev'), array('-e', '--env'), false, 'dev'),
411-
array(array('app/console', 'foo:bar', '--env=dev', '--en=1'), array('--en'), false, '1'),
412-
array(array('app/console', 'foo:bar', '--env=dev', '', '--en=1'), array('--en'), false, '1'),
413-
array(array('app/console', 'foo:bar', '--env', 'val'), '--env', false, 'val'),
414-
array(array('app/console', 'foo:bar', '--env', 'val', '--dummy'), '--env', false, 'val'),
415-
array(array('app/console', 'foo:bar', '--', '--env=dev'), '--env', false, 'dev'),
416-
array(array('app/console', 'foo:bar', '--', '--env=dev'), '--env', true, false),
407+
array(array('app/console', 'foo:bar'), '-e', 'default', false, 'default'),
408+
array(array('app/console', 'foo:bar', '-e', 'dev'), '-e', 'default', false, 'dev'),
409+
array(array('app/console', 'foo:bar', '--env=dev'), '--env', 'default', false, 'dev'),
410+
array(array('app/console', 'foo:bar', '-e', 'dev'), array('-e', '--env'), 'default', false, 'dev'),
411+
array(array('app/console', 'foo:bar', '--env=dev'), array('-e', '--env'), 'default', false, 'dev'),
412+
array(array('app/console', 'foo:bar', '--env=dev', '--en=1'), array('--en'), 'default', false, '1'),
413+
array(array('app/console', 'foo:bar', '--env=dev', '', '--en=1'), array('--en'), 'default', false, '1'),
414+
array(array('app/console', 'foo:bar', '--env', 'val'), '--env', 'default', false, 'val'),
415+
array(array('app/console', 'foo:bar', '--env', 'val', '--dummy'), '--env', 'default', false, 'val'),
416+
array(array('app/console', 'foo:bar', '--', '--env=dev'), '--env', 'default', false, 'dev'),
417+
array(array('app/console', 'foo:bar', '--', '--env=dev'), '--env', 'default', true, 'default'),
417418
);
418419
}
419420

src/Symfony/Component/Console/Tests/Input/ArrayInputTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,14 @@ public function testGetParameterOption()
4747
{
4848
$input = new ArrayInput(array('name' => 'Fabien', '--foo' => 'bar'));
4949
$this->assertEquals('bar', $input->getParameterOption('--foo'), '->getParameterOption() returns the option of specified name');
50-
$this->assertFalse($input->getParameterOption('--bar'), '->getParameterOption() returns the default if an option is not present in the passed parameters');
50+
$this->assertEquals('default', $input->getParameterOption('--bar', 'default'), '->getParameterOption() returns the default value if an option is not present in the passed parameters');
5151

5252
$input = new ArrayInput(array('Fabien', '--foo' => 'bar'));
5353
$this->assertEquals('bar', $input->getParameterOption('--foo'), '->getParameterOption() returns the option of specified name');
5454

5555
$input = new ArrayInput(array('--foo', '--', '--bar' => 'woop'));
5656
$this->assertEquals('woop', $input->getParameterOption('--bar'), '->getParameterOption() returns the correct value if an option is present in the passed parameters');
57-
$this->assertFalse($input->getParameterOption('--bar', false, true), '->getParameterOption() returns false if an option is present in the passed parameters after an end of options signal');
57+
$this->assertEquals('default', $input->getParameterOption('--bar', 'default', true), '->getParameterOption() returns the default value if an option is present in the passed parameters after an end of options signal');
5858
}
5959

6060
public function testParseArguments()

src/Symfony/Component/DependencyInjection/ContainerBuilder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -608,10 +608,10 @@ private function doGet($id, $invalidBehavior = ContainerInterface::EXCEPTION_ON_
608608
* the parameters passed to the container constructor to have precedence
609609
* over the loaded ones.
610610
*
611-
* $container = new ContainerBuilder(array('foo' => 'bar'));
611+
* $container = new ContainerBuilder(new ParameterBag(array('foo' => 'bar')));
612612
* $loader = new LoaderXXX($container);
613613
* $loader->load('resource_name');
614-
* $container->register('foo', new stdClass());
614+
* $container->register('foo', 'stdClass');
615615
*
616616
* In the above example, even if the loaded resource defines a foo
617617
* parameter, the value will still be 'bar' as defined in the ContainerBuilder

src/Symfony/Component/DependencyInjection/Tests/Compiler/ValidateEnvPlaceholdersPassTest.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,18 @@ public function testConfigurationWithoutRootNode(): void
237237
$this->addToAssertionCount(1);
238238
}
239239

240+
public function testEmptyConfigFromMoreThanOneSource()
241+
{
242+
$container = new ContainerBuilder();
243+
$container->registerExtension(new EnvExtension(new ConfigurationWithArrayNodeRequiringOneElement()));
244+
$container->loadFromExtension('env_extension', array());
245+
$container->loadFromExtension('env_extension', array());
246+
247+
$this->doProcess($container);
248+
249+
$this->addToAssertionCount(1);
250+
}
251+
240252
public function testDiscardedEnvInConfig(): void
241253
{
242254
$container = new ContainerBuilder();
@@ -315,6 +327,24 @@ public function getConfigTreeBuilder()
315327
}
316328
}
317329

330+
class ConfigurationWithArrayNodeRequiringOneElement implements ConfigurationInterface
331+
{
332+
public function getConfigTreeBuilder()
333+
{
334+
$treeBuilder = new TreeBuilder();
335+
$treeBuilder->root('env_extension')
336+
->children()
337+
->arrayNode('nodes')
338+
->isRequired()
339+
->requiresAtLeastOneElement()
340+
->scalarPrototype()->end()
341+
->end()
342+
->end();
343+
344+
return $treeBuilder;
345+
}
346+
}
347+
318348
class EnvExtension extends Extension
319349
{
320350
private $configuration;
@@ -337,6 +367,10 @@ public function getConfiguration(array $config, ContainerBuilder $container)
337367

338368
public function load(array $configs, ContainerBuilder $container)
339369
{
370+
if (!array_filter($configs)) {
371+
return;
372+
}
373+
340374
try {
341375
$this->config = $this->processConfiguration($this->getConfiguration($configs, $container), $configs);
342376
} catch (TreeWithoutRootNodeException $e) {

src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ public function getOrphanedEvents(): array
217217
public function reset()
218218
{
219219
$this->called = array();
220+
$this->orphanedEvents = array();
220221
}
221222

222223
/**

0 commit comments

Comments
 (0)