|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Module\User\ListPage\Service; |
|
4
|
|
|
|
|
5
|
|
|
use App\Infrastructure\Database\Hydrator; |
|
6
|
|
|
use App\Module\User\Authorization\Service\UserPrivilegeDeterminer; |
|
|
|
|
|
|
7
|
|
|
use App\Module\User\Data\UserResultData; |
|
8
|
|
|
use App\Module\User\FindDropdownOptions\Service\AuthorizedUserRoleFilterer; |
|
|
|
|
|
|
9
|
|
|
use App\Module\User\FindList\Repository\UserListFinderRepository; |
|
10
|
|
|
use App\Module\User\Read\Service\UserReadAuthorizationChecker; |
|
11
|
|
|
|
|
12
|
|
|
// Class cannot be readonly as it's mocked (doubled) in tests |
|
13
|
|
|
class UserListPageFinder |
|
14
|
|
|
{ |
|
15
|
4 |
|
public function __construct( |
|
16
|
|
|
private readonly UserListFinderRepository $userListFinderRepository, |
|
17
|
|
|
private readonly UserPrivilegeDeterminer $userPrivilegeDeterminer, |
|
18
|
|
|
private readonly AuthorizedUserRoleFilterer $authorizedUserRoleFilterer, |
|
19
|
|
|
private readonly UserReadAuthorizationChecker $userReadAuthorizationChecker, |
|
20
|
|
|
private readonly Hydrator $hydrator, |
|
21
|
|
|
) { |
|
22
|
4 |
|
} |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @return UserResultData[] |
|
26
|
|
|
*/ |
|
27
|
4 |
|
public function findAllUsersResultDataForList(): array |
|
28
|
|
|
{ |
|
29
|
4 |
|
$userResultArray = $this->hydrator->hydrate( |
|
30
|
4 |
|
$this->userListFinderRepository->findAllUserRows(), |
|
31
|
4 |
|
UserResultData::class |
|
32
|
4 |
|
); |
|
33
|
|
|
|
|
34
|
4 |
|
foreach ($userResultArray as $key => $userResultData) { |
|
35
|
|
|
// Check if authenticated user is allowed to read user |
|
36
|
4 |
|
if ($this->userReadAuthorizationChecker->isGrantedToRead($userResultData->id)) { |
|
37
|
|
|
// Authorization limits which entries are in the user role dropdown |
|
38
|
4 |
|
$userResultData->availableUserRoles = $this->authorizedUserRoleFilterer->filterAuthorizedUserRoles( |
|
39
|
4 |
|
$userResultData->userRoleId |
|
40
|
4 |
|
); |
|
41
|
4 |
|
$userResultData->userRolePrivilege = $this->userPrivilegeDeterminer->getUserRoleAssignmentPrivilege( |
|
42
|
4 |
|
$userResultData->availableUserRoles |
|
43
|
4 |
|
); |
|
44
|
|
|
|
|
45
|
|
|
// Check if user is allowed to change status |
|
46
|
4 |
|
$userResultData->statusPrivilege = $this->userPrivilegeDeterminer->getMutationPrivilege( |
|
47
|
4 |
|
(int)$userResultData->id, |
|
48
|
4 |
|
'status', |
|
49
|
4 |
|
); |
|
50
|
|
|
} else { |
|
51
|
1 |
|
unset($userResultArray[$key]); |
|
52
|
|
|
} |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
4 |
|
return $userResultArray; |
|
56
|
|
|
} |
|
57
|
|
|
} |
|
58
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths