Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/Doctrine/EntityClassGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

namespace Symfony\Bundle\MakerBundle\Doctrine;

use Doctrine\Common\Persistence\ManagerRegistry as LegacyManagerRegistry;
use Doctrine\Persistence\ManagerRegistry;
use Symfony\Bundle\MakerBundle\Generator;
use Symfony\Bundle\MakerBundle\Util\ClassNameDetails;

Expand Down Expand Up @@ -52,6 +54,7 @@ public function generateEntityClass(ClassNameDetails $entityClassDetails, bool $
'entity_class_name' => $entityClassDetails->getShortName(),
'entity_alias' => $entityAlias,
'with_password_upgrade' => $withPasswordUpgrade,
'doctrine_registry_class' => interface_exists(ManagerRegistry::class) ? ManagerRegistry::class : LegacyManagerRegistry::class,
]
);

Expand Down
3 changes: 3 additions & 0 deletions src/Doctrine/EntityRegenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@

namespace Symfony\Bundle\MakerBundle\Doctrine;

use Doctrine\Common\Persistence\ManagerRegistry as LegacyManagerRegistry;
use Doctrine\Common\Persistence\Mapping\MappingException as CommonMappingException;
use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\ORM\Mapping\MappingException;
use Doctrine\Persistence\ManagerRegistry;
use Symfony\Bundle\MakerBundle\Exception\RuntimeCommandException;
use Symfony\Bundle\MakerBundle\FileManager;
use Symfony\Bundle\MakerBundle\Generator;
Expand Down Expand Up @@ -235,6 +237,7 @@ private function generateRepository(ClassMetadata $metadata)
'entity_class_name' => $entityClassName,
'entity_alias' => strtolower($entityClassName[0]),
'with_password_upgrade' => false,
'doctrine_registry_class' => interface_exists(ManagerRegistry::class) ? ManagerRegistry::class : LegacyManagerRegistry::class,
]
);

Expand Down
6 changes: 5 additions & 1 deletion src/Maker/MakeFixtures.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
namespace Symfony\Bundle\MakerBundle\Maker;

use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Common\Persistence\ObjectManager as LegacyObjectManager;
use Doctrine\ORM\Mapping\Column;
use Doctrine\Persistence\ObjectManager;
use Symfony\Bundle\MakerBundle\ConsoleStyle;
use Symfony\Bundle\MakerBundle\DependencyBuilder;
use Symfony\Bundle\MakerBundle\Generator;
Expand Down Expand Up @@ -51,7 +53,9 @@ public function generate(InputInterface $input, ConsoleStyle $io, Generator $gen
$generator->generateClass(
$fixturesClassNameDetails->getFullName(),
'doctrine/Fixtures.tpl.php',
[]
[
'object_manager_class' => interface_exists(ObjectManager::class) ? ObjectManager::class : LegacyObjectManager::class,
]
);

$generator->writeChanges();
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/skeleton/doctrine/Fixtures.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace <?= $namespace; ?>;

use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Common\Persistence\ObjectManager;
use <?= $object_manager_class; ?>;

class <?= $class_name ?> extends Fixture
{
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/skeleton/doctrine/Repository.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use <?= $entity_full_class_name; ?>;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Common\Persistence\ManagerRegistry;
use <?= $doctrine_registry_class; ?>;
<?= $with_password_upgrade ? "use Symfony\Component\Security\Core\Exception\UnsupportedUserException;\n" : '' ?>
<?= $with_password_upgrade ? "use Symfony\Component\Security\Core\User\PasswordUpgraderInterface;\n" : '' ?>
<?= $with_password_upgrade ? "use Symfony\Component\Security\Core\User\UserInterface;\n" : '' ?>
Expand Down
2 changes: 1 addition & 1 deletion src/Util/YamlSourceManipulator.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ private function updateData(array $newData)
$this->arrayTypeForDepths[$this->depth] = $this->isHash($currentData) ? self::ARRAY_TYPE_HASH : self::ARRAY_TYPE_SEQUENCE;

$this->log(sprintf(
'Changing array type & format via updateData()',
'Changing array type & format via updateData() (type=%s, format=%s)',
$this->arrayTypeForDepths[$this->depth],
$this->arrayFormatForDepths[$this->depth]
));
Expand Down
11 changes: 11 additions & 0 deletions tests/Doctrine/EntityRegeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,17 @@ class EntityRegeneratorTest extends TestCase
*/
public function testRegenerateEntities(string $expectedDirName, bool $overwrite)
{
/*
* Prior to symfony/doctrine-bridge 5.0 (which require
* PHP 7.3), the deprecated Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain
* is used when our test container. This shows up as a *direct*
* deprecation. We're choosing to silence it here, instead of
* ignoring all direct deprecations.
*/
if (\PHP_VERSION_ID < 70300) {
$this->setGroups(['@legacy']);
}

$kernel = new TestEntityRegeneratorKernel('dev', true);
$this->doTestRegeneration(
__DIR__.'/fixtures/source_project',
Expand Down
8 changes: 4 additions & 4 deletions tests/Maker/MakeMessageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@ public function getTestDetails()
yield 'message_basic' => [MakerTestDetails::createTest(
$this->getMakerInstance(MakeMessage::class),
[
'SendWelcomeEmail'
'SendWelcomeEmail',
])
->setFixtureFilesPath(__DIR__.'/../fixtures/MakeMessageBasic')
// because there is no version compatible with 7.0
->setRequiredPhpVersion(70100)
->setRequiredPhpVersion(70100),
];

yield 'message_with_transport' => [
MakerTestDetails::createTest(
$this->getMakerInstance(MakeMessage::class),
[
'SendWelcomeEmail',
1
1,
]
)
->setFixtureFilesPath(__DIR__.'/../fixtures/MakeMessageWithTransport')
Expand All @@ -61,7 +61,7 @@ function (string $output, string $directory) {
$this->getMakerInstance(MakeMessage::class),
[
'SendWelcomeEmail',
0
0,
]
)
->setFixtureFilesPath(__DIR__.'/../fixtures/MakeMessageWithTransport')
Expand Down