Skip to content

Commit

Permalink
Merge 4.x into 5.x
Browse files Browse the repository at this point in the history
  • Loading branch information
SonataCI committed Mar 1, 2023
2 parents a552170 + 7f42bfd commit 012e2af
Show file tree
Hide file tree
Showing 37 changed files with 279 additions and 303 deletions.
157 changes: 0 additions & 157 deletions UPGRADE-3.x.md

This file was deleted.

13 changes: 7 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
"homepage": "https://docs.sonata-project.org/projects/SonataDoctrineORMAdminBundle",
"require": {
"php": "^7.4 || ^8.0",
"doctrine/dbal": "^2.13 || ^3.0",
"doctrine/doctrine-bundle": "^2.4",
"doctrine/orm": "^2.8",
"doctrine/persistence": "^2.1 || ^3.0",
"doctrine/dbal": "^3.4",
"doctrine/doctrine-bundle": "^2.7",
"doctrine/orm": "^2.14",
"doctrine/persistence": "^3.0.2",
"sonata-project/admin-bundle": "^4.18",
"sonata-project/exporter": "^2.0 || ^3.0",
"sonata-project/form-extensions": "^1.4",
Expand All @@ -50,14 +50,15 @@
"dama/doctrine-test-bundle": "^6.7",
"doctrine/doctrine-fixtures-bundle": "^3.4",
"friendsofphp/php-cs-fixer": "^3.4",
"matthiasnoback/symfony-dependency-injection-test": "^4.2",
"phpstan/extension-installer": "^1.0",
"phpstan/phpstan": "^1.0",
"phpstan/phpstan-phpunit": "^1.0",
"phpstan/phpstan-strict-rules": "^1.0",
"phpstan/phpstan-symfony": "^1.0",
"phpunit/phpunit": "^9.5",
"psalm/plugin-phpunit": "^0.18",
"psalm/plugin-symfony": "^4.0",
"psalm/plugin-symfony": "^4.0 || ^5.0",
"rector/rector": "^0.15",
"sonata-project/block-bundle": "^4.2",
"sonata-project/entity-audit-bundle": "^1.1",
Expand All @@ -67,7 +68,7 @@
"symfony/phpunit-bridge": "^6.1",
"symfony/templating": "^4.4 || ^5.4 || ^6.0",
"symfony/yaml": "^4.4 || ^5.4 || ^6.0",
"vimeo/psalm": "^4.1.1",
"vimeo/psalm": "^4.1.1 || ^5.7",
"weirdan/doctrine-psalm-plugin": "^2.0"
},
"conflict": {
Expand Down
6 changes: 0 additions & 6 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="3.16@d03e5ef057d6adc656c0ff7e166c50b73b4f48f3">
<file src="src/Model/ModelManager.php">
<!-- https://github.com/vimeo/psalm/issues/5643 -->
<TypeDoesNotContainType occurrences="1">
<code>[] === $idx</code>
</TypeDoesNotContainType>
</file>
<!-- https://github.com/vimeo/psalm/issues/7995 -->
<file src="src/Datagrid/ProxyQuery.php">
<MoreSpecificReturnType occurrences="1">
Expand Down
2 changes: 1 addition & 1 deletion psalm.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<psalm xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="https://getpsalm.org/schema/config" errorLevel="2" findUnusedPsalmSuppress="true" resolveFromConfigFile="true" xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd" errorBaseline="psalm-baseline.xml">
<psalm xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="https://getpsalm.org/schema/config" errorLevel="2" findUnusedPsalmSuppress="true" resolveFromConfigFile="true" xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd" errorBaseline="psalm-baseline.xml" findUnusedBaselineEntry="true" findUnusedCode="false">
<projectFiles>
<directory name="src"/>
<directory name="tests"/>
Expand Down
42 changes: 24 additions & 18 deletions src/DependencyInjection/Compiler/AddGuesserCompilerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,30 +27,36 @@ final class AddGuesserCompilerPass implements CompilerPassInterface
public function process(ContainerBuilder $container): void
{
// ListBuilder
$definition = $container->getDefinition('sonata.admin.guesser.orm_list_chain');
$services = [];
foreach ($container->findTaggedServiceIds('sonata.admin.guesser.orm_list') as $id => $attributes) {
$services[] = new Reference($id);
if ($container->hasDefinition('sonata.admin.guesser.orm_list_chain')) {
$definition = $container->getDefinition('sonata.admin.guesser.orm_list_chain');
$services = [];
foreach ($container->findTaggedServiceIds('sonata.admin.guesser.orm_list') as $id => $attributes) {
$services[] = new Reference($id);
}

$definition->replaceArgument(0, $services);
}

$definition->replaceArgument(0, $services);

// DatagridBuilder
$definition = $container->getDefinition('sonata.admin.guesser.orm_datagrid_chain');
$services = [];
foreach ($container->findTaggedServiceIds('sonata.admin.guesser.orm_datagrid') as $id => $attributes) {
$services[] = new Reference($id);
if ($container->hasDefinition('sonata.admin.guesser.orm_datagrid_chain')) {
$definition = $container->getDefinition('sonata.admin.guesser.orm_datagrid_chain');
$services = [];
foreach ($container->findTaggedServiceIds('sonata.admin.guesser.orm_datagrid') as $id => $attributes) {
$services[] = new Reference($id);
}

$definition->replaceArgument(0, $services);
}

$definition->replaceArgument(0, $services);

// ShowBuilder
$definition = $container->getDefinition('sonata.admin.guesser.orm_show_chain');
$services = [];
foreach ($container->findTaggedServiceIds('sonata.admin.guesser.orm_show') as $id => $attributes) {
$services[] = new Reference($id);
if ($container->hasDefinition('sonata.admin.guesser.orm_show_chain')) {
$definition = $container->getDefinition('sonata.admin.guesser.orm_show_chain');
$services = [];
foreach ($container->findTaggedServiceIds('sonata.admin.guesser.orm_show') as $id => $attributes) {
$services[] = new Reference($id);
}

$definition->replaceArgument(0, $services);
}

$definition->replaceArgument(0, $services);
}
}
2 changes: 1 addition & 1 deletion src/FieldDescription/FieldDescriptionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ private function getMetadata(string $class): ClassMetadata
/**
* @param class-string $class
*
* @throw \UnexpectedValueException
* @throws \UnexpectedValueException
*/
private function getEntityManager(string $class): EntityManagerInterface
{
Expand Down
11 changes: 10 additions & 1 deletion tests/App/AppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
use Symfony\Component\Security\Http\Attribute\IsGranted;
use Symfony\Component\Security\Http\Authentication\AuthenticatorManager;

final class AppKernel extends Kernel
Expand Down Expand Up @@ -91,12 +92,20 @@ protected function configureContainer(ContainerBuilder $container, LoaderInterfa

$loader->load(__DIR__.'/config/config.yml');

if (class_exists(AuthenticatorManager::class)) {
if (class_exists(IsGranted::class)) {
$loader->load(__DIR__.'/config/config_symfony_v6.yml');
} elseif (class_exists(AuthenticatorManager::class)) {
$loader->load(__DIR__.'/config/config_symfony_v5.yml');
} else {
$loader->load(__DIR__.'/config/config_symfony_v4.yml');
}

if (version_compare(\PHP_VERSION, '8.0.0', '>=')) {
$loader->load(__DIR__.'/config/config_php8.yml');
} else {
$loader->load(__DIR__.'/config/config_php7.yml');
}

if (class_exists(HttpCacheHandler::class)) {
$loader->load($this->getProjectDir().'/config/config_sonata_block_v4.yaml');
}
Expand Down
6 changes: 3 additions & 3 deletions tests/App/DataFixtures/BookFixtures.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@ final class BookFixtures extends Fixture implements DependentFixtureInterface

public function load(ObjectManager $manager): void
{
$author = $this->getReference(AuthorFixtures::AUTHOR);
$author = $this->getReference(AuthorFixtures::AUTHOR, Author::class);
\assert($author instanceof Author);
$category = $this->getReference(CategoryFixtures::CATEGORY);
$category = $this->getReference(CategoryFixtures::CATEGORY, Category::class);
\assert($category instanceof Category);

$book = new Book('book_id', 'Don Quixote', $author);
$book->addCategory($category);

$manager->persist($book);

$authorWithTwoBooks = $this->getReference(AuthorFixtures::AUTHOR_WITH_TWO_BOOKS);
$authorWithTwoBooks = $this->getReference(AuthorFixtures::AUTHOR_WITH_TWO_BOOKS, Author::class);
\assert($authorWithTwoBooks instanceof Author);

$book1 = new Book('book_1', 'Book 1', $authorWithTwoBooks);
Expand Down
8 changes: 4 additions & 4 deletions tests/App/DataFixtures/ItemFixtures.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ final class ItemFixtures extends Fixture implements DependentFixtureInterface
{
public function load(ObjectManager $manager): void
{
$command1 = $this->getReference(CommandFixtures::COMMAND_1);
$command1 = $this->getReference(CommandFixtures::COMMAND_1, Command::class);
\assert($command1 instanceof Command);
$command2 = $this->getReference(CommandFixtures::COMMAND_2);
$command2 = $this->getReference(CommandFixtures::COMMAND_2, Command::class);
\assert($command2 instanceof Command);
$product1 = $this->getReference(ProductFixtures::PRODUCT_1);
$product1 = $this->getReference(ProductFixtures::PRODUCT_1, Product::class);
\assert($product1 instanceof Product);
$product2 = $this->getReference(ProductFixtures::PRODUCT_2);
$product2 = $this->getReference(ProductFixtures::PRODUCT_2, Product::class);
\assert($product2 instanceof Product);

$item1 = new Item($command1, $product1);
Expand Down
3 changes: 3 additions & 0 deletions tests/App/Entity/Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,17 @@

namespace Sonata\DoctrineORMAdminBundle\Tests\App\Entity;

use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;

/** @ORM\Embeddable() */
#[ORM\Embeddable]
class Address
{
/**
* @ORM\Column(type="string")
*/
#[ORM\Column(type: Types::STRING)]
private string $street;

public function __construct(string $street = '')
Expand Down

0 comments on commit 012e2af

Please sign in to comment.