feat: split project description into 4 fields

This commit is contained in:
2026-08-13 16:47:15 +02:00
parent 79ef243d11
commit c0fab8a098
5 changed files with 125 additions and 44 deletions
+26
View File
@@ -0,0 +1,26 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20260813144440 extends AbstractMigration
{
public function getDescription(): string
{
return 'Split description into: brief, about, goal and team';
}
public function up(Schema $schema): void
{
$this->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');
}
}
+17 -4
View File
@@ -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.
+8 -30
View File
@@ -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(
+21 -2
View File
@@ -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.\
+53 -8
View File
@@ -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;
}