Skip to content

Commit

Permalink
Add type check to Pages::changePageParent()
Browse files Browse the repository at this point in the history
  • Loading branch information
giuscris committed Mar 16, 2019
1 parent bf3acaa commit 4ae2b29
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions admin/src/Controllers/Pages.php
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,9 @@ protected function changePageId(Page $page, $id)
*/
protected function changePageParent(Page $page, $parent)
{
if (!($parent instanceof Page || $parent instanceof Site)) {
throw new InvalidArgumentException(__METHOD__ . ' accepts only instances of ' . Page::class . ' or ' . Site::class . ' as $parent argument');
}
$destination = $parent->path() . basename($page->path()) . DS;
FileSystem::moveDirectory($page->path(), $destination);
return new Page($destination);
Expand Down

0 comments on commit 4ae2b29

Please sign in to comment.