Skip to content
This repository was archived by the owner on Nov 17, 2020. It is now read-only.

Commit 5737139

Browse files
committed
Use Doctrine persistence package
1 parent a08bda3 commit 5737139

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

AbstractFixture.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@
1515
use Doctrine\Common\DataFixtures\AbstractFixture as BaseAbstractFixture;
1616
use Doctrine\ORM\Id\AssignedGenerator;
1717
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
18-
use Doctrine\Common\Persistence\ObjectManager;
18+
use Doctrine\Persistence\ObjectManager;
1919
use Doctrine\Instantiator\Instantiator;
2020
use Doctrine\ORM\EntityManagerInterface;
2121
use Doctrine\ORM\EntityRepository;
2222
use ReflectionClass;
23+
use function count;
2324
use function method_exists;
2425
use RuntimeException;
2526
use function sprintf;
@@ -90,7 +91,7 @@ public function load(ObjectManager $manager)
9091

9192
$objects = $this->getObjects();
9293

93-
$this->totalNumberOfObjects = \count($objects);
94+
$this->totalNumberOfObjects = count($objects);
9495

9596
$this->numberOfIteratedObjects = 0;
9697
foreach ($objects as $data) {
@@ -114,7 +115,7 @@ public function load(ObjectManager $manager)
114115
/**
115116
* Creates the object and persist it in database.
116117
*
117-
* @param object $data
118+
* @param array $data
118119
*/
119120
private function fixtureObject(array $data): void
120121
{
@@ -127,7 +128,7 @@ private function fixtureObject(array $data): void
127128
// This means that it _may_ break objects for which ids are not provided in the fixtures.
128129
$metadata = $this->manager->getClassMetadata($this->getEntityClass());
129130
$primaryKey = $metadata->getIdentifierFieldNames();
130-
if (1 === \count($primaryKey) && isset($data[$primaryKey[0]])) {
131+
if (1 === count($primaryKey) && isset($data[$primaryKey[0]])) {
131132
$metadata->setIdGeneratorType($metadata::GENERATOR_TYPE_NONE);
132133
$metadata->setIdGenerator(new AssignedGenerator());
133134
}

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"require": {
1616
"php": "^7.2",
1717
"doctrine/orm": "^2.6",
18+
"doctrine/persistence": "^1.3",
1819
"doctrine/instantiator": "^1.1"
1920
},
2021
"require-dev": {

0 commit comments

Comments
 (0)