edmondscommerce /
doctrine-static-meta
| 1 | <?php declare(strict_types=1); |
||||
| 2 | |||||
| 3 | namespace EdmondsCommerce\DoctrineStaticMeta\Entity\Embeddable\Traits\Identity; |
||||
| 4 | |||||
| 5 | use Doctrine\ORM\Events; |
||||
| 6 | use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder; |
||||
| 7 | use EdmondsCommerce\DoctrineStaticMeta\Entity\Embeddable\Interfaces\Identity\HasFullNameEmbeddableInterface; |
||||
| 8 | use EdmondsCommerce\DoctrineStaticMeta\Entity\Embeddable\Interfaces\Objects\Identity\FullNameEmbeddableInterface; |
||||
| 9 | use EdmondsCommerce\DoctrineStaticMeta\Entity\Embeddable\Objects\Identity\FullNameEmbeddable; |
||||
| 10 | |||||
| 11 | trait HasFullNameEmbeddableTrait |
||||
| 12 | { |
||||
| 13 | /** |
||||
| 14 | * @var FullNameEmbeddable |
||||
| 15 | */ |
||||
| 16 | private $fullNameEmbeddable; |
||||
| 17 | |||||
| 18 | /** |
||||
| 19 | * Called at construction time |
||||
| 20 | */ |
||||
| 21 | 2 | private function initFullNameEmbeddable(): void |
|||
| 22 | { |
||||
| 23 | 2 | $this->setFullNameEmbeddable(new FullNameEmbeddable(), false); |
|||
| 24 | 2 | } |
|||
| 25 | |||||
| 26 | /** |
||||
| 27 | * @return mixed |
||||
| 28 | */ |
||||
| 29 | 2 | public function getFullNameEmbeddable(): FullNameEmbeddableInterface |
|||
| 30 | { |
||||
| 31 | 2 | return $this->fullNameEmbeddable; |
|||
| 32 | } |
||||
| 33 | |||||
| 34 | /** |
||||
| 35 | * @param mixed $fullNameEmbeddable |
||||
| 36 | * |
||||
| 37 | * @param bool $notify |
||||
| 38 | * |
||||
| 39 | * @return $this |
||||
| 40 | * @SuppressWarnings(PHPMD.BooleanArgumentFlag) |
||||
| 41 | */ |
||||
| 42 | 2 | public function setFullNameEmbeddable($fullNameEmbeddable, bool $notify = true): self |
|||
| 43 | { |
||||
| 44 | 2 | $this->fullNameEmbeddable = $fullNameEmbeddable; |
|||
| 45 | 2 | $this->fullNameEmbeddable->setOwningEntity($this); |
|||
| 46 | 2 | if (true === $notify) { |
|||
| 47 | 1 | $this->notifyEmbeddablePrefixedProperties(HasFullNameEmbeddableInterface::PROP_FULL_NAME_EMBEDDABLE); |
|||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||
| 48 | } |
||||
| 49 | |||||
| 50 | 2 | return $this; |
|||
| 51 | } |
||||
| 52 | |||||
| 53 | public function postLoadSetOwningEntityOnFullNameEmbeddable(): void |
||||
| 54 | { |
||||
| 55 | $this->fullNameEmbeddable->setOwningEntity($this); |
||||
|
0 ignored issues
–
show
$this of type EdmondsCommerce\Doctrine...FullNameEmbeddableTrait is incompatible with the type EdmondsCommerce\Doctrine...TrackingPolicyInterface expected by parameter $entity of EdmondsCommerce\Doctrine...ject::setOwningEntity().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 56 | } |
||||
| 57 | |||||
| 58 | /** |
||||
| 59 | * @param ClassMetadataBuilder $builder |
||||
| 60 | */ |
||||
| 61 | 2 | protected static function metaForFullNameEmbeddable(ClassMetadataBuilder $builder): void |
|||
| 62 | { |
||||
| 63 | 2 | $builder->addLifecycleEvent('postLoadSetOwningEntityOnFullNameEmbeddable', Events::postLoad); |
|||
| 64 | 2 | $builder->createEmbedded( |
|||
| 65 | 2 | HasFullNameEmbeddableInterface::PROP_FULL_NAME_EMBEDDABLE, |
|||
| 66 | 2 | FullNameEmbeddable::class |
|||
| 67 | ) |
||||
| 68 | 2 | ->setColumnPrefix( |
|||
| 69 | 2 | HasFullNameEmbeddableInterface::COLUMN_PREFIX_FULL_NAME |
|||
| 70 | ) |
||||
| 71 | 2 | ->build(); |
|||
| 72 | 2 | } |
|||
| 73 | } |
||||
| 74 |