Skip to content

Commit

Permalink
Merge 3.x into master
Browse files Browse the repository at this point in the history
  • Loading branch information
SonataCI committed Nov 12, 2019
2 parents c4be527 + addab4b commit 4fc246a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 25 deletions.
10 changes: 5 additions & 5 deletions composer.json
Expand Up @@ -30,11 +30,11 @@
"doctrine/mongodb-odm-bundle": "^3.0 || ^4.0",
"sonata-project/admin-bundle": "^3.31",
"sonata-project/core-bundle": "^3.8",
"symfony/config": "^2.8 || ^3.2 || ^4.0",
"symfony/dependency-injection": "^2.8 || ^3.2 || ^4.0",
"symfony/doctrine-bridge": "^2.8 || ^3.2 || ^4.0",
"symfony/form": "^2.8 || ^3.2 || ^4.0",
"symfony/http-kernel": "^2.8 || ^3.2 || ^4.0",
"symfony/config": "^3.4 || ^4.2",
"symfony/dependency-injection": "^3.4 || ^4.2",
"symfony/doctrine-bridge": "^3.4 || ^4.2",
"symfony/form": "^3.4 || ^4.2",
"symfony/http-kernel": "^3.4 || ^4.2",
"twig/extensions": "^1.0",
"twig/twig": "^1.34 || ^2.0"
},
Expand Down
17 changes: 4 additions & 13 deletions src/Builder/FormContractor.php
Expand Up @@ -97,13 +97,7 @@ public function getDefaultOptions($type, FieldDescriptionInterface $fieldDescrip
$options = [];
$options['sonata_field_description'] = $fieldDescription;

// NEXT_MAJOR: Check only against FQCNs when dropping support for Symfony 2.8
if (\in_array($type, [
'sonata_type_model',
'sonata_type_model_list',
'sonata_type_model_hidden',
'sonata_type_model_autocomplete',
], true) || $this->checkFormClass($type, [
if ($this->checkFormClass($type, [
ModelType::class,
ModelTypeList::class,
ModelListType::class,
Expand All @@ -120,8 +114,7 @@ public function getDefaultOptions($type, FieldDescriptionInterface $fieldDescrip
$options['class'] = $fieldDescription->getTargetEntity();
$options['model_manager'] = $fieldDescription->getAdmin()->getModelManager();

// NEXT_MAJOR: Check only against FQCNs when dropping support for Symfony 2.8
if ('sonata_type_model_autocomplete' === $type || $this->checkFormClass($type, [ModelAutocompleteType::class])) {
if ($this->checkFormClass($type, [ModelAutocompleteType::class])) {
if (!$fieldDescription->getAssociationAdmin()) {
throw new \RuntimeException(sprintf(
'The current field `%s` is not linked to an admin.'
Expand All @@ -131,8 +124,7 @@ public function getDefaultOptions($type, FieldDescriptionInterface $fieldDescrip
));
}
}
// NEXT_MAJOR: Check only against FQCNs when dropping support for Symfony 2.8
} elseif ('sonata_type_admin' === $type || $this->checkFormClass($type, [AdminType::class])) {
} elseif ($this->checkFormClass($type, [AdminType::class])) {
if (!$fieldDescription->getAssociationAdmin()) {
throw new \RuntimeException(sprintf(
'The current field `%s` is not linked to an admin.'
Expand All @@ -156,8 +148,7 @@ public function getDefaultOptions($type, FieldDescriptionInterface $fieldDescrip

$options['data_class'] = $fieldDescription->getAssociationAdmin()->getClass();
$fieldDescription->setOption('edit', $fieldDescription->getOption('edit', 'admin'));
// NEXT_MAJOR: Check only against FQCNs when dropping support for Symfony 2.8
} elseif ('sonata_type_collection' === $type || $this->checkFormClass($type, [
} elseif ($this->checkFormClass($type, [
CollectionType::class,
DeprecatedCollectionType::class,
])) {
Expand Down
7 changes: 0 additions & 7 deletions tests/Builder/FormContractorTest.php
Expand Up @@ -74,23 +74,16 @@ public function testDefaultOptionsForSonataFormTypes(): void
$fieldDescription->method('getTargetEntity')->willReturn($modelClass);
$fieldDescription->method('getAssociationAdmin')->willReturn($admin);

// NEXT_MAJOR: Use only FQCNs when dropping support for Symfony 2.8
$modelTypes = [
'sonata_type_model',
'sonata_type_model_list',
'sonata_type_model_hidden',
'sonata_type_model_autocomplete',
ModelType::class,
ModelListType::class,
ModelHiddenType::class,
ModelAutocompleteType::class,
];
$adminTypes = [
'sonata_type_admin',
AdminType::class,
];
$collectionTypes = [
'sonata_type_collection',
DeprecatedCollectionType::class,
];

Expand Down

0 comments on commit 4fc246a

Please sign in to comment.