1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-08-07 23:03:00 +03:00

Applied StyleCI changes

This commit is contained in:
Dan Brown
2022-07-17 10:32:16 +01:00
parent e6e6d25974
commit 9cf05944f6
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