* feat: start project reviews entity * feat: add review areas entity * feat: add review comments entity * fix: code styles improvements by php-cs-fixer * feat: expose project review resources in the API * feat: add timestampt to review resources * feat: add SQL migration * fix: update ProjectReview API docs and operations * feat: refactor ProjectsListener to dedicated project status listener * fix: make default review area risk high * feat: add ReviewService for creating default project reviews * fix: renamed timestampt entity traits * fix: update doctrine migration * feat: test for release date to be set greater than today's start * feat: add test for project campaign review * fix: update person and organization patch validations * fix: test if review entity is truly persisted * fix: bad start statuses in project tests * fix: ProjectStatusListener not persisting side effect data * fix: centralize project status change side-effects processing in ProjectService * fix: small review persistence tweaks * feat: allow only concerned users to see and edit review areas * feat: apply validations and security for concerned users to review comments
72 lines
1.5 KiB
PHP
72 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Service\Project;
|
|
|
|
use App\Entity\Project\Review;
|
|
use App\Entity\Project\ReviewArea;
|
|
use App\Entity\Project\ReviewType;
|
|
|
|
class ReviewService
|
|
{
|
|
public function makeReview(ReviewType $type): Review
|
|
{
|
|
$review = new Review();
|
|
$review->setType($type);
|
|
|
|
/** @var ReviewArea[] */
|
|
$areas = match ($type) {
|
|
ReviewType::Campaign => $this->getCampaignReviewAreas(),
|
|
ReviewType::Financial => $this->getFinancialReviewAreas(),
|
|
};
|
|
|
|
foreach ($areas as $area) {
|
|
$review->addArea($area);
|
|
}
|
|
|
|
return $review;
|
|
}
|
|
|
|
/**
|
|
* @return ReviewArea[]
|
|
*/
|
|
private function getCampaignReviewAreas(): array
|
|
{
|
|
$config = new ReviewArea();
|
|
$config->setTitle('configuration');
|
|
|
|
$info = new ReviewArea();
|
|
$info->setTitle('info');
|
|
|
|
$rewards = new ReviewArea();
|
|
$rewards->setTitle('rewards');
|
|
|
|
$collabs = new ReviewArea();
|
|
$collabs->setTitle('collaborations');
|
|
|
|
$budget = new ReviewArea();
|
|
$budget->setTitle('budget');
|
|
|
|
$about = new ReviewArea();
|
|
$about->setTitle('about');
|
|
|
|
return [
|
|
$config,
|
|
$info,
|
|
$rewards,
|
|
$collabs,
|
|
$budget,
|
|
$about,
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @return ReviewArea[]
|
|
*
|
|
* @todo Add financial review areas
|
|
*/
|
|
private function getFinancialReviewAreas(): array
|
|
{
|
|
return [];
|
|
}
|
|
}
|