From ff40c877307dd556202b5392d5c8f810ddb45d3c Mon Sep 17 00:00:00 2001 From: kozhilya Date: Wed, 26 Mar 2025 19:12:04 +0400 Subject: [PATCH] 123 --- migrations/Version20241211060919.php | 32 ++++ migrations/Version20241211061051.php | 36 ++++ migrations/Version20241211061203.php | 32 ++++ .../Pf2eSchemaGenerator/EntitySchemas.php | 12 +- src/Entity/Pf2e/Ancestry.php | 179 ++++++++++++++++++ src/Repository/Pf2e/AncestryRepository.php | 43 +++++ 6 files changed, 333 insertions(+), 1 deletion(-) create mode 100644 migrations/Version20241211060919.php create mode 100644 migrations/Version20241211061051.php create mode 100644 migrations/Version20241211061203.php create mode 100644 src/Entity/Pf2e/Ancestry.php create mode 100644 src/Repository/Pf2e/AncestryRepository.php diff --git a/migrations/Version20241211060919.php b/migrations/Version20241211060919.php new file mode 100644 index 0000000..c8764d1 --- /dev/null +++ b/migrations/Version20241211060919.php @@ -0,0 +1,32 @@ +addSql('CREATE TABLE ancestry (id VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, rarity INT NOT NULL, type VARCHAR(255) NOT NULL, attribute JSON DEFAULT NULL, attribute_flaw JSON DEFAULT NULL, hp_raw INT DEFAULT NULL, image JSON DEFAULT NULL, size JSON NOT NULL, speed VARCHAR(255) NOT NULL, PRIMARY KEY(id))'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('CREATE SCHEMA public'); + $this->addSql('DROP TABLE ancestry'); + } +} diff --git a/migrations/Version20241211061051.php b/migrations/Version20241211061051.php new file mode 100644 index 0000000..cee083f --- /dev/null +++ b/migrations/Version20241211061051.php @@ -0,0 +1,36 @@ +addSql('ALTER TABLE ancestry ADD item_id INT NOT NULL'); + $this->addSql('ALTER TABLE ancestry ADD CONSTRAINT FK_63FAD02F126F525E FOREIGN KEY (item_id) REFERENCES item (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('CREATE UNIQUE INDEX UNIQ_63FAD02F126F525E ON ancestry (item_id)'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('CREATE SCHEMA public'); + $this->addSql('ALTER TABLE ancestry DROP CONSTRAINT FK_63FAD02F126F525E'); + $this->addSql('DROP INDEX UNIQ_63FAD02F126F525E'); + $this->addSql('ALTER TABLE ancestry DROP item_id'); + } +} diff --git a/migrations/Version20241211061203.php b/migrations/Version20241211061203.php new file mode 100644 index 0000000..c50c8b7 --- /dev/null +++ b/migrations/Version20241211061203.php @@ -0,0 +1,32 @@ +addSql('ALTER TABLE ancestry ALTER hp_raw TYPE VARCHAR(255)'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('CREATE SCHEMA public'); + $this->addSql('ALTER TABLE ancestry ALTER hp_raw TYPE INT'); + } +} diff --git a/src/Command/Pf2eSchemaGenerator/EntitySchemas.php b/src/Command/Pf2eSchemaGenerator/EntitySchemas.php index 8e498cd..885fc3f 100644 --- a/src/Command/Pf2eSchemaGenerator/EntitySchemas.php +++ b/src/Command/Pf2eSchemaGenerator/EntitySchemas.php @@ -37,14 +37,24 @@ return [ ] ], "ancestry" => [ -// "class" => , + "class" => \App\Entity\Pf2e\Ancestry::class, "schema" => [ + "name" => true, "rarity" => [ "method" => "enum", "field" => "rarity_id", "enum" => \App\Entity\Rarity::class, ], + "type" => true, + "attribute" => true, + "attribute_flaw" => true, + "hp_raw" => true, + "image" => true, + "size" => true, + "speed" => "speed_markdown", +// "trait" => [], +// "source" => [], ], "localization" => [ "title" => "name", diff --git a/src/Entity/Pf2e/Ancestry.php b/src/Entity/Pf2e/Ancestry.php new file mode 100644 index 0000000..cda255f --- /dev/null +++ b/src/Entity/Pf2e/Ancestry.php @@ -0,0 +1,179 @@ +id; + } + + public function setId(string $value): self + { + $this->id = $value; + + return $this; + } + + public function getItem(): ?Item + { + return $this->item; + } + + public function setItem(Item $item): static + { + $this->item = $item; + + return $this; + } + + public function getName(): ?string + { + return $this->name; + } + + public function setName(string $name): static + { + $this->name = $name; + + return $this; + } + + public function getRarity(): ?Rarity + { + return $this->rarity; + } + + public function setRarity(Rarity $rarity): static + { + $this->rarity = $rarity; + + return $this; + } + + public function getType(): ?string + { + return $this->type; + } + + public function setType(string $type): static + { + $this->type = $type; + + return $this; + } + + public function getAttribute(): ?array + { + return $this->attribute; + } + + public function setAttribute(?array $attribute): static + { + $this->attribute = $attribute; + + return $this; + } + + public function getAttributeFlaw(): ?array + { + return $this->attribute_flaw; + } + + public function setAttributeFlaw(?array $attribute_flaw): static + { + $this->attribute_flaw = $attribute_flaw; + + return $this; + } + + public function getHpRaw(): ?string + { + return $this->hp_raw; + } + + public function setHpRaw(?string $hp_raw): static + { + $this->hp_raw = $hp_raw; + + return $this; + } + + public function getImage(): ?array + { + return $this->image; + } + + public function setImage(?array $image): static + { + $this->image = $image; + + return $this; + } + + public function getSize(): array + { + return $this->size; + } + + public function setSize(array $size): static + { + $this->size = $size; + + return $this; + } + + public function getSpeed(): ?string + { + return $this->speed; + } + + public function setSpeed(string $speed): static + { + $this->speed = $speed; + + return $this; + } +} diff --git a/src/Repository/Pf2e/AncestryRepository.php b/src/Repository/Pf2e/AncestryRepository.php new file mode 100644 index 0000000..19496aa --- /dev/null +++ b/src/Repository/Pf2e/AncestryRepository.php @@ -0,0 +1,43 @@ + + */ +class AncestryRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, Ancestry::class); + } + + // /** + // * @return Ancestry[] Returns an array of Ancestry objects + // */ + // public function findByExampleField($value): array + // { + // return $this->createQueryBuilder('a') + // ->andWhere('a.exampleField = :val') + // ->setParameter('val', $value) + // ->orderBy('a.id', 'ASC') + // ->setMaxResults(10) + // ->getQuery() + // ->getResult() + // ; + // } + + // public function findOneBySomeField($value): ?Ancestry + // { + // return $this->createQueryBuilder('a') + // ->andWhere('a.exampleField = :val') + // ->setParameter('val', $value) + // ->getQuery() + // ->getOneOrNullResult() + // ; + // } +}