-
-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: use a "placeholder" for inversed one-to-one (#755)
- Loading branch information
Showing
7 changed files
with
171 additions
and
34 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Zenstruck\Foundry\Persistence; | ||
|
||
/** | ||
* @internal | ||
* @author Nicolas PHILIPPE <nikophil@gmail.com> | ||
*/ | ||
enum PersistMode | ||
{ | ||
case PERSIST; | ||
case WITHOUT_PERSISTING; | ||
case NO_PERSIST_BUT_SCHEDULE_FOR_INSERT; | ||
|
||
public function isPersisting(): bool | ||
{ | ||
return $this === self::PERSIST; | ||
} | ||
} |
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
39 changes: 39 additions & 0 deletions
39
tests/Fixture/Entity/EdgeCases/InversedOneToOneWithSetter/InverseSide.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,39 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the zenstruck/foundry package. | ||
* | ||
* (c) Kevin Bond <kevinbond@gmail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Zenstruck\Foundry\Tests\Fixture\Entity\EdgeCases\InversedOneToOneWithSetter; | ||
|
||
use Doctrine\ORM\Mapping as ORM; | ||
use Zenstruck\Foundry\Tests\Fixture\Model\Base; | ||
|
||
/** | ||
* @author Nicolas PHILIPPE <nikophil@gmail.com> | ||
*/ | ||
#[ORM\Entity] | ||
#[ORM\Table('inversed_one_to_one_with_setter_inverse_side')] | ||
class InverseSide extends Base | ||
{ | ||
#[ORM\OneToOne(mappedBy: 'inverseSide')] | ||
private OwningSide|null $owningSide = null; | ||
|
||
public function getOwningSide(): ?OwningSide | ||
{ | ||
return $this->owningSide; | ||
} | ||
|
||
public function setOwningSide(OwningSide $owningSide): void | ||
{ | ||
$this->owningSide = $owningSide; | ||
$owningSide->inverseSide = $this; | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
tests/Fixture/Entity/EdgeCases/InversedOneToOneWithSetter/OwningSide.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,28 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the zenstruck/foundry package. | ||
* | ||
* (c) Kevin Bond <kevinbond@gmail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Zenstruck\Foundry\Tests\Fixture\Entity\EdgeCases\InversedOneToOneWithSetter; | ||
|
||
use Doctrine\ORM\Mapping as ORM; | ||
use Zenstruck\Foundry\Tests\Fixture\Model\Base; | ||
|
||
/** | ||
* @author Nicolas PHILIPPE <nikophil@gmail.com> | ||
*/ | ||
#[ORM\Entity] | ||
#[ORM\Table('inversed_one_to_one_with_setter_owning_side')] | ||
class OwningSide extends Base | ||
{ | ||
#[ORM\OneToOne(inversedBy: 'owningSide')] | ||
public ?InverseSide $inverseSide = null; | ||
} |
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