Merge branch '4.4' into 5.2
* 4.4: [DoctrineBridge] fix setting default mapping type to attribute/annotation on php 8/7 respectively do not render the same label id attribute twice
This commit is contained in:
commit
17b0187fab
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace Symfony\Bridge\Doctrine\DependencyInjection;
|
namespace Symfony\Bridge\Doctrine\DependencyInjection;
|
||||||
|
|
||||||
|
use Symfony\Component\Config\Resource\GlobResource;
|
||||||
use Symfony\Component\DependencyInjection\Alias;
|
use Symfony\Component\DependencyInjection\Alias;
|
||||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
use Symfony\Component\DependencyInjection\Definition;
|
use Symfony\Component\DependencyInjection\Definition;
|
||||||
@ -88,6 +89,25 @@ abstract class AbstractDoctrineExtension extends Extension
|
|||||||
if (!$mappingConfig) {
|
if (!$mappingConfig) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
} elseif (!$mappingConfig['type'] && \PHP_VERSION_ID < 80000) {
|
||||||
|
$mappingConfig['type'] = 'annotation';
|
||||||
|
} elseif (!$mappingConfig['type']) {
|
||||||
|
$mappingConfig['type'] = 'attribute';
|
||||||
|
|
||||||
|
$glob = new GlobResource($mappingConfig['dir'], '*', true);
|
||||||
|
$container->addResource($glob);
|
||||||
|
|
||||||
|
foreach ($glob as $file) {
|
||||||
|
$content = file_get_contents($file);
|
||||||
|
|
||||||
|
if (preg_match('/^#\[.*Entity\b/m', $content)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (preg_match('/^ \* @.*Entity\b/m', $content)) {
|
||||||
|
$mappingConfig['type'] = 'annotation';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->assertValidMappingConfiguration($mappingConfig, $objectManager['name']);
|
$this->assertValidMappingConfiguration($mappingConfig, $objectManager['name']);
|
||||||
|
@ -125,7 +125,7 @@
|
|||||||
{% if app is defined and app.request is defined %}{%- set input_lang = app.request.locale -%}{%- endif -%}
|
{% if app is defined and app.request is defined %}{%- set input_lang = app.request.locale -%}{%- endif -%}
|
||||||
{%- set attr = {lang: input_lang} | merge(attr) -%}
|
{%- set attr = {lang: input_lang} | merge(attr) -%}
|
||||||
{{- block('form_widget_simple') -}}
|
{{- block('form_widget_simple') -}}
|
||||||
{%- set label_attr = label_attr|merge({ class: (label_attr.class|default('') ~ ' custom-file-label')|trim }) -%}
|
{%- set label_attr = label_attr|merge({ class: (label_attr.class|default('') ~ ' custom-file-label')|trim })|filter((value, key) => key != 'id') -%}
|
||||||
<label for="{{ form.vars.id }}" {% with { attr: label_attr } %}{{ block('attributes') }}{% endwith %}>
|
<label for="{{ form.vars.id }}" {% with { attr: label_attr } %}{{ block('attributes') }}{% endwith %}>
|
||||||
{%- if attr.placeholder is defined and attr.placeholder is not none -%}
|
{%- if attr.placeholder is defined and attr.placeholder is not none -%}
|
||||||
{{- translation_domain is same as(false) ? attr.placeholder : attr.placeholder|trans({}, translation_domain) -}}
|
{{- translation_domain is same as(false) ? attr.placeholder : attr.placeholder|trans({}, translation_domain) -}}
|
||||||
|
@ -1121,6 +1121,24 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testFileLabelIdNotDuplicated()
|
||||||
|
{
|
||||||
|
$form = $this->factory->createNamed('name', FileType::class);
|
||||||
|
|
||||||
|
$this->assertWidgetMatchesXpath($form->createView(), ['id' => 'n/a', 'attr' => ['class' => 'my&class form-control-file'], 'label_attr' => ['id' => 'label-id']],
|
||||||
|
'/div
|
||||||
|
[@class="custom-file"]
|
||||||
|
[
|
||||||
|
./input
|
||||||
|
[@type="file"]
|
||||||
|
[@name="name"]
|
||||||
|
/following-sibling::label
|
||||||
|
[@for="name"][not(@id)]
|
||||||
|
]
|
||||||
|
'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public function testFileWithPlaceholder()
|
public function testFileWithPlaceholder()
|
||||||
{
|
{
|
||||||
$form = $this->factory->createNamed('name', FileType::class);
|
$form = $this->factory->createNamed('name', FileType::class);
|
||||||
|
Reference in New Issue
Block a user