<?php
namespace App\Domain\Entity\Comment;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Link;
use App\Application\Controller\Api\Comment\GetTripAction;
use App\Application\Controller\Api\Comment\GetTripCommentsAction;
use App\Domain\Entity\Comment;
use App\Domain\Entity\Locale;
use App\Domain\Entity\Person;
use App\Domain\Entity\Trip;
use DateTime;
/**
* Class Comment
*
* @package App\Domain\Entity
*/
#[ApiResource(
operations : [
new GetCollection(filters: [
'comment.search_filter',
'comment.exists_filter',
'soft_delete_filter',
'comment.order_filter',
]),
],
normalizationContext : ['groups' => ['comment_read']],
denormalizationContext: ['groups' => ['comment_write']],
filters : ['translation.groups'],
order : ['createdAt' => 'DESC'],
)]
#[ApiResource(
uriTemplate : '/trips/{uuid}/comments',
operations : [
new GetCollection(
filters: [
'comment.search_filter',
'comment.exists_filter',
'soft_delete_filter',
'comment.order_filter',
'comment.null_filter',
],
),
],
uriVariables : [
'uuid' => new Link(toProperty: 'trip', fromClass: Trip::class),
],
normalizationContext : ['groups' => ['comment_read']],
denormalizationContext: ['groups' => ['comment_write']],
filters : ['translation.groups'],
order : ['createdAt' => 'DESC'],
)]
class TripComment extends Comment
{
/**
* @param Person $author
* @param Locale|null $authorLocale
* @param Trip $trip
* @param string $status
* @param int $notation
* @param Comment|null $parent
* @param string|null $remoteId
*/
public function __construct(
Person $author,
?Locale $authorLocale,
public Trip $trip,
string $status = self::COMMENT_NEW,
int $notation = 0,
?Comment $parent = null,
public ?string $remoteId = null,
public ?DateTime $zhistUpdate = null,
) {
parent::__construct(
author : $author,
authorLocale: $authorLocale,
status : $status,
notation : $notation,
parent : $parent,
zhistUpdate : $zhistUpdate,
);
}
}