-
-
Notifications
You must be signed in to change notification settings - Fork 226
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix composite key serialization (#135)
- Loading branch information
Showing
6 changed files
with
137 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
tests/Doctrine/Tests/Common/DataFixtures/TestEntity/UserRole.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace Doctrine\Tests\Common\DataFixtures\TestEntity; | ||
|
||
/** | ||
* @Entity | ||
*/ | ||
class UserRole | ||
{ | ||
/** | ||
* @ManyToOne(targetEntity="User") | ||
* @Id | ||
*/ | ||
private $user; | ||
|
||
/** | ||
* @ManyToOne(targetEntity="Role") | ||
* @Id | ||
*/ | ||
private $role; | ||
|
||
public function __construct(User $user, Role $role) | ||
{ | ||
$this->user = $user; | ||
$this->role = $role; | ||
} | ||
|
||
public function getUser() | ||
{ | ||
return $this->user; | ||
} | ||
|
||
public function getRole() | ||
{ | ||
return $this->role; | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
tests/Doctrine/Tests/Common/DataFixtures/TestFixtures/UserRoleFixture.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
namespace Doctrine\Tests\Common\DataFixtures\TestFixtures; | ||
|
||
use Doctrine\Common\DataFixtures\AbstractFixture; | ||
use Doctrine\Common\Persistence\ObjectManager; | ||
use Doctrine\Tests\Common\DataFixtures\TestEntity\UserRole; | ||
|
||
class UserRoleFixture extends AbstractFixture | ||
{ | ||
public function load(ObjectManager $manager) | ||
{ | ||
$userRole = new UserRole( | ||
$this->getReference('admin'), | ||
$this->getReference('admin-role') | ||
); | ||
|
||
$manager->persist($userRole); | ||
$this->referenceRepository->addReference('composite-key', $userRole); | ||
$manager->flush(); | ||
} | ||
} |