Skip to content

Commit

Permalink
Merge branch '3.x' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
jordisala1991 committed Jul 18, 2020
2 parents 43b306d + dbd9087 commit d002ef5
Show file tree
Hide file tree
Showing 28 changed files with 688 additions and 655 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,24 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [3.72.0](https://github.com/sonata-project/SonataAdminBundle/compare/3.71.1...3.72.0) - 2020-07-14
### Added
- [[#6040](https://github.com/sonata-project/SonataAdminBundle/pull/6040)] Added new `AdminExtractor` to extract translations from the Admin classes ([@franmomu](https://github.com/franmomu))

### Deprecated
- [[#6040](https://github.com/sonata-project/SonataAdminBundle/pull/6040)] `AdminExtractor` class for JMSTranslationBundle integration ([@franmomu](https://github.com/franmomu))

### Fixed
- [[#6195](https://github.com/sonata-project/SonataAdminBundle/pull/6195)] Fixed design of validation message error when using a inline table collection. ([@VincentLanglet](https://github.com/VincentLanglet))
- [[#6171](https://github.com/sonata-project/SonataAdminBundle/pull/6171)] EmbeddedAdmin now correctly set the parent object when creating a new instance. ([@VincentLanglet](https://github.com/VincentLanglet))
- [[#6171](https://github.com/sonata-project/SonataAdminBundle/pull/6171)] Error message is correctly displayed for CollectionType ([@VincentLanglet](https://github.com/VincentLanglet))
- [[#6193](https://github.com/sonata-project/SonataAdminBundle/pull/6193)] Fixed default `[]` value for every non-nullable array class properties ([@VincentLanglet](https://github.com/VincentLanglet))
- [[#5799](https://github.com/sonata-project/SonataAdminBundle/pull/5799)] Stop calling `mb_strlen()` on null in `RetrieveAutocompleteItemsAction` ([@mar20](https://github.com/mar20))
- [[#6183](https://github.com/sonata-project/SonataAdminBundle/pull/6183)] Fix form one-to-many tabs translations ([@EmmanuelVella](https://github.com/EmmanuelVella))

### Removed
- [[#6199](https://github.com/sonata-project/SonataAdminBundle/pull/6199)] Support for Symfony < 4.4 ([@wbloszyk](https://github.com/wbloszyk))

## [3.71.1](https://github.com/sonata-project/SonataAdminBundle/compare/3.71.0...3.71.1) - 2020-06-30
### Changed
- [[#6170](https://github.com/sonata-project/SonataAdminBundle/pull/6170)] Move
Expand Down
18 changes: 18 additions & 0 deletions UPGRADE-3.x.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
UPGRADE 3.x
===========

UPGRADE FROM 3.71 to 3.72
=========================

## Deprecated `SonataAdminBundle\Admin\AdminHelper::addNewInstance()`

Use
```
$instance = $fieldDescription->getAssociationAdmin()->getNewInstance();
SonataAdminBundle\Manipulator\ObjectManipulator::setObject($instance, $object, $fieldDescription);
```
Instead of
```
$this->adminHelper->addNewInstance($object, $fieldDescription);
```

The static method `setObject()` avoids the need to inject the admin helper dependency,
and adds more flexibility with the instance you're adding to the object.

UPGRADE FROM 3.68 to 3.69
=========================

Expand Down
50 changes: 25 additions & 25 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,30 +32,30 @@
"sonata-project/exporter": "^2.1",
"sonata-project/form-extensions": "^0.1.1 || ^1.4",
"sonata-project/twig-extensions": "^0.1.1 || ^1.3",
"symfony/asset": "^4.3",
"symfony/config": "^4.3",
"symfony/console": "^4.3",
"symfony/asset": "^4.4",
"symfony/config": "^4.4",
"symfony/console": "^4.4",
"symfony/dependency-injection": "^4.4.3",
"symfony/doctrine-bridge": "^4.3",
"symfony/event-dispatcher": "^4.3",
"symfony/doctrine-bridge": "^4.4",
"symfony/event-dispatcher": "^4.4",
"symfony/event-dispatcher-contracts": "^1.1 || ^2.0",
"symfony/expression-language": "^4.3",
"symfony/form": "^4.3",
"symfony/framework-bundle": "^4.3",
"symfony/http-foundation": "^4.3",
"symfony/http-kernel": "^4.3",
"symfony/options-resolver": "^4.3",
"symfony/property-access": "^4.3",
"symfony/routing": "^4.3",
"symfony/expression-language": "^4.4",
"symfony/form": "^4.4",
"symfony/framework-bundle": "^4.4",
"symfony/http-foundation": "^4.4",
"symfony/http-kernel": "^4.4",
"symfony/options-resolver": "^4.4",
"symfony/property-access": "^4.4",
"symfony/routing": "^4.4",
"symfony/security-acl": "^3.0",
"symfony/security-bundle": "^4.3",
"symfony/security-core": "^4.3",
"symfony/security-csrf": "^4.3",
"symfony/security-bundle": "^4.4",
"symfony/security-core": "^4.4",
"symfony/security-csrf": "^4.4",
"symfony/string": "^5.1",
"symfony/translation": "^4.3",
"symfony/twig-bridge": "^4.3",
"symfony/twig-bundle": "^4.3",
"symfony/validator": "^4.3",
"symfony/translation": "^4.4",
"symfony/twig-bridge": "^4.4",
"symfony/twig-bundle": "^4.4",
"symfony/validator": "^4.4",
"twig/string-extra": "^3.0",
"twig/twig": "^2.12.1"
},
Expand All @@ -73,12 +73,12 @@
"phpstan/phpstan": "^0.12.29",
"psr/event-dispatcher": "^1.0",
"sonata-project/intl-bundle": "^2.4",
"symfony/browser-kit": "^4.3",
"symfony/css-selector": "^4.3",
"symfony/filesystem": "^4.3",
"symfony/browser-kit": "^4.4",
"symfony/css-selector": "^4.4",
"symfony/filesystem": "^4.4",
"symfony/maker-bundle": "^1.17",
"symfony/phpunit-bridge": "^5.0",
"symfony/yaml": "^4.3"
"symfony/phpunit-bridge": "^5.1",
"symfony/yaml": "^4.4"
},
"suggest": {
"jms/translation-bundle": "Extract message keys from Admins",
Expand Down
109 changes: 0 additions & 109 deletions docs/cookbook/recipe_custom_view.rst

This file was deleted.

1 change: 0 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ The demo website can be found at http://demo.sonata-project.org.
cookbook/recipe_sortable_sonata_type_model
cookbook/recipe_delete_field_group
cookbook/recipe_data_mapper
cookbook/recipe_custom_view
cookbook/recipe_persisting_filters
cookbook/recipe_creating_an_admin_with_annotations
cookbook/recipe_workflow_integration
Expand Down
10 changes: 5 additions & 5 deletions docs/reference/advanced_configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -306,19 +306,19 @@ If you want to use the Tab Menu in a different way, you can replace the Menu Tem
Translations
^^^^^^^^^^^^

The translation parameters and domain can be customised by using the
``translation_domain`` and ``translation_parameters`` keys of the extra array
The label translation parameters and domain can be customised by using the
``label_translation_parameters`` and ``label_catalogue`` keys of the extra array
of data associated with the item, respectively::

$menuItem->setExtras([
'translation_parameters' => ['myparam' => 'myvalue'],
'translation_domain' => 'My domain',
'label_translation_parameters' => ['myparam' => 'myvalue'],
'label_catalogue' => 'My domain',
]);

You can also set the translation domain on the menu root, and children will
inherit it::

$menu->setExtra('translation_domain', 'My domain');
$menu->setExtra('label_catalogue', 'My domain');

Filter parameters
^^^^^^^^^^^^^^^^^
Expand Down
18 changes: 16 additions & 2 deletions src/Action/RetrieveAutocompleteItemsAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,14 @@ private function retrieveFilterFieldDescription(
throw new \RuntimeException(sprintf('The field "%s" does not exist.', $field));
}

if (null === $fieldDescription->getTargetModel()) {
// NEXT_MAJOR: Remove the check and use `getTargetModel`.
if (method_exists($fieldDescription, 'getTargetModel')) {
$targetModel = $fieldDescription->getTargetModel();
} else {
$targetModel = $fieldDescription->getTargetEntity();
}

if (null === $targetModel) {
throw new \RuntimeException(sprintf('No associated entity with field "%s".', $field));
}

Expand All @@ -212,7 +219,14 @@ private function retrieveFormFieldDescription(
throw new \RuntimeException(sprintf('The field "%s" does not exist.', $field));
}

if (null === $fieldDescription->getTargetModel()) {
// NEXT_MAJOR: Remove the check and use `getTargetModel`.
if (method_exists($fieldDescription, 'getTargetModel')) {
$targetModel = $fieldDescription->getTargetModel();
} else {
$targetModel = $fieldDescription->getTargetEntity();
}

if (null === $targetModel) {
throw new \RuntimeException(sprintf('No associated entity with field "%s".', $field));
}

Expand Down
10 changes: 9 additions & 1 deletion src/Action/SetObjectFieldValueAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

namespace Sonata\AdminBundle\Action;

use Sonata\AdminBundle\Admin\FieldDescriptionInterface;
use Sonata\AdminBundle\Admin\Pool;
use Sonata\AdminBundle\Twig\Extension\SonataAdminExtension;
use Symfony\Component\HttpFoundation\JsonResponse;
Expand Down Expand Up @@ -124,7 +125,8 @@ public function __invoke(Request $request): JsonResponse
if ('' !== $value
&& 'choice' === $fieldDescription->getType()
&& null !== $fieldDescription->getOption('class')
&& $fieldDescription->getOption('class') === $fieldDescription->getTargetModel()
// NEXT_MAJOR: Replace this call with "$fieldDescription->getOption('class') === $fieldDescription->getTargetModel()".
&& $this->hasFieldDescriptionAssociationWithClass($fieldDescription, $fieldDescription->getOption('class'))
) {
$value = $admin->getModelManager()->find($fieldDescription->getOption('class'), $value);

Expand Down Expand Up @@ -162,4 +164,10 @@ public function __invoke(Request $request): JsonResponse

return new JsonResponse($content, Response::HTTP_OK);
}

private function hasFieldDescriptionAssociationWithClass(FieldDescriptionInterface $fieldDescription, string $class): bool
{
return (method_exists($fieldDescription, 'getTargetModel') && $class === $fieldDescription->getTargetModel())
|| $class === $fieldDescription->getTargetEntity();
}
}
Loading

0 comments on commit d002ef5

Please sign in to comment.