Applied StyleCI changes

This commit is contained in:
Dan Brown 2022-07-17 10:32:16 +01:00
parent e6e6d25974
commit 9cf05944f6
No known key found for this signature in database
GPG Key ID: 46D9F943C24A2EF9
7 changed files with 11 additions and 12 deletions

View 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,
];
}
}
}

View 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()

View File

@ -10,4 +10,4 @@ class SimpleEntityData
public int $owned_by;
public ?int $book_id;
public ?int $chapter_id;
}
}

View File

@ -21,7 +21,6 @@ use SplObjectStorage;
class SearchRunner
{
protected EntityProvider $entityProvider;
protected PermissionApplicator $permissions;

View 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

View 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);

View 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;