]> BookStack Code Mirror - bookstack/commitdiff
Applied latest styleCI changes
authorDan Brown <redacted>
Thu, 6 Jan 2022 12:18:11 +0000 (12:18 +0000)
committerDan Brown <redacted>
Thu, 6 Jan 2022 12:18:11 +0000 (12:18 +0000)
app/Entities/Tools/BookContents.php
app/Entities/Tools/BookSortMap.php
app/Entities/Tools/BookSortMapItem.php
app/Http/Controllers/RoleController.php
app/Http/Controllers/WebhookController.php
app/Theming/ThemeEvents.php
app/Uploads/ImageService.php
tests/Actions/WebhookManagementTest.php
tests/Entity/SortTest.php
tests/ThemeTest.php

index 99602de414034a44ca9db88a4cd47655d814254f..6f11e8cbe528f3002008f8a03d78248d0f3fdb0d 100644 (file)
@@ -119,9 +119,10 @@ class BookContents
         // Sort our changes from our map to be chapters first
         // Since they need to be process to ensure book alignment for child page changes.
         $sortMapItems = $sortMap->all();
-        usort($sortMapItems, function(BookSortMapItem $itemA, BookSortMapItem $itemB) {
+        usort($sortMapItems, function (BookSortMapItem $itemA, BookSortMapItem $itemB) {
             $aScore = $itemA->type === 'page' ? 2 : 1;
             $bScore = $itemB->type === 'page' ? 2 : 1;
+
             return $aScore - $bScore;
         });
 
@@ -167,9 +168,9 @@ class BookContents
             return;
         }
 
-        $currentParentKey =  'book:' . $model->book_id;
+        $currentParentKey = 'book:' . $model->book_id;
         if ($model instanceof Page && $model->chapter_id) {
-             $currentParentKey = 'chapter:' . $model->chapter_id;
+            $currentParentKey = 'chapter:' . $model->chapter_id;
         }
 
         $currentParent = $modelMap[$currentParentKey] ?? null;
@@ -265,6 +266,7 @@ class BookContents
 
     /**
      * Load models from the database into the given sort map.
+     *
      * @return array<string, Entity>
      */
     protected function loadModelsFromSortMap(BookSortMap $sortMap): array
@@ -272,8 +274,8 @@ class BookContents
         $modelMap = [];
         $ids = [
             'chapter' => [],
-            'page' => [],
-            'book' => [],
+            'page'    => [],
+            'book'    => [],
         ];
 
         foreach ($sortMap->all() as $sortMapItem) {
index 1ce4905f7bad6431704ee8d4511ead4001140dc2..43b25817ea3f191c24ee4c76d3d30149374b3f28 100644 (file)
@@ -41,5 +41,4 @@ class BookSortMap
 
         return $map;
     }
-
-}
\ No newline at end of file
+}
index 7fb9a1db561919ed1b663590de5a01d50695ae55..f76d87f23669001369630bc7d588f91c1923e819 100644 (file)
@@ -4,7 +4,6 @@ namespace BookStack\Entities\Tools;
 
 class BookSortMapItem
 {
-
     /**
      * @var int
      */
@@ -30,7 +29,6 @@ class BookSortMapItem
      */
     public $parentBookId;
 
-
     public function __construct(int $id, int $sort, ?int $parentChapterId, string $type, int $parentBookId)
     {
         $this->id = $id;
@@ -39,6 +37,4 @@ class BookSortMapItem
         $this->type = $type;
         $this->parentBookId = $parentBookId;
     }
-
-
-}
\ No newline at end of file
+}
index ea117c0009bcd4cbeb73e0806928aeb09b27e7ee..fee31ffbfe297a8806a9b9d12a8c310c3325418a 100644 (file)
@@ -30,6 +30,7 @@ class RoleController extends Controller
         $roles = $this->permissionsRepo->getAllRoles();
 
         $this->setPageTitle(trans('settings.roles'));
+
         return view('settings.roles.index', ['roles' => $roles]);
     }
 
@@ -51,6 +52,7 @@ class RoleController extends Controller
         }
 
         $this->setPageTitle(trans('settings.role_create'));
+
         return view('settings.roles.create', ['role' => $role]);
     }
 
@@ -85,6 +87,7 @@ class RoleController extends Controller
         }
 
         $this->setPageTitle(trans('settings.role_edit'));
+
         return view('settings.roles.edit', ['role' => $role]);
     }
 
@@ -120,6 +123,7 @@ class RoleController extends Controller
         $roles->prepend($blankRole);
 
         $this->setPageTitle(trans('settings.role_delete'));
+
         return view('settings.roles.delete', ['role' => $role, 'roles' => $roles]);
     }
 
index 1a4fa79d7b6b369bcfb9b64990e0aaba8e062d26..264921dfc39ed7743f1f58f27afe5d400196a2a9 100644 (file)
@@ -36,6 +36,7 @@ class WebhookController extends Controller
     public function create()
     {
         $this->setPageTitle(trans('settings.webhooks_create'));
+
         return view('settings.webhooks.create');
     }
 
index 7acb3fac9223dbc875ab9e354b63d95ef191052c..48073416ca6d72661685cae210623e0ea5faf53b 100644 (file)
@@ -90,8 +90,8 @@ class ThemeEvents
      * If the listener returns a non-null value, that will be used as the POST data instead
      * of the system default.
      *
-     * @param string $event
-     * @param \BookStack\Actions\Webhook $webhook
+     * @param string                                $event
+     * @param \BookStack\Actions\Webhook            $webhook
      * @param string|\BookStack\Interfaces\Loggable $detail
      */
     const WEBHOOK_CALL_BEFORE = 'webhook_call_before';
index 7243feeb0ec0fa1c23cad6fced69015e90d6fc4d..e755be7e6e7c261adfd8e49ef1d344957983013f 100644 (file)
@@ -3,7 +3,6 @@
 namespace BookStack\Uploads;
 
 use BookStack\Exceptions\ImageUploadException;
-use BookStack\Util\WebSafeMimeSniffer;
 use ErrorException;
 use Exception;
 use Illuminate\Contracts\Cache\Repository as Cache;
@@ -240,6 +239,7 @@ class ImageService
         }
 
         $initialHeader = substr($imageData, 0, strpos($imageData, 'IDAT'));
+
         return strpos($initialHeader, 'acTL') !== false;
     }
 
@@ -274,6 +274,7 @@ class ImageService
         $storage = $this->getStorageDisk($image->type);
         if ($storage->exists($this->adjustPathForStorageDisk($thumbFilePath, $image->type))) {
             $this->cache->put($thumbCacheKey, $thumbFilePath, 60 * 60 * 72);
+
             return $this->getPublicUrl($thumbFilePath);
         }
 
@@ -282,6 +283,7 @@ class ImageService
         // Do not resize apng images where we're not cropping
         if ($keepRatio && $this->isApngData($image, $imageData)) {
             $this->cache->put($thumbCacheKey, $image->path, 60 * 60 * 72);
+
             return $this->getPublicUrl($image->path);
         }
 
index 6eb32871411776e3ebb8f749353fa6d9929aca5d..1fbf9b7a962fcd71c3b8898ecd6bcecb35d2abd8 100644 (file)
@@ -84,7 +84,7 @@ class WebhookManagementTest extends TestCase
             'endpoint' => 'https://example.com/updated-webhook',
             'events'   => [ActivityType::PAGE_CREATE, ActivityType::PAGE_UPDATE],
             'active'   => 'true',
-            'timeout'  => 5
+            'timeout'  => 5,
         ]);
         $resp->assertRedirect('/settings/webhooks');
 
index 9ff75e7000ccc78762b9be14a10e7d5036e9c7e8..7b10278b06c8f422015af0630fcf5473a6caaa68 100644 (file)
@@ -264,20 +264,20 @@ class SortTest extends TestCase
         // Create request data
         $reqData = [
             [
-                'id' => $chapterToMove->id,
-                'sort' => 0,
+                'id'            => $chapterToMove->id,
+                'sort'          => 0,
                 'parentChapter' => false,
-                'type' => 'chapter',
-                'book' => $newBook->id,
+                'type'          => 'chapter',
+                'book'          => $newBook->id,
             ],
         ];
         foreach ($pagesToMove as $index => $page) {
             $reqData[] = [
-                'id' => $page->id,
-                'sort' => $index,
+                'id'            => $page->id,
+                'sort'          => $index,
                 'parentChapter' => $index === count($pagesToMove) - 1 ? $chapterToMove->id : false,
-                'type' => 'page',
-                'book' => $newBook->id,
+                'type'          => 'page',
+                'book'          => $newBook->id,
             ];
         }
 
@@ -285,8 +285,8 @@ class SortTest extends TestCase
         $sortResp->assertRedirect($newBook->getUrl());
         $sortResp->assertStatus(302);
         $this->assertDatabaseHas('chapters', [
-            'id' => $chapterToMove->id,
-            'book_id' => $newBook->id,
+            'id'       => $chapterToMove->id,
+            'book_id'  => $newBook->id,
             'priority' => 0,
         ]);
         $this->assertTrue($newBook->chapters()->count() === 1);
@@ -304,11 +304,11 @@ class SortTest extends TestCase
         $otherChapter = Chapter::query()->where('book_id', '!=', $page->book_id)->first();
 
         $sortData = [
-            'id' => $page->id,
-            'sort' => 0,
+            'id'            => $page->id,
+            'sort'          => 0,
             'parentChapter' => $otherChapter->id,
-            'type' => 'page',
-            'book' => $page->book_id,
+            'type'          => 'page',
+            'book'          => $page->book_id,
         ];
         $this->asEditor()->put($page->book->getUrl('/sort'), ['sort-tree' => json_encode([$sortData])])->assertRedirect();
 
@@ -326,11 +326,11 @@ class SortTest extends TestCase
         $this->setEntityRestrictions($otherChapter);
 
         $sortData = [
-            'id' => $page->id,
-            'sort' => 0,
+            'id'            => $page->id,
+            'sort'          => 0,
             'parentChapter' => $otherChapter->id,
-            'type' => 'page',
-            'book' => $otherChapter->book_id,
+            'type'          => 'page',
+            'book'          => $otherChapter->book_id,
         ];
         $this->asEditor()->put($page->book->getUrl('/sort'), ['sort-tree' => json_encode([$sortData])])->assertRedirect();
 
@@ -349,11 +349,11 @@ class SortTest extends TestCase
         $this->setEntityRestrictions($otherChapter->book, ['update', 'delete'], [$editor->roles()->first()]);
 
         $sortData = [
-            'id' => $page->id,
-            'sort' => 0,
+            'id'            => $page->id,
+            'sort'          => 0,
             'parentChapter' => $otherChapter->id,
-            'type' => 'page',
-            'book' => $otherChapter->book_id,
+            'type'          => 'page',
+            'book'          => $otherChapter->book_id,
         ];
         $this->actingAs($editor)->put($page->book->getUrl('/sort'), ['sort-tree' => json_encode([$sortData])])->assertRedirect();
 
@@ -372,11 +372,11 @@ class SortTest extends TestCase
         $this->setEntityRestrictions($otherChapter, ['view', 'delete'], [$editor->roles()->first()]);
 
         $sortData = [
-            'id' => $page->id,
-            'sort' => 0,
+            'id'            => $page->id,
+            'sort'          => 0,
             'parentChapter' => $otherChapter->id,
-            'type' => 'page',
-            'book' => $otherChapter->book_id,
+            'type'          => 'page',
+            'book'          => $otherChapter->book_id,
         ];
         $this->actingAs($editor)->put($page->book->getUrl('/sort'), ['sort-tree' => json_encode([$sortData])])->assertRedirect();
 
@@ -395,11 +395,11 @@ class SortTest extends TestCase
         $this->setEntityRestrictions($page, ['view', 'delete'], [$editor->roles()->first()]);
 
         $sortData = [
-            'id' => $page->id,
-            'sort' => 0,
+            'id'            => $page->id,
+            'sort'          => 0,
             'parentChapter' => $otherChapter->id,
-            'type' => 'page',
-            'book' => $otherChapter->book_id,
+            'type'          => 'page',
+            'book'          => $otherChapter->book_id,
         ];
         $this->actingAs($editor)->put($page->book->getUrl('/sort'), ['sort-tree' => json_encode([$sortData])])->assertRedirect();
 
@@ -418,11 +418,11 @@ class SortTest extends TestCase
         $this->setEntityRestrictions($page, ['view', 'update'], [$editor->roles()->first()]);
 
         $sortData = [
-            'id' => $page->id,
-            'sort' => 0,
+            'id'            => $page->id,
+            'sort'          => 0,
             'parentChapter' => $otherChapter->id,
-            'type' => 'page',
-            'book' => $otherChapter->book_id,
+            'type'          => 'page',
+            'book'          => $otherChapter->book_id,
         ];
         $this->actingAs($editor)->put($page->book->getUrl('/sort'), ['sort-tree' => json_encode([$sortData])])->assertRedirect();
 
@@ -431,7 +431,6 @@ class SortTest extends TestCase
         ]);
     }
 
-
     public function test_book_sort_item_returns_book_content()
     {
         $books = Book::all();
index fe816255997b638d0233c6c175ba642734083e6a..775be92fc371379186f3bfad71f7fa41d80a178e 100644 (file)
@@ -170,6 +170,7 @@ class ThemeTest extends TestCase
         $args = [];
         $callback = function (...$eventArgs) use (&$args) {
             $args = $eventArgs;
+
             return ['test' => 'hello!'];
         };
         Theme::listen(ThemeEvents::WEBHOOK_CALL_BEFORE, $callback);