Skip to content

Commit

Permalink
Merge branch '6.4' into 7.0
Browse files Browse the repository at this point in the history
* 6.4: (21 commits)
  [ErrorHandler] Add missing self-closing tags on link elements
  Fix merge (bis)
  Fix merge
  Add missing return type
  [FrameworkBundle] ConfigBuilderCacheWarmer should be non-optional
  [HttpClient] Fix pausing responses before they start when using curl
  [Notifier] Updated the NTFY notifier to run without a user parameter
  [Translation] Fix constant domain resolution in PhpAstExtractor
  separate child and parent context in NotificationEmail on writes
  [Mailer] [Mailgun] Fix sender header encoding
  do not overwrite the cache key when it is false
  [Mailer] [Scaleway] Fix attachment handling
  [Mailer] Throw TransportException when unable to read from socket
  [Serializer] Rewrite `AbstractObjectNormalizer::createChildContext()` to use the provided `cache_key` from original context when creating child contexts
  Revert #47715
  [HttpClient] Fix error chunk creation in passthru
  Adjusting and removing the 'review' attribute from the pt_br translation XML.
  [DependencyInjection] Fix loading all env vars from secrets when only a subset is needed
  Fix option filenameMaxLength to the File constraint (Image)
  [Serializer] Take unnamed variadic parameters into account when denormalizing
  ...
  • Loading branch information
nicolas-grekas committed Jan 29, 2024
2 parents e9a5d25 + c50354e commit c349f85
Show file tree
Hide file tree
Showing 13 changed files with 86 additions and 18 deletions.
20 changes: 20 additions & 0 deletions Mime/NotificationEmail.php
Expand Up @@ -174,6 +174,26 @@ public function getHtmlTemplate(): ?string
return '@email/'.$this->theme.'/notification/body.html.twig';
}

/**
* @return $this
*/
public function context(array $context): static
{
$parentContext = [];

foreach ($context as $key => $value) {
if (\array_key_exists($key, $this->context)) {
$this->context[$key] = $value;
} else {
$parentContext[$key] = $value;
}
}

parent::context($parentContext);

return $this;
}

public function getContext(): array
{
return array_merge($this->context, parent::getContext());
Expand Down
10 changes: 5 additions & 5 deletions Resources/views/Form/form_div_layout.html.twig
Expand Up @@ -14,7 +14,7 @@
{# Attribute "required" is not supported #}
{%- set required = false -%}
{%- endif -%}
<input type="{{ type }}" {{ block('widget_attributes') }}{% if value is not empty %} value="{{ value }}"{% endif %}>
<input type="{{ type }}" {{ block('widget_attributes') }} {% if value is not empty %}value="{{ value }}" {% endif %}/>
{%- endblock form_widget_simple -%}

{%- block form_widget_compound -%}
Expand Down Expand Up @@ -91,11 +91,11 @@
{%- endblock choice_widget_options -%}

{%- block checkbox_widget -%}
<input type="checkbox" {{ block('widget_attributes') }}{% if value is defined %} value="{{ value }}"{% endif %}{% if checked %} checked="checked"{% endif %}>
<input type="checkbox" {{ block('widget_attributes') }}{% if value is defined %} value="{{ value }}"{% endif %}{% if checked %} checked="checked"{% endif %} />
{%- endblock checkbox_widget -%}

{%- block radio_widget -%}
<input type="radio" {{ block('widget_attributes') }}{% if value is defined %} value="{{ value }}"{% endif %}{% if checked %} checked="checked"{% endif %}>
<input type="radio" {{ block('widget_attributes') }}{% if value is defined %} value="{{ value }}"{% endif %}{% if checked %} checked="checked"{% endif %} />
{%- endblock radio_widget -%}

{%- block datetime_widget -%}
Expand Down Expand Up @@ -402,7 +402,7 @@
{%- endif -%}
<form{% if name != '' %} name="{{ name }}"{% endif %} method="{{ form_method|lower }}"{% if action != '' %} action="{{ action }}"{% endif %}{{ block('attributes') }}{% if multipart %} enctype="multipart/form-data"{% endif %}>
{%- if form_method != method -%}
<input type="hidden" name="_method" value="{{ method }}">
<input type="hidden" name="_method" value="{{ method }}" />
{%- endif -%}
{%- endblock form_start -%}

Expand Down Expand Up @@ -440,7 +440,7 @@
{%- endif -%}

{%- if form_method != method -%}
<input type="hidden" name="_method" value="{{ method }}">
<input type="hidden" name="_method" value="{{ method }}" />
{%- endif -%}
{% endif -%}
{% endblock form_rest %}
Expand Down
2 changes: 0 additions & 2 deletions Test/FormLayoutTestCase.php
Expand Up @@ -52,8 +52,6 @@ protected function assertMatchesXpath($html, $expression, $count = 1): void
{
$dom = new \DOMDocument('UTF-8');

$html = preg_replace('/(<input [^>]+)(?<!\/)>/', '$1/>', $html);

try {
// Wrap in <root> node so we can load HTML with multiple tags at
// the top level
Expand Down
4 changes: 2 additions & 2 deletions Tests/Extension/AbstractBootstrap3LayoutTestCase.php
Expand Up @@ -2797,7 +2797,7 @@ public function testWidgetAttributes()
$html = $this->renderWidget($form->createView());

// compare plain HTML to check the whitespace
$this->assertSame('<input type="text" id="text" name="text" disabled="disabled" required="required" readonly="readonly" maxlength="10" pattern="\d+" class="foobar form-control" data-foo="bar" value="value">', $html);
$this->assertSame('<input type="text" id="text" name="text" disabled="disabled" required="required" readonly="readonly" maxlength="10" pattern="\d+" class="foobar form-control" data-foo="bar" value="value" />', $html);
}

public function testWidgetAttributeNameRepeatedIfTrue()
Expand All @@ -2809,7 +2809,7 @@ public function testWidgetAttributeNameRepeatedIfTrue()
$html = $this->renderWidget($form->createView());

// foo="foo"
$this->assertSame('<input type="text" id="text" name="text" required="required" foo="foo" class="form-control" value="value">', $html);
$this->assertSame('<input type="text" id="text" name="text" required="required" foo="foo" class="form-control" value="value" />', $html);
}

public function testButtonAttributes()
Expand Down
4 changes: 2 additions & 2 deletions Tests/Extension/AbstractLayoutTestCase.php
Expand Up @@ -2448,7 +2448,7 @@ public function testWidgetAttributes()
$html = $this->renderWidget($form->createView());

// compare plain HTML to check the whitespace
$this->assertSame('<input type="text" id="text" name="text" disabled="disabled" required="required" readonly="readonly" maxlength="10" pattern="\d+" class="foobar" data-foo="bar" value="value">', $html);
$this->assertSame('<input type="text" id="text" name="text" disabled="disabled" required="required" readonly="readonly" maxlength="10" pattern="\d+" class="foobar" data-foo="bar" value="value" />', $html);
}

public function testWidgetAttributeNameRepeatedIfTrue()
Expand All @@ -2460,7 +2460,7 @@ public function testWidgetAttributeNameRepeatedIfTrue()
$html = $this->renderWidget($form->createView());

// foo="foo"
$this->assertSame('<input type="text" id="text" name="text" required="required" foo="foo" value="value">', $html);
$this->assertSame('<input type="text" id="text" name="text" required="required" foo="foo" value="value" />', $html);
}

public function testWidgetAttributeHiddenIfFalse()
Expand Down
2 changes: 1 addition & 1 deletion Tests/Extension/Fixtures/templates/form/theme.html.twig
@@ -1,4 +1,4 @@
{% block form_widget_simple %}
{%- set type = type|default('text') -%}
<input type="{{ type }}" {{ block('widget_attributes') }} value="{{ value }}" rel="theme">
<input type="{{ type }}" {{ block('widget_attributes') }} value="{{ value }}" rel="theme" />
{%- endblock form_widget_simple %}
Expand Up @@ -2,5 +2,5 @@

{% block form_widget_simple %}
{%- set type = type|default('text') -%}
<input type="{{ type }}" {{ block('widget_attributes') }} value="{{ value }}" rel="theme">
<input type="{{ type }}" {{ block('widget_attributes') }} value="{{ value }}" rel="theme" />
{%- endblock form_widget_simple %}
Expand Up @@ -2,5 +2,5 @@

{% block form_widget_simple %}
{%- set type = type|default('text') -%}
<input type="{{ type }}" {{ block('widget_attributes') }} value="{{ value }}" rel="theme">
<input type="{{ type }}" {{ block('widget_attributes') }} value="{{ value }}" rel="theme" />
{%- endblock form_widget_simple %}
2 changes: 1 addition & 1 deletion Tests/Extension/FormExtensionBootstrap3LayoutTest.php
Expand Up @@ -71,7 +71,7 @@ public function testMoneyWidgetInIso()
$this->assertSame(<<<'HTML'
<div class="input-group">
<span class="input-group-addon">&euro; </span>
<input type="text" id="name" name="name" required="required" class="form-control"> </div>
<input type="text" id="name" name="name" required="required" class="form-control" /> </div>
HTML
, trim($this->renderWidget($view)));
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/Extension/FormExtensionBootstrap4LayoutTest.php
Expand Up @@ -76,7 +76,7 @@ public function testMoneyWidgetInIso()
$this->assertSame(<<<'HTML'
<div class="input-group "><div class="input-group-prepend">
<span class="input-group-text">&euro; </span>
</div><input type="text" id="name" name="name" required="required" class="form-control"></div>
</div><input type="text" id="name" name="name" required="required" class="form-control" /></div>
HTML
, trim($this->renderWidget($view)));
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/Extension/FormExtensionBootstrap5LayoutTest.php
Expand Up @@ -75,7 +75,7 @@ public function testMoneyWidgetInIso()
->createView();

self::assertSame(<<<'HTML'
<div class="input-group "><span class="input-group-text">&euro; </span><input type="text" id="name" name="name" required="required" class="form-control"></div>
<div class="input-group "><span class="input-group-text">&euro; </span><input type="text" id="name" name="name" required="required" class="form-control" /></div>
HTML
, trim($this->renderWidget($view)));
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/Extension/FormExtensionDivLayoutTest.php
Expand Up @@ -156,7 +156,7 @@ public function testMoneyWidgetInIso()
->createView()
;

$this->assertSame('&euro; <input type="text" id="name" name="name" required="required">', $this->renderWidget($view));
$this->assertSame('&euro; <input type="text" id="name" name="name" required="required" />', $this->renderWidget($view));
}

public function testHelpAttr()
Expand Down
50 changes: 50 additions & 0 deletions Tests/Mime/NotificationEmailTest.php
Expand Up @@ -128,4 +128,54 @@ public function testPublicMailSubject()
$headers = $email->getPreparedHeaders();
$this->assertSame('Foo', $headers->get('Subject')->getValue());
}

public function testContext()
{
$email = new NotificationEmail();
$email->context(['some' => 'context']);

$this->assertSame([
'importance' => NotificationEmail::IMPORTANCE_LOW,
'content' => '',
'exception' => false,
'action_text' => null,
'action_url' => null,
'markdown' => false,
'raw' => false,
'footer_text' => 'Notification email sent by Symfony',
'some' => 'context',
], $email->getContext());

$context = $email->getContext();
$context['foo'] = 'bar';
$email->context($context);

$this->assertSame([
'importance' => NotificationEmail::IMPORTANCE_LOW,
'content' => '',
'exception' => false,
'action_text' => null,
'action_url' => null,
'markdown' => false,
'raw' => false,
'footer_text' => 'Notification email sent by Symfony',
'some' => 'context',
'foo' => 'bar',
], $email->getContext());

$email->action('Action Text', 'Action URL');

$this->assertSame([
'importance' => NotificationEmail::IMPORTANCE_LOW,
'content' => '',
'exception' => false,
'action_text' => 'Action Text',
'action_url' => 'Action URL',
'markdown' => false,
'raw' => false,
'footer_text' => 'Notification email sent by Symfony',
'some' => 'context',
'foo' => 'bar',
], $email->getContext());
}
}

0 comments on commit c349f85

Please sign in to comment.