Skip to content

Commit 39d08bb

Browse files
committed
orm 3.x
1 parent 6e55b75 commit 39d08bb

File tree

16 files changed

+27
-297
lines changed

16 files changed

+27
-297
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,17 @@ and the possiblity to install only the needed vendors make the difference to the
4343

4444
## Suggested
4545

46-
* [doctrine/dbal][20]: ^3.9.3
46+
* [doctrine/dbal][20]: ^4.2.1
4747
* [doctrine/mongodb-odm][21]: ^2.9.0
48-
* [doctrine/orm][22]: ^2.20
48+
* [doctrine/orm][22]: ^3.3
4949
* [mongodb/mongodb][23]: ^1.20
5050

5151
## Installation
5252

5353
Through [Composer](http://getcomposer.org) as [chubbyphp/chubbyphp-laminas-config-doctrine][1].
5454

5555
```sh
56-
composer require chubbyphp/chubbyphp-laminas-config-doctrine "^2.3"
56+
composer require chubbyphp/chubbyphp-laminas-config-doctrine "^3.0"
5757
```
5858

5959
## Usage

composer.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"php": "^8.2",
2626
"chubbyphp/chubbyphp-laminas-config-factory": "^1.3",
2727
"doctrine/common": "^3.4.5",
28-
"doctrine/event-manager": "^1.2|^2.0.1",
28+
"doctrine/event-manager": "^2.0.1",
2929
"psr/container": "^1.1.2|^2.0.2",
3030
"symfony/cache": "^5.4.46|^6.4.14|^7.2",
3131
"symfony/console": "^5.4.46|^6.4.14|^7.2"
@@ -34,9 +34,9 @@
3434
"chubbyphp/chubbyphp-dev-helper": "dev-master",
3535
"chubbyphp/chubbyphp-laminas-config": "^1.4",
3636
"chubbyphp/chubbyphp-mock": "^1.8",
37-
"doctrine/dbal": "^3.9.3",
37+
"doctrine/dbal": "^4.2.1",
3838
"doctrine/mongodb-odm": "^2.9.0",
39-
"doctrine/orm": "^2.20",
39+
"doctrine/orm": "^3.3",
4040
"infection/infection": "^0.29.8",
4141
"mongodb/mongodb": "^1.20",
4242
"php-coveralls/php-coveralls": "^2.7",
@@ -46,9 +46,9 @@
4646
"ramsey/uuid": "^4.7.6"
4747
},
4848
"conflict": {
49-
"doctrine/dbal": "<3.9.3 || >=4.0",
49+
"doctrine/dbal": "<4.2.1 || >=5.0",
5050
"doctrine/mongodb-odm": "<2.9.0 || >=3.0",
51-
"doctrine/orm": "<2.20 || >=3.0",
51+
"doctrine/orm": "<3.3 || >=4.0",
5252
"mongodb/mongodb": "<1.20|| >=2.0"
5353
},
5454
"autoload": {
@@ -70,7 +70,7 @@
7070
},
7171
"extra": {
7272
"branch-alias": {
73-
"dev-master": "2.3-dev"
73+
"dev-master": "3.0-dev"
7474
}
7575
},
7676
"scripts": {

src/ServiceFactory/DBAL/ConnectionFactory.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44

55
namespace Chubbyphp\Laminas\Config\Doctrine\ServiceFactory\DBAL;
66

7-
use Chubbyphp\Laminas\Config\Doctrine\ServiceFactory\Common\EventManagerFactory;
87
use Chubbyphp\Laminas\Config\Factory\AbstractFactory;
9-
use Doctrine\Common\EventManager;
108
use Doctrine\DBAL\Configuration;
119
use Doctrine\DBAL\Connection;
1210
use Doctrine\DBAL\DriverManager;
@@ -19,13 +17,9 @@ public function __invoke(ContainerInterface $container): Connection
1917
/** @var Configuration $configuration */
2018
$configuration = $this->resolveDependency($container, Configuration::class, ConfigurationFactory::class);
2119

22-
/** @var EventManager $eventManager */
23-
$eventManager = $this->resolveDependency($container, EventManager::class, EventManagerFactory::class);
24-
2520
return DriverManager::getConnection(
2621
$this->resolveConfig($container->get('config')['doctrine']['dbal']['connection'] ?? []),
27-
$configuration,
28-
$eventManager
22+
$configuration
2923
);
3024
}
3125
}

src/ServiceFactory/DBAL/Tools/Console/Command/ReservedWordsCommandFactory.php

Lines changed: 0 additions & 22 deletions
This file was deleted.

src/ServiceFactory/ORM/ConfigurationFactory.php

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,44 +14,24 @@ public function __invoke(ContainerInterface $container): Configuration
1414
{
1515
$config = $this->resolveConfig($container->get('config')['doctrine']['orm']['configuration'] ?? []);
1616

17-
/** @var array<string, mixed> $namedQueries */
18-
$namedQueries = $this->resolveValue($container, $config['namedQueries'] ?? []);
19-
20-
/** @var array<string, mixed> $namedNativeQueries */
21-
$namedNativeQueries = $this->resolveValue($container, $config['namedNativeQueries'] ?? []);
22-
2317
/** @var array<string, mixed> $filters */
2418
$filters = $this->resolveValue($container, $config['filters'] ?? []);
2519

26-
unset($config['namedQueries'], $config['namedNativeQueries'], $config['filters']);
20+
unset($config['filters']);
2721

2822
$configuration = new Configuration();
2923

30-
$this->callAdders($configuration, $namedQueries, $namedNativeQueries, $filters);
24+
$this->callAdders($configuration, $filters);
3125
$this->callSetters($container, $configuration, $config);
3226

3327
return $configuration;
3428
}
3529

3630
/**
37-
* @param array<string, mixed> $namedQueries
38-
* @param array<string, mixed> $namedNativeQueries
3931
* @param array<string, mixed> $filters
4032
*/
41-
private function callAdders(Configuration $configuration, array $namedQueries, array $namedNativeQueries, array $filters): void
33+
private function callAdders(Configuration $configuration, array $filters): void
4234
{
43-
foreach ($namedQueries as $namedQuery) {
44-
$configuration->addNamedQuery($namedQuery['name'], $namedQuery['dql']);
45-
}
46-
47-
foreach ($namedNativeQueries as $namedNativeQuery) {
48-
$configuration->addNamedNativeQuery(
49-
$namedNativeQuery['name'],
50-
$namedNativeQuery['sql'],
51-
$namedNativeQuery['rsm']
52-
);
53-
}
54-
5535
foreach ($filters as $filter) {
5636
$configuration->addFilter($filter['name'], $filter['className']);
5737
}

src/ServiceFactory/ORM/EntityManagerFactory.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44

55
namespace Chubbyphp\Laminas\Config\Doctrine\ServiceFactory\ORM;
66

7+
use Chubbyphp\Laminas\Config\Doctrine\ServiceFactory\Common\EventManagerFactory;
78
use Chubbyphp\Laminas\Config\Doctrine\ServiceFactory\DBAL\ConnectionFactory;
89
use Chubbyphp\Laminas\Config\Factory\AbstractFactory;
10+
use Doctrine\Common\EventManager;
911
use Doctrine\DBAL\Connection;
1012
use Doctrine\ORM\Configuration;
1113
use Doctrine\ORM\EntityManager;
@@ -21,6 +23,9 @@ public function __invoke(ContainerInterface $container): EntityManager
2123
/** @var Configuration $configuration */
2224
$configuration = $this->resolveDependency($container, Configuration::class, ConfigurationFactory::class);
2325

24-
return EntityManager::create($connection, $configuration);
26+
/** @var EventManager $eventManager */
27+
$eventManager = $this->resolveDependency($container, EventManager::class, EventManagerFactory::class);
28+
29+
return new EntityManager($connection, $configuration, $eventManager);
2530
}
2631
}

src/ServiceFactory/ORM/Tools/Console/Command/ConvertMappingCommandFactory.php

Lines changed: 0 additions & 22 deletions
This file was deleted.

src/ServiceFactory/ORM/Tools/Console/Command/EnsureProductionSettingsCommandFactory.php

Lines changed: 0 additions & 22 deletions
This file was deleted.

tests/Integration/EntityManagerTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,6 @@ public function test(): void
8282

8383
$container = $factory(new Config($config));
8484

85-
/** @var EntityManagerInterface $entityManager */
86-
$entityManager = $container->get(EntityManagerInterface::class);
87-
8885
/** @var ConnectionProvider $connectionProvider */
8986
$connectionProvider = $container->get(ConnectionProvider::class);
9087

@@ -102,6 +99,8 @@ public function test(): void
10299
$sample = new Sample();
103100
$sample->setName('name');
104101

102+
$entityManager = $entityManagerProvider->getDefaultManager();
103+
105104
$entityManager->persist($sample);
106105
$entityManager->flush();
107106

tests/Resources/Mapping/Orm/SampleMapping.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ final class SampleMapping implements ClassMapMappingInterface
1616
*/
1717
public function configureMapping(ClassMetadata $metadata): void
1818
{
19-
$metadata->setPrimaryTable(['name' => 'sample']);
20-
2119
$builder = new ClassMetadataBuilder($metadata);
2220
$builder->setTable('sample');
2321
$builder->createField('id', 'guid')->makePrimaryKey()->build();

0 commit comments

Comments
 (0)