@@ -27,6 +27,8 @@ class Card extends AbstractObject implements CardInterface
27
27
);
28
28
29
29
protected $ newChecklists = array ();
30
+ protected $ newComments = array ();
31
+ protected $ commentsToBeRemoved = array ();
30
32
31
33
/**
32
34
* {@inheritdoc}
@@ -778,22 +780,29 @@ public function getDateOfLastActivity()
778
780
/**
779
781
* {@inheritdoc}
780
782
*/
781
- public function getActions ($ params = array ()) {
783
+ public function getActions ($ params = array ())
784
+ {
782
785
return $ this ->api ->actions ()->all ($ this ->id , $ params );
783
786
}
784
-
787
+
785
788
/**
786
789
* {@inheritdoc}
787
790
*/
788
- public function addComment ($ text ) {
789
- return $ this ->api ->actions ()->addComment ($ this ->id , $ text );
791
+ public function addComment ($ text )
792
+ {
793
+ $ this ->newComments [] = $ text ;
794
+
795
+ return $ this ;
790
796
}
791
797
792
798
/**
793
799
* {@inheritdoc}
794
800
*/
795
- public function removeComment ($ commentId ) {
796
- return $ this ->api ->actions ()->removeComment ($ this ->id , $ commentId );
801
+ public function removeComment ($ commentId )
802
+ {
803
+ $ this ->commentsToBeRemoved [] = $ commentId ;
804
+
805
+ return $ this ;
797
806
}
798
807
799
808
/**
@@ -806,4 +815,20 @@ protected function preSave()
806
815
$ this ->addChecklist ($ checklist );
807
816
}
808
817
}
818
+
819
+ /**
820
+ * {@inheritdoc}
821
+ */
822
+ protected function postSave ()
823
+ {
824
+ foreach ($ this ->newComments as $ key => $ text ) {
825
+ $ this ->api ->actions ()->addComment ($ this ->id , $ text );
826
+ unset($ this ->newComments [$ key ]);
827
+ }
828
+
829
+ foreach ($ this ->commentsToBeRemoved as $ key => $ commentId ) {
830
+ $ this ->api ->actions ()->removeComment ($ this ->id , $ commentId );
831
+ unset($ this ->commentsToBeRemoved [$ key ]);
832
+ }
833
+ }
809
834
}
0 commit comments