@@ -178,21 +178,16 @@ public function save(?Content $originalContent = null, ?ContentValidatorInterfac
178
178
179
179
// check for status changes
180
180
if ($ originalContent !== null ) {
181
- // deny if we detect the status field being changed
182
- if ($ originalStatus !== $ content ->getStatus () ) {
183
- $ this ->denyAccessUnlessGranted (ContentVoter::CONTENT_CHANGE_STATUS , $ content );
181
+ // revert the propery change if the current user dont have right
182
+ if ($ this ->isGranted (ContentVoter::CONTENT_CHANGE_STATUS , $ content ) === false ) {
183
+ $ content ->setStatus ($ originalStatus );
184
+ $ content ->setPublishedAt ($ originalPublishedAt );
185
+ $ content ->setDepublishedAt ($ originalDepublishedAt );
184
186
}
185
187
186
- // deny if we detect the publication dates field being changed
187
- if (($ originalPublishedAt !== null && Date::datesDiffer ($ originalPublishedAt , $ content ->getPublishedAt ())) ||
188
- ($ originalDepublishedAt !== null && Date::datesDiffer ($ originalDepublishedAt , $ content ->getDepublishedAt ()))
189
- ) {
190
- $ this ->denyAccessUnlessGranted (ContentVoter::CONTENT_CHANGE_STATUS , $ content );
191
- }
192
-
193
- // deny if owner changes
194
- if ($ originalAuthor !== $ content ->getAuthor ()) {
195
- $ this ->denyAccessUnlessGranted (ContentVoter::CONTENT_CHANGE_OWNERSHIP , $ content );
188
+ // revert the owner property if the current user dont have right
189
+ if ($ this ->isGranted (ContentVoter::CONTENT_CHANGE_OWNERSHIP , $ content ) === false ) {
190
+ $ content ->setAuthor ($ originalAuthor );
196
191
}
197
192
}
198
193
0 commit comments