]> BookStack Code Mirror - bookstack/commitdiff
Applied StyleCI changes 3569/head
authorDan Brown <redacted>
Sun, 17 Jul 2022 09:32:16 +0000 (10:32 +0100)
committerDan Brown <redacted>
Sun, 17 Jul 2022 09:32:16 +0000 (10:32 +0100)
app/Auth/Permissions/JointPermissionBuilder.php
app/Auth/Permissions/PermissionApplicator.php
app/Auth/Permissions/SimpleEntityData.php
app/Entities/Tools/SearchRunner.php
app/Providers/CustomFacadeProvider.php
tests/Entity/EntitySearchTest.php
tests/SharedTestHelpers.php

index 9ee09a3a635110112669c32d0f57efe0a20b18dd..f377eef5ce55057fae0278bb0a9b6febb79511d5 100644 (file)
@@ -148,7 +148,6 @@ class JointPermissionBuilder
             ]);
     }
 
-
     /**
      * Build joint permissions for the given book and role combinations.
      */
@@ -207,6 +206,7 @@ class JointPermissionBuilder
 
     /**
      * @param Entity[] $entities
+     *
      * @return SimpleEntityData[]
      */
     protected function entitiesToSimpleEntities(array $entities): array
@@ -288,7 +288,9 @@ class JointPermissionBuilder
     /**
      * From the given entity list, provide back a mapping of entity types to
      * the ids of that given type. The type used is the DB morph class.
+     *
      * @param SimpleEntityData[] $entities
+     *
      * @return array<string, int[]>
      */
     protected function entitiesToTypeIdMap(array $entities): array
@@ -307,8 +309,10 @@ class JointPermissionBuilder
     }
 
     /**
-     * Get the entity permissions for all the given entities
+     * Get the entity permissions for all the given entities.
+     *
      * @param SimpleEntityData[] $entities
+     *
      * @return EntityPermission[]
      */
     protected function getEntityPermissionsForEntities(array $entities): array
@@ -316,7 +320,7 @@ class JointPermissionBuilder
         $idsByType = $this->entitiesToTypeIdMap($entities);
         $permissionFetch = EntityPermission::query()
             ->where('action', '=', 'view')
-            ->where(function(Builder $query) use ($idsByType) {
+            ->where(function (Builder $query) use ($idsByType) {
                 foreach ($idsByType as $type => $ids) {
                     $query->orWhere(function (Builder $query) use ($type, $ids) {
                         $query->where('restrictable_type', '=', $type)->whereIn('restrictable_id', $ids);
@@ -398,5 +402,4 @@ class JointPermissionBuilder
             'role_id'            => $roleId,
         ];
     }
-
-}
\ No newline at end of file
+}
index b89857c5c3c773560ad5d82e6fe3d0802daf32e4..d855a6170616f0fbf4974d240b04e88866f4046a 100644 (file)
@@ -86,7 +86,7 @@ class PermissionApplicator
     public function checkUserHasEntityPermissionOnAny(string $action, string $entityClass = ''): bool
     {
         if (strpos($action, '-') !== false) {
-            throw new InvalidArgumentException("Action should be a simple entity permission action, not a role permission");
+            throw new InvalidArgumentException('Action should be a simple entity permission action, not a role permission');
         }
 
         $permissionQuery = EntityPermission::query()
index 0d1c94b0dd2f6df1b499a964491f55bbe7a0302a..6ec0c4179ed4529f98e945f256803d4d417f3c91 100644 (file)
@@ -10,4 +10,4 @@ class SimpleEntityData
     public int $owned_by;
     public ?int $book_id;
     public ?int $chapter_id;
-}
\ No newline at end of file
+}
index 4594090847e9bad44c89d5b98ad4a7bc7247c40b..78659b7864565d6d1f6edfeb0e843aecb0ba0678 100644 (file)
@@ -21,7 +21,6 @@ use SplObjectStorage;
 
 class SearchRunner
 {
-
     protected EntityProvider $entityProvider;
     protected PermissionApplicator $permissions;
 
index 04de822505136fc861e88bac941f2d035c2c46ba..6ba5632e6506766c5e8501b669720cf950bc29ae 100644 (file)
@@ -3,9 +3,7 @@
 namespace BookStack\Providers;
 
 use BookStack\Actions\ActivityLogger;
-use BookStack\Auth\Permissions\PermissionApplicator;
 use BookStack\Theming\ThemeService;
-use BookStack\Uploads\ImageService;
 use Illuminate\Support\ServiceProvider;
 
 class CustomFacadeProvider extends ServiceProvider
index 55c54695eaed73522b3f8aff70e60f76a4171fef..a23a2fd26d8fe39dad85d87584230be1ff400348 100644 (file)
@@ -234,7 +234,7 @@ class EntitySearchTest extends TestCase
     {
         $page = Page::query()->first();
         $baseSelector = 'a[data-entity-type="page"][data-entity-id="' . $page->id . '"]';
-        $searchUrl = "/ajax/search/entities?permission=update&term=" . urlencode($page->name);
+        $searchUrl = '/ajax/search/entities?permission=update&term=' . urlencode($page->name);
 
         $resp = $this->asEditor()->get($searchUrl);
         $resp->assertElementContains($baseSelector, $page->name);
index 99bc92494dba2c12fd8203fbe8806ae7bbfdbcb8..bc7b10266b06cfe9bc4fc0a78f2adefcfe920277 100644 (file)
@@ -3,7 +3,6 @@
 namespace Tests;
 
 use BookStack\Auth\Permissions\JointPermissionBuilder;
-use BookStack\Auth\Permissions\PermissionApplicator;
 use BookStack\Auth\Permissions\PermissionsRepo;
 use BookStack\Auth\Permissions\RolePermission;
 use BookStack\Auth\Role;
Morty Proxy This is a proxified and sanitized view of the page, visit original site.