-
Notifications
You must be signed in to change notification settings - Fork 300
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed referencedColumnName value to be able to use values with Embedd…
…ed attributes
- Loading branch information
Showing
5 changed files
with
133 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Knp\DoctrineBehaviors\Tests\Fixtures\Entity; | ||
|
||
use Doctrine\ORM\Mapping\Column; | ||
use Doctrine\ORM\Mapping\Embeddable; | ||
use Doctrine\ORM\Mapping\Id; | ||
use Ramsey\Uuid\Uuid; | ||
|
||
#[Embeddable] | ||
class TranslatableEmbeddableUuid | ||
{ | ||
#[Id] | ||
#[Column(name: 'uuid', unique: true)] | ||
protected string $value; | ||
|
||
public function __construct(string $value) | ||
{ | ||
$this->value = $value; | ||
} | ||
|
||
public static function random(): self | ||
{ | ||
return new self(Uuid::uuid4()->toString()); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
tests/Fixtures/Entity/TranslatableEmbeddedIdentifierEntity.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,38 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Knp\DoctrineBehaviors\Tests\Fixtures\Entity; | ||
|
||
use Doctrine\ORM\Mapping\Embedded; | ||
use Doctrine\ORM\Mapping\Entity; | ||
use Knp\DoctrineBehaviors\Contract\Entity\TranslatableInterface; | ||
use Knp\DoctrineBehaviors\Model\Translatable\TranslatableTrait; | ||
|
||
#[Entity] | ||
class TranslatableEmbeddedIdentifierEntity implements TranslatableInterface | ||
{ | ||
use TranslatableTrait; | ||
|
||
#[Embedded(class: TranslatableEmbeddableUuid::class, columnPrefix: false)] | ||
private TranslatableEmbeddableUuid $uuid; | ||
|
||
public function __construct() | ||
{ | ||
$this->uuid = TranslatableEmbeddableUuid::random(); | ||
} | ||
|
||
/** | ||
* @param mixed[] $arguments | ||
* @return mixed | ||
*/ | ||
public function __call(string $method, array $arguments) | ||
{ | ||
return $this->proxyCurrentLocaleTranslation($method, $arguments); | ||
} | ||
|
||
public function getUuid(): TranslatableEmbeddableUuid | ||
{ | ||
return $this->uuid; | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
tests/Fixtures/Entity/TranslatableEmbeddedIdentifierEntityTranslation.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,43 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Knp\DoctrineBehaviors\Tests\Fixtures\Entity; | ||
|
||
use Doctrine\ORM\Mapping\Column; | ||
use Doctrine\ORM\Mapping\Embedded; | ||
use Doctrine\ORM\Mapping\Entity; | ||
use Knp\DoctrineBehaviors\Contract\Entity\TranslationInterface; | ||
use Knp\DoctrineBehaviors\Model\Translatable\TranslationTrait; | ||
|
||
#[Entity] | ||
class TranslatableEmbeddedIdentifierEntityTranslation implements TranslationInterface | ||
{ | ||
use TranslationTrait; | ||
|
||
#[Embedded(class: TranslatableEmbeddableUuid::class, columnPrefix: false)] | ||
private TranslatableEmbeddableUuid $uuid; | ||
|
||
#[Column(type: 'string')] | ||
private ?string $title = null; | ||
|
||
public function __construct() | ||
{ | ||
$this->uuid = TranslatableEmbeddableUuid::random(); | ||
} | ||
|
||
public function getUuid(): TranslatableEmbeddableUuid | ||
{ | ||
return $this->uuid; | ||
} | ||
|
||
public function getTitle(): ?string | ||
{ | ||
return $this->title; | ||
} | ||
|
||
public function setTitle(string $title): void | ||
{ | ||
$this->title = $title; | ||
} | ||
} |
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