]);
}
-
/**
* Build joint permissions for the given book and role combinations.
*/
/**
* @param Entity[] $entities
+ *
* @return SimpleEntityData[]
*/
protected function entitiesToSimpleEntities(array $entities): array
/**
* 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
}
/**
- * 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
$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);
'role_id' => $roleId,
];
}
-
-}
\ No newline at end of file
+}
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()
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
{
$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);