]> BookStack Code Mirror - bookstack/commitdiff
Removed "isA" usages from trashcan
authorDan Brown <redacted>
Sat, 6 Feb 2021 13:29:39 +0000 (13:29 +0000)
committerDan Brown <redacted>
Sat, 6 Feb 2021 13:29:39 +0000 (13:29 +0000)
app/Entities/Tools/TrashCan.php

index 7be432f4c5df14b7066d5bcacdde90dd90c6fe04..df98fd318fd89e1b0d82b897cbcd038a97a4e1a3 100644 (file)
@@ -273,11 +273,11 @@ class TrashCan
             $count++;
         };
 
-        if ($entity->isA('chapter') || $entity->isA('book')) {
+        if ($entity instanceof Chapter || $entity instanceof Book) {
             $entity->pages()->withTrashed()->withCount('deletions')->get()->each($restoreAction);
         }
 
-        if ($entity->isA('book')) {
+        if ($entity instanceof Book) {
             $entity->chapters()->withTrashed()->withCount('deletions')->get()->each($restoreAction);
         }
 
@@ -286,19 +286,20 @@ class TrashCan
 
     /**
      * Destroy the given entity.
+     * @throws Exception
      */
     protected function destroyEntity(Entity $entity): int
     {
-        if ($entity->isA('page')) {
+        if ($entity instanceof Page) {
             return $this->destroyPage($entity);
         }
-        if ($entity->isA('chapter')) {
+        if ($entity instanceof Chapter) {
             return $this->destroyChapter($entity);
         }
-        if ($entity->isA('book')) {
+        if ($entity instanceof Book) {
             return $this->destroyBook($entity);
         }
-        if ($entity->isA('bookshelf')) {
+        if ($entity instanceof Bookshelf) {
             return $this->destroyShelf($entity);
         }
     }