Skip to content

Commit

Permalink
refactor #15427 [PostgreSQL] Sylius installation fix amend (Rafikooo)
Browse files Browse the repository at this point in the history
This PR was merged into the 1.13 branch.

Discussion
----------

| Q               | A                                                            |
|-----------------|--------------------------------------------------------------|
| Branch?         | 1.13 <!-- see the comment below -->                  |
| Bug fix?        | no                                                      |
| New feature?    | no                                                      |
| BC breaks?      | no                                                      |
| Deprecations?   | no<!-- don't forget to update the UPGRADE-*.md file --> |
| License         | MIT                                                          |

Follow up to: #15425

Commits
-------

9a4c74b [CoreBundle] Refactor the constructor of the DatabaseSetupCommandsProvider class
  • Loading branch information
GSadee committed Oct 12, 2023
2 parents 32c61b0 + 9a4c74b commit 1c8fdab
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,21 @@ final class DatabaseSetupCommandsProvider implements DatabaseSetupCommandsProvid
/** @var AbstractSchemaManager<PostgreSQLPlatform|MySQLPlatform>|null */
private ?AbstractSchemaManager $schemaManager = null;

public function __construct(
private Registry $doctrineRegistry,
private ?EntityManagerInterface $entityManager = null,
) {
if (null === $this->entityManager) {
public function __construct(private Registry|EntityManagerInterface $entityManager)
{
if ($this->entityManager instanceof Registry) {
trigger_deprecation(
'sylius/sylius',
'1.13',
'Not passing an $entityManager to "%s" is deprecated and will be prohibited in Sylius 2.0.',
'Passing a $registry to the "%s" constructor is deprecated and will be prohibited in Sylius 2.0. Pass an instance of "%s" instead.',
self::class,
EntityManagerInterface::class,
);

$this->entityManager = $this->getEntityManager();
$objectManager = $this->entityManager->getManager();
Assert::isInstanceOf($objectManager, EntityManagerInterface::class);

$this->entityManager = $objectManager;
}
}

Expand Down Expand Up @@ -119,12 +122,4 @@ private function createSchemaManager(): AbstractSchemaManager

return $this->schemaManager;
}

private function getEntityManager(): EntityManagerInterface
{
$objectManager = $this->doctrineRegistry->getManager();
Assert::isInstanceOf($objectManager, EntityManagerInterface::class);

return $objectManager;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
</service>

<service id="sylius.commands_provider.database_setup" class="Sylius\Bundle\CoreBundle\Installer\Provider\DatabaseSetupCommandsProvider">
<argument type="service" id="doctrine" />
<argument type="service" id="doctrine.orm.entity_manager" />
</service>
<service id="Sylius\Bundle\CoreBundle\Installer\Provider\DatabaseSetupCommandsProviderInterface" alias="sylius.commands_provider.database_setup" />
Expand Down

0 comments on commit 1c8fdab

Please sign in to comment.