src/Domain/Entity/Comment/TripComment.php line 56

Open in your IDE?
  1. <?php
  2. namespace App\Domain\Entity\Comment;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use ApiPlatform\Metadata\GetCollection;
  5. use ApiPlatform\Metadata\Link;
  6. use App\Application\Controller\Api\Comment\GetTripAction;
  7. use App\Application\Controller\Api\Comment\GetTripCommentsAction;
  8. use App\Domain\Entity\Comment;
  9. use App\Domain\Entity\Locale;
  10. use App\Domain\Entity\Person;
  11. use App\Domain\Entity\Trip;
  12. use DateTime;
  13. /**
  14.  * Class Comment
  15.  *
  16.  * @package App\Domain\Entity
  17.  */
  18. #[ApiResource(
  19.     operations            : [
  20.         new GetCollection(filters: [
  21.             'comment.search_filter',
  22.             'comment.exists_filter',
  23.             'soft_delete_filter',
  24.             'comment.order_filter',
  25.         ]),
  26.     ],
  27.     normalizationContext  : ['groups' => ['comment_read']],
  28.     denormalizationContext: ['groups' => ['comment_write']],
  29.     filters               : ['translation.groups'],
  30.     order                 : ['createdAt' => 'DESC'],
  31. )]
  32. #[ApiResource(
  33.     uriTemplate           '/trips/{uuid}/comments',
  34.     operations            : [
  35.         new GetCollection(
  36.             filters: [
  37.                 'comment.search_filter',
  38.                 'comment.exists_filter',
  39.                 'soft_delete_filter',
  40.                 'comment.order_filter',
  41.                 'comment.null_filter',
  42.             ],
  43.         ),
  44.     ],
  45.     uriVariables          : [
  46.         'uuid' => new Link(toProperty'trip'fromClassTrip::class),
  47.     ],
  48.     normalizationContext  : ['groups' => ['comment_read']],
  49.     denormalizationContext: ['groups' => ['comment_write']],
  50.     filters               : ['translation.groups'],
  51.     order                 : ['createdAt' => 'DESC'],
  52. )]
  53. class TripComment extends Comment
  54. {
  55.     /**
  56.      * @param Person       $author
  57.      * @param Locale|null  $authorLocale
  58.      * @param Trip         $trip
  59.      * @param string       $status
  60.      * @param int          $notation
  61.      * @param Comment|null $parent
  62.      * @param string|null  $remoteId
  63.      */
  64.     public function __construct(
  65.         Person $author,
  66.         ?Locale $authorLocale,
  67.         public Trip $trip,
  68.         string $status self::COMMENT_NEW,
  69.         int $notation 0,
  70.         ?Comment $parent null,
  71.         public ?string $remoteId null,
  72.         public ?DateTime $zhistUpdate null,
  73.     ) {
  74.         parent::__construct(
  75.             author      $author,
  76.             authorLocale$authorLocale,
  77.             status      $status,
  78.             notation    $notation,
  79.             parent      $parent,
  80.             zhistUpdate $zhistUpdate,
  81.         );
  82.     }
  83. }