diff --git a/migrations/Version20260813144440.php b/migrations/Version20260813144440.php new file mode 100644 index 0000000..0f1e6fd --- /dev/null +++ b/migrations/Version20260813144440.php @@ -0,0 +1,26 @@ +addSql('ALTER TABLE project ADD desc_about LONGTEXT DEFAULT NULL, ADD desc_goal LONGTEXT DEFAULT NULL, ADD desc_team LONGTEXT DEFAULT NULL, CHANGE description desc_brief LONGTEXT DEFAULT NULL'); + } + + public function down(Schema $schema): void + { + $this->addSql('ALTER TABLE project ADD description LONGTEXT DEFAULT NULL, DROP desc_brief, DROP desc_about, DROP desc_goal, DROP desc_team'); + } +} diff --git a/src/ApiResource/Project/ProjectApiResource.php b/src/ApiResource/Project/ProjectApiResource.php index 87a23f0..95fb1a4 100644 --- a/src/ApiResource/Project/ProjectApiResource.php +++ b/src/ApiResource/Project/ProjectApiResource.php @@ -141,11 +141,24 @@ class ProjectApiResource public Territory $territory; /** - * Free-form rich text description for the Project. + * Rich-text (markdown) introduction to the project. */ - #[API\ApiFilter(filterClass: SearchFilter::class, strategy: 'partial')] - #[Assert\NotBlank()] - public string $description; + public string $descBrief; + + /** + * Rich-text (markdown) description on the main features of the project. + */ + public string $descAbout; + + /** + * Rich-text (markdown) about why this project is important. + */ + public string $descGoal; + + /** + * Rich-text (markdown) about team and previous experience. + */ + public string $descTeam; /** * Extracted embedding data from the Project's video. diff --git a/src/Benzina/ProjectsPump.php b/src/Benzina/ProjectsPump.php index 7990ed9..a53a9af 100644 --- a/src/Benzina/ProjectsPump.php +++ b/src/Benzina/ProjectsPump.php @@ -92,7 +92,10 @@ class ProjectsPump implements PumpInterface $project->addLocale($record['lang']); $project->setTitle($record['name'] ?? ''); $project->setSubtitle($record['subtitle'] ?? ''); - $project->setDescription($this->getProjectDescription($record)); + $project->setDescBrief($record['description']); + $project->setDescAbout($record['about']); + $project->setDescGoal($record['motivation']); + $project->setDescTeam($record['related']); $this->setPreventFlushAndClear(true); $this->persist($project, $context); @@ -103,7 +106,10 @@ class ProjectsPump implements PumpInterface $this->localize($project, $localizations, $context, [ 'title' => fn($l) => $l['name'], 'subtitle' => fn($l) => $l['subtitle'], - 'description' => fn($l) => $this->getProjectDescription($l), + 'descBrief' => fn($l) => $l['description'], + 'descAbout' => fn($l) => $l['about'], + 'descGoal' => fn($l) => $l['motivation'], + 'descTeam' => fn($l) => $l['related'], ]); } @@ -123,34 +129,6 @@ class ProjectsPump implements PumpInterface return $this->userRepository->matching($criteria)->first() ?? null; } - private function getProjectDescription(array $record): string - { - $lang = $record['lang']; - $hasTitles = \array_key_exists($lang, self::PROJECT_DESC_TITLES); - - $description = $record['description']; - - if ($hasTitles) { - $description .= \sprintf("\n\n## %s", self::PROJECT_DESC_TITLES[$lang]['about']); - } - - $description .= \sprintf("\n%s", $record['about']); - - if ($hasTitles) { - $description .= \sprintf("\n\n## %s", self::PROJECT_DESC_TITLES[$lang]['motivation']); - } - - $description .= \sprintf("\n\n%s", $record['motivation']); - - if ($hasTitles) { - $description .= \sprintf("\n\n## %s", self::PROJECT_DESC_TITLES[$lang]['related']); - } - - $description .= \sprintf("\n%s", $record['related']); - - return $description; - } - private function getProjectLocalizations(Project $project, array $context): array { $query = $this->getDbConnection($context)->prepare( diff --git a/src/Dto/ProjectUpdationDto.php b/src/Dto/ProjectUpdationDto.php index 5d5857c..85244cb 100644 --- a/src/Dto/ProjectUpdationDto.php +++ b/src/Dto/ProjectUpdationDto.php @@ -47,9 +47,28 @@ class ProjectUpdationDto public Territory $territory; /** - * Free-form rich text description for the Project. + * Rich-text (markdown allowed) introduction to the project. */ - public string $description; + #[Assert\NotBlank()] + public string $descBrief; + + /** + * Rich-text (markdown allowed) description on the main features of the project. + */ + #[Assert\NotBlank()] + public string $descAbout; + + /** + * Rich-text (markdown allowed) about why this project is important. + */ + #[Assert\NotBlank()] + public string $descGoal; + + /** + * Rich-text (markdown allowed) about team and previous experience. + */ + #[Assert\NotBlank()] + public string $descTeam; /** * On `minimum`, Project will campaign until the minimum deadline.\ diff --git a/src/Entity/Project/Project.php b/src/Entity/Project/Project.php index 763b79c..b6c9b91 100644 --- a/src/Entity/Project/Project.php +++ b/src/Entity/Project/Project.php @@ -78,12 +78,21 @@ class Project implements UserOwnedInterface, AccountingOwnerInterface, Localized #[ORM\Embedded(class: Territory::class)] private ?Territory $territory; - /** - * The description body for the Project. - */ #[ORM\Column(type: Types::TEXT, nullable: true)] #[Gedmo\Translatable()] - private ?string $description = null; + private ?string $descBrief = null; + + #[ORM\Column(type: Types::TEXT, nullable: true)] + #[Gedmo\Translatable()] + private ?string $descAbout = null; + + #[ORM\Column(type: Types::TEXT, nullable: true)] + #[Gedmo\Translatable()] + private ?string $descGoal = null; + + #[ORM\Column(type: Types::TEXT, nullable: true)] + #[Gedmo\Translatable()] + private ?string $descTeam = null; /** * A video showcasing the Project. @@ -277,14 +286,50 @@ class Project implements UserOwnedInterface, AccountingOwnerInterface, Localized return $this; } - public function getDescription(): ?string + public function getDescBrief(): ?string { - return $this->description; + return $this->descBrief; } - public function setDescription(string $description): static + public function setDescBrief(?string $descBrief): static { - $this->description = $description; + $this->descBrief = $descBrief; + + return $this; + } + + public function getDescAbout(): ?string + { + return $this->descAbout; + } + + public function setDescAbout(?string $descAbout): static + { + $this->descAbout = $descAbout; + + return $this; + } + + public function getDescGoal(): ?string + { + return $this->descGoal; + } + + public function setDescGoal(?string $descGoal): static + { + $this->descGoal = $descGoal; + + return $this; + } + + public function getDescTeam(): ?string + { + return $this->descTeam; + } + + public function setDescTeam(?string $descTeam): static + { + $this->descTeam = $descTeam; return $this; }