]> BookStack Code Mirror - bookstack/commitdiff
Updated PR code to use isA and updated that function definition
authorDan Brown <redacted>
Sat, 26 Sep 2020 16:00:17 +0000 (17:00 +0100)
committerDan Brown <redacted>
Sat, 26 Sep 2020 16:00:17 +0000 (17:00 +0100)
Related to #2227

app/Entities/Entity.php
app/Entities/Managers/BookContents.php

index 120290d8ff12317529bd9d60d05519189098d0c8..cc7df46d4f653e201f9ba17c72a09c0b45046577 100644 (file)
@@ -201,12 +201,10 @@ class Entity extends Ownable
     }
 
     /**
-     * Allows checking of the exact class, Used to check entity type.
-     * Cleaner method for is_a.
-     * @param $type
-     * @return bool
+     * Check if this instance or class is a certain type of entity.
+     * Examples of $type are 'page', 'book', 'chapter'
      */
-    public static function isA($type)
+    public static function isA(string $type): bool
     {
         return static::getType() === strtolower($type);
     }
index 779a9292b404d169f9aa893ab29f892dd8613737..52447e43bf0b397d4c69782fed8453793e3a13bf 100644 (file)
@@ -62,7 +62,7 @@ class BookContents
         $all->each(function (Entity $entity) use ($renderPages) {
             $entity->setRelation('book', $this->book);
 
-            if ($renderPages && get_class($entity) == 'BookStack\Entities\Page') {
+            if ($renderPages && $entity->isA('page')) {
                 $entity->html = (new PageContent($entity))->render();
             }
         });