Skip to content

Commit 7f5688a

Browse files
Handle state updates in the ModelWithContent::save method
1 parent 43ca5b0 commit 7f5688a

File tree

3 files changed

+6
-40
lines changed

3 files changed

+6
-40
lines changed

src/Cms/FileActions.php

-20
Original file line numberDiff line numberDiff line change
@@ -400,26 +400,6 @@ public function replace(string $source, bool $move = false): static
400400
});
401401
}
402402

403-
/**
404-
* Stores the content on disk
405-
* @internal
406-
*/
407-
public function save(
408-
array|null $data = null,
409-
string|null $languageCode = null,
410-
bool $overwrite = false
411-
): static {
412-
$file = parent::save($data, $languageCode, $overwrite);
413-
414-
ModelState::update(
415-
method: 'set',
416-
current: $this,
417-
next: $file
418-
);
419-
420-
return $file;
421-
}
422-
423403
/**
424404
* Remove all public versions of this file
425405
*

src/Cms/ModelWithContent.php

+6
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,12 @@ public function save(
452452
$overwrite
453453
);
454454

455+
ModelState::update(
456+
method: 'set',
457+
current: $this,
458+
next: $clone
459+
);
460+
455461
return $clone;
456462
}
457463

src/Cms/PageActions.php

-20
Original file line numberDiff line numberDiff line change
@@ -808,26 +808,6 @@ public function resortSiblingsAfterUnlisting(): bool
808808
return true;
809809
}
810810

811-
/**
812-
* Stores the content on disk
813-
* @internal
814-
*/
815-
public function save(
816-
array|null $data = null,
817-
string|null $languageCode = null,
818-
bool $overwrite = false
819-
): static {
820-
$page = parent::save($data, $languageCode, $overwrite);
821-
822-
ModelState::update(
823-
method: 'set',
824-
current: $this,
825-
next: $page
826-
);
827-
828-
return $page;
829-
}
830-
831811
/**
832812
* Convert a page from listed or
833813
* unlisted to draft.

0 commit comments

Comments
 (0)