]> BookStack Code Mirror - bookstack/blobdiff - app/Entities/Tools/SiblingFetcher.php
Fixed failing test after drawio default url change
[bookstack] / app / Entities / Tools / SiblingFetcher.php
index 6964fa2e62419e111531cfbb006c008cfc6fb8a0..617ef4a620df810f9369e8fd8f6e49abed461304 100644 (file)
@@ -1,35 +1,38 @@
-<?php namespace BookStack\Entities\Tools;
+<?php
+
+namespace BookStack\Entities\Tools;
 
 use BookStack\Entities\EntityProvider;
 use BookStack\Entities\Models\Book;
 use BookStack\Entities\Models\Bookshelf;
+use BookStack\Entities\Models\Chapter;
+use BookStack\Entities\Models\Page;
 use Illuminate\Support\Collection;
 
 class SiblingFetcher
 {
-
     /**
      * Search among the siblings of the entity of given type and id.
      */
     public function fetch(string $entityType, int $entityId): Collection
     {
-        $entity = (new EntityProvider)->get($entityType)->visible()->findOrFail($entityId);
+        $entity = (new EntityProvider())->get($entityType)->visible()->findOrFail($entityId);
         $entities = [];
 
         // Page in chapter
-        if ($entity->isA('page') && $entity->chapter) {
+        if ($entity instanceof Page && $entity->chapter) {
             $entities = $entity->chapter->getVisiblePages();
         }
 
         // Page in book or chapter
-        if (($entity->isA('page') && !$entity->chapter) || $entity->isA('chapter')) {
+        if (($entity instanceof Page && !$entity->chapter) || $entity instanceof Chapter) {
             $entities = $entity->book->getDirectChildren();
         }
 
         // Book
         // Gets just the books in a shelf if shelf is in context
-        if ($entity->isA('book')) {
-            $contextShelf = (new ShelfContext)->getContextualShelfForBook($entity);
+        if ($entity instanceof Book) {
+            $contextShelf = (new ShelfContext())->getContextualShelfForBook($entity);
             if ($contextShelf) {
                 $entities = $contextShelf->visibleBooks()->get();
             } else {
@@ -37,8 +40,8 @@ class SiblingFetcher
             }
         }
 
-        // Shelve
-        if ($entity->isA('bookshelf')) {
+        // Shelf
+        if ($entity instanceof Bookshelf) {
             $entities = Bookshelf::visible()->get();
         }