mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-10-01 01:36:00 -04:00
Applied StyleCI changes
This commit is contained in:
parent
e6e6d25974
commit
9cf05944f6
@ -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,
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -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()
|
||||
|
@ -10,4 +10,4 @@ class SimpleEntityData
|
||||
public int $owned_by;
|
||||
public ?int $book_id;
|
||||
public ?int $chapter_id;
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,6 @@ use SplObjectStorage;
|
||||
|
||||
class SearchRunner
|
||||
{
|
||||
|
||||
protected EntityProvider $entityProvider;
|
||||
protected PermissionApplicator $permissions;
|
||||
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user