src/Entity/Profile/ProfileInventoryItem.php line 17

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity\Profile;
  4. use AngelGamez\TranslatableBundle\Entity\TranslatableValue;
  5. use App\Repository\ProfileInventoryItemRepository;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Doctrine\ORM\Mapping\UniqueConstraint;
  8. use Symfony\Component\Serializer\Annotation\Groups;
  9. #[ORM\Table(name: 'profile_inventory_items')]
  10. #[UniqueConstraint(name: 'profile_inventory_item_uri_unique', columns: ['uri_identity'])]
  11. #[ORM\Entity(repositoryClass: ProfileInventoryItemRepository::class)]
  12. #[ORM\Cache(usage: 'NONSTRICT_READ_WRITE', region: 'profiles')]
  13. class ProfileInventoryItem
  14. {
  15.     #[ORM\Id]
  16.     #[ORM\Column(name: 'id', type: 'smallint')]
  17.     #[ORM\GeneratedValue(strategy: 'AUTO')]
  18.     #[Groups(['preview', 'listing'])]
  19.     private int $id;
  20.     #[ORM\Column(name: 'type', type: 'string', length: 32)]
  21.     #[Groups(['preview', 'listing'])]
  22.     private string $type;
  23.     #[ORM\Column(name: 'name', type: 'translatable')]
  24.     #[Groups(['preview', 'listing'])]
  25.     private TranslatableValue $name;
  26.     #[ORM\Column(name: 'uri_identity', type: 'string', length: 128)]
  27.     #[Groups(['preview', 'listing'])]
  28.     private string $uriIdentity;
  29.     #[ORM\Column(name: 'sort', type: 'smallint')]
  30.     #[Groups(['preview', 'listing'])]
  31.     private int $sort;
  32.     public function __construct(TranslatableValue $name, string $uriIdentity, string $type, int $sort)
  33.     {
  34.         if (!in_array($type, ProfileInventoryItemType::all(), true)) {
  35.             throw new \InvalidArgumentException(sprintf('Unsupported profile inventory item type "%s".', $type));
  36.         }
  37.         $this->name = $name;
  38.         $this->uriIdentity = $uriIdentity;
  39.         $this->type = $type;
  40.         $this->sort = $sort;
  41.     }
  42.     public function getId(): int
  43.     {
  44.         return $this->id;
  45.     }
  46.     public function getType(): string
  47.     {
  48.         return $this->type;
  49.     }
  50.     public function getName(): TranslatableValue
  51.     {
  52.         return $this->name;
  53.     }
  54.     public function getUriIdentity(): string
  55.     {
  56.         return $this->uriIdentity;
  57.     }
  58.     public function getSort(): int
  59.     {
  60.         return $this->sort;
  61.     }
  62. }