66use  DR \Review \Controller \AbstractController ;
77use  DR \Review \Entity \Review \CodeReview ;
88use  DR \Review \Entity \Review \Comment ;
9- use  DR \Review \Entity \Review \LineReference ;
109use  DR \Review \Form \Review \AddCommentFormType ;
1110use  DR \Review \Repository \Review \CommentRepository ;
1211use  DR \Review \Security \Role \Roles ;
13- use  DR \Utils \Assert ;
1412use  Symfony \Bridge \Doctrine \Attribute \MapEntity ;
1513use  Symfony \Component \HttpFoundation \JsonResponse ;
1614use  Symfony \Component \HttpFoundation \Request ;
@@ -28,27 +26,21 @@ public function __construct(private readonly CommentRepository $commentRepositor
2826    #[IsGranted(Roles::ROLE_USER )]
2927    public  function  __invoke (Request $ requestCodeReview $ reviewJsonResponse 
3028    {
31-         $ form$ this createForm (AddCommentFormType::class, null , ['review '  => $ review
32-         $ formhandleRequest ($ request
33-         if  ($ formisSubmitted () === false  || $ formisValid () === false ) {
34-             return  $ this json (['success '  => false ], Response::HTTP_BAD_REQUEST );
35-         }
36- 
37-         /** @var array{lineReference: string, message: string} $data */ 
38-         $ data$ formgetData ();
39- 
40-         $ lineReferencefromString ($ data'lineReference ' ]);
41- 
4229        $ user$ this getUser ();
4330        $ commentnew  Comment ();
4431        $ commentsetUser ($ user
32+         $ commentsetMessage ('' );
33+         $ commentsetTag (null );
4534        $ commentsetReview ($ review
46-         $ commentsetFilePath (Assert::notNull ($ lineReferenceoldPath  ?? $ lineReferencenewPath ));
47-         $ commentsetLineReference ($ lineReference
48-         $ commentsetMessage ($ data'message ' ]);
4935        $ commentsetCreateTimestamp (time ());
5036        $ commentsetUpdateTimestamp (time ());
5137
38+         $ form$ this createForm (AddCommentFormType::class, $ comment'review '  => $ review
39+         $ formhandleRequest ($ request
40+         if  ($ formisSubmitted () === false  || $ formisValid () === false ) {
41+             return  $ this json (['success '  => false ], Response::HTTP_BAD_REQUEST );
42+         }
43+ 
5244        $ this commentRepository ->save ($ commenttrue );
5345
5446        $ url$ this generateUrl (GetCommentThreadController::class, ['id '  => (int )$ commentgetId ()]);
0 commit comments