Skip to content

Commit 01f6a3c

Browse files
committed
Fixing a bug where a repository would not be generated under certain
conditions
1 parent 2f0e0f3 commit 01f6a3c

File tree

6 files changed

+95
-0
lines changed

6 files changed

+95
-0
lines changed

src/Doctrine/EntityRegenerator.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,5 +206,7 @@ private function generateRepository(ClassMetadata $metadata)
206206
'entity_alias' => strtolower($entityClassName[0]),
207207
]
208208
);
209+
210+
$this->generator->writeChanges();
209211
}
210212
}

tests/Doctrine/fixtures/expected_xml/src/Entity/User.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ class User
99
{
1010
private $id;
1111

12+
private $name;
13+
1214
private $avatars;
1315

1416
public function __construct()
@@ -22,6 +24,18 @@ public function getId(): ?int
2224
return $this->id;
2325
}
2426

27+
public function getName(): ?string
28+
{
29+
return $this->name;
30+
}
31+
32+
public function setName(string $name): self
33+
{
34+
$this->name = $name;
35+
36+
return $this;
37+
}
38+
2539
/**
2640
* @return Collection|UserAvatar[]
2741
*/
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace Symfony\Bundle\MakerBundle\Tests\tmp\current_project\src\Entity;
4+
5+
class XOther
6+
{
7+
private $id;
8+
9+
public function getId(): ?int
10+
{
11+
return $this->id;
12+
}
13+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
3+
namespace Symfony\Bundle\MakerBundle\Tests\tmp\current_project\src\Repository;
4+
5+
use Symfony\Bundle\MakerBundle\Tests\tmp\current_project\src\Entity\XOther;
6+
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
7+
use Symfony\Bridge\Doctrine\RegistryInterface;
8+
9+
/**
10+
* @method XOther|null find($id, $lockMode = null, $lockVersion = null)
11+
* @method XOther|null findOneBy(array $criteria, array $orderBy = null)
12+
* @method XOther[] findAll()
13+
* @method XOther[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
14+
*/
15+
class XOtherRepository extends ServiceEntityRepository
16+
{
17+
public function __construct(RegistryInterface $registry)
18+
{
19+
parent::__construct($registry, XOther::class);
20+
}
21+
22+
// /**
23+
// * @return XOther[] Returns an array of XOther objects
24+
// */
25+
/*
26+
public function findByExampleField($value)
27+
{
28+
return $this->createQueryBuilder('x')
29+
->andWhere('x.exampleField = :val')
30+
->setParameter('val', $value)
31+
->orderBy('x.id', 'ASC')
32+
->setMaxResults(10)
33+
->getQuery()
34+
->getResult()
35+
;
36+
}
37+
*/
38+
39+
/*
40+
public function findOneBySomeField($value): ?XOther
41+
{
42+
return $this->createQueryBuilder('x')
43+
->andWhere('x.exampleField = :val')
44+
->setParameter('val', $value)
45+
->getQuery()
46+
->getOneOrNullResult()
47+
;
48+
}
49+
*/
50+
}

tests/Doctrine/fixtures/xml_source_project/config/doctrine/User.orm.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
<id name="id" type="integer">
88
<generator strategy="AUTO" />
99
</id>
10+
<field name="name" type="string" length="100">
11+
<options>
12+
<option name="coment">First Name</option>
13+
</options>
14+
</field>
1015
<one-to-many field="avatars" target-entity="UserAvatar" mapped-by="user" />
1116
</entity>
1217
</doctrine-mapping>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
4+
http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
5+
6+
<entity name="Symfony\Bundle\MakerBundle\Tests\tmp\current_project\src\Entity\XOther" repository-class="Symfony\Bundle\MakerBundle\Tests\tmp\current_project\src\Repository\XOtherRepository">
7+
<id name="id" type="integer">
8+
<generator strategy="AUTO" />
9+
</id>
10+
</entity>
11+
</doctrine-mapping>

0 commit comments

Comments
 (0)