Basic Structure

This commit is contained in:
2024-12-09 12:10:08 +04:00
parent cb02dcfbc5
commit 78094e41c1
4 changed files with 173 additions and 0 deletions
+62
View File
@@ -0,0 +1,62 @@
<?php
namespace App\Entity\Pf2e;
use App\Repository\Pf2e\ItemRepository;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Types\UuidType;
use Symfony\Component\Uid\Uuid;
#[ORM\Entity(repositoryClass: ItemRepository::class)]
class Item
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(type: UuidType::NAME, unique: true)]
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
#[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')]
private ?Uuid $uuid = null;
#[ORM\Column(length: 255)]
private ?string $name = null;
#[ORM\Column(enumType: ItemTypeEnum::class)]
private ?ItemTypeEnum $type = null;
public function getId(): ?int
{
return $this->id;
}
public function getUuid(): ?Uuid
{
return $this->uuid;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): static
{
$this->name = $name;
return $this;
}
public function getType(): ?ItemTypeEnum
{
return $this->type;
}
public function setType(ItemTypeEnum $type): static
{
$this->type = $type;
return $this;
}
}
+18
View File
@@ -0,0 +1,18 @@
<?php
namespace App\Entity\Pf2e;
enum ItemTypeEnum: string {
case Feat = 'feat';
case Ancestry = 'ancestry';
case Heritage = 'heritage';
case Archetype = 'archetype';
case Background = 'background';
case Skill = 'skill';
case Klass = 'klass';
case SubKlass = 'sub-klass';
case Equipment = 'equipment';
case Trait = 'trait';
case Rule = 'rule';
}
+43
View File
@@ -0,0 +1,43 @@
<?php
namespace App\Repository\Pf2e;
use App\Entity\Pf2e\Item;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @extends ServiceEntityRepository<Item>
*/
class ItemRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Item::class);
}
// /**
// * @return Item[] Returns an array of Item objects
// */
// public function findByExampleField($value): array
// {
// return $this->createQueryBuilder('i')
// ->andWhere('i.exampleField = :val')
// ->setParameter('val', $value)
// ->orderBy('i.id', 'ASC')
// ->setMaxResults(10)
// ->getQuery()
// ->getResult()
// ;
// }
// public function findOneBySomeField($value): ?Item
// {
// return $this->createQueryBuilder('i')
// ->andWhere('i.exampleField = :val')
// ->setParameter('val', $value)
// ->getQuery()
// ->getOneOrNullResult()
// ;
// }
}