Skip to content

Commit

Permalink
Merge pull request #8 from anzusystems/feature/custom_data
Browse files Browse the repository at this point in the history
Add custom data trait
  • Loading branch information
marforon authored Feb 15, 2023
2 parents 6d7f71b + 1ecac13 commit 5334473
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Entity/Interfaces/CustomDataInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

declare(strict_types=1);

namespace AnzuSystems\Contracts\Entity\Interfaces;

interface CustomDataInterface
{
public function getCustomData(): array;

public function setCustomData(array $customData): static;
}
31 changes: 31 additions & 0 deletions src/Entity/Traits/CustomDataTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

declare(strict_types=1);

namespace AnzuSystems\Contracts\Entity\Traits;

use AnzuSystems\SerializerBundle\Attributes\Serialize;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;

trait CustomDataTrait
{
/**
* Custom data..
*/
#[ORM\Column(type: Types::JSON)]
#[Serialize(strategy: Serialize::KEYS_VALUES)]
protected array $customData;

public function getCustomData(): array
{
return $this->customData;
}

public function setCustomData(array $customData): static
{
$this->customData = $customData;

return $this;
}
}

0 comments on commit 5334473

Please sign in to comment.