@@ -37,7 +37,7 @@ public function create(CreateArticleDTO $data): Article
3737
3838 $ authorId = $ data ->authorId
3939 ? AuthorId::fromInt ($ data ->authorId )
40- : AuthorId:: fromInt ( $ this ->currentUserGateway ->getId ()-> getValue () );
40+ : $ this ->currentUserGateway ->getCurrentAuthorId ( );
4141
4242 $ article = match ($ data ->status ) {
4343 'draft ' => $ this ->createDraft ($ data , $ authorId ),
@@ -81,6 +81,10 @@ private function createPublished(CreateArticleDTO $data, AuthorId $authorId): Ar
8181
8282 public function publishDraft (int $ id ): void
8383 {
84+ CompositePolicy::allOf ([
85+ new GlobalPermissionPolicy ('publish_article ' ),
86+ ])->check ();
87+
8488 $ article = $ this ->repository ->getById (ArticleId::fromInt ($ id ));
8589 $ article ->publish ();
8690
@@ -101,6 +105,10 @@ public function getArticleList(GetArticleListDTO $data): LengthAwarePaginator
101105
102106 public function updateArticle (int $ id , UpdateArticleDTO $ data ): Article
103107 {
108+ CompositePolicy::allOf ([
109+ new GlobalPermissionPolicy ('publish_article ' ),
110+ ])->check ();
111+
104112 $ article = $ this ->repository ->getById (ArticleId::fromInt ($ id ));
105113 $ article ->revise (
106114 $ data ->title ,
@@ -120,6 +128,10 @@ public function updateArticle(int $id, UpdateArticleDTO $data): Article
120128
121129 public function archiveArticle (int $ id )
122130 {
131+ CompositePolicy::allOf ([
132+ new GlobalPermissionPolicy ('publish_article ' ),
133+ ])->check ();
134+
123135 $ article = $ this ->repository ->getById (ArticleId::fromInt ($ id ));
124136
125137 $ article ->archive ();
@@ -130,6 +142,10 @@ public function archiveArticle(int $id)
130142
131143 public function deleteArticle (int $ id )
132144 {
145+ CompositePolicy::allOf ([
146+ new GlobalPermissionPolicy ('publish_article ' ),
147+ ])->check ();
148+
133149 $ article = $ this ->repository ->getById (ArticleId::fromInt ($ id ));
134150 $ article ->delete ();
135151
0 commit comments