1 | <?php |
||||
2 | |||||
3 | namespace OCA\FaceRecognition\Settings; |
||||
4 | |||||
5 | use OCA\Viewer\Event\LoadViewer; |
||||
0 ignored issues
–
show
|
|||||
6 | |||||
7 | use OCP\EventDispatcher\IEventDispatcher; |
||||
8 | use OCP\AppFramework\Http\TemplateResponse; |
||||
9 | use OCP\AppFramework\Services\IInitialState; |
||||
10 | use OCP\Settings\ISettings; |
||||
11 | |||||
12 | use OCA\FaceRecognition\Db\Person; |
||||
13 | use OCA\FaceRecognition\Db\PersonMapper; |
||||
14 | |||||
15 | use OCA\FaceRecognition\Service\SettingsService; |
||||
16 | |||||
17 | class Personal implements ISettings { |
||||
18 | |||||
19 | /** @var IEventDispatcher */ |
||||
20 | private $eventDispatcher; |
||||
21 | |||||
22 | /** @var \OCP\AppFramework\Services\IInitialState **/ |
||||
23 | protected IInitialState $initialState; |
||||
24 | |||||
25 | /** @var PersonMapper */ |
||||
26 | protected $personMapper; |
||||
27 | |||||
28 | /** @var SettingsService */ |
||||
29 | protected $settingsService; |
||||
30 | |||||
31 | protected ?string $userId; |
||||
32 | |||||
33 | public function __construct(IEventDispatcher $eventDispatcher, |
||||
34 | IInitialState $initialState, |
||||
35 | PersonMapper $personmapper, |
||||
36 | SettingsService $settingsService, |
||||
37 | string $userId) |
||||
38 | { |
||||
39 | $this->eventDispatcher = $eventDispatcher; |
||||
40 | $this->initialState = $initialState; |
||||
41 | $this->personMapper = $personmapper; |
||||
42 | $this->settingsService = $settingsService; |
||||
43 | $this->userId = $userId; |
||||
44 | } |
||||
45 | |||||
46 | public function getPriority() |
||||
47 | { |
||||
48 | return 20; |
||||
49 | } |
||||
50 | |||||
51 | public function getSection() |
||||
52 | { |
||||
53 | return 'facerecognition'; |
||||
54 | } |
||||
55 | |||||
56 | public function getSectionID(): string |
||||
57 | { |
||||
58 | return 'facerecognition'; |
||||
59 | } |
||||
60 | |||||
61 | public function getForm() |
||||
62 | { |
||||
63 | $userEnabled = $this->settingsService->getUserEnabled($this->userId); |
||||
64 | $unamedCount = 0; |
||||
65 | $hiddenCount = 0; |
||||
66 | |||||
67 | if ($userEnabled) { |
||||
68 | $modelId = $this->settingsService->getCurrentFaceModel(); |
||||
69 | $minClusterSize = $this->settingsService->getMinimumFacesInCluster(); |
||||
70 | |||||
71 | $clusters = $this->personMapper->findUnassigned($this->userId, $modelId); |
||||
0 ignored issues
–
show
It seems like
$this->userId can also be of type null ; however, parameter $userId of OCA\FaceRecognition\Db\P...apper::findUnassigned() does only seem to accept string , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
72 | foreach ($clusters as $cluster) { |
||||
73 | $clusterSize = $this->personMapper->countClusterFaces($cluster->getId()); |
||||
74 | if ($clusterSize >= $minClusterSize) |
||||
75 | $unamedCount++; |
||||
76 | } |
||||
77 | |||||
78 | $clusters = $this->personMapper->findIgnored($this->userId, $modelId); |
||||
0 ignored issues
–
show
It seems like
$this->userId can also be of type null ; however, parameter $userId of OCA\FaceRecognition\Db\PersonMapper::findIgnored() does only seem to accept string , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
79 | foreach ($clusters as $cluster) { |
||||
80 | $clusterSize = $this->personMapper->countClusterFaces($cluster->getId()); |
||||
81 | if ($clusterSize >= $minClusterSize) |
||||
82 | $hiddenCount++; |
||||
83 | } |
||||
84 | } |
||||
85 | |||||
86 | $this->initialState->provideInitialState('user-enabled', $userEnabled); |
||||
87 | $this->initialState->provideInitialState('has-unamed', $unamedCount > 0); |
||||
88 | $this->initialState->provideInitialState('has-hidden', $hiddenCount > 0); |
||||
89 | |||||
90 | $this->eventDispatcher->dispatch(LoadViewer::class, new LoadViewer()); |
||||
0 ignored issues
–
show
The function
OCP\EventDispatcher\IEventDispatcher::dispatch() has been deprecated: 21.0.0 use \OCP\EventDispatcher\IEventDispatcher::dispatchTyped
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This function has been deprecated. The supplier of the function has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead. ![]() |
|||||
91 | return new TemplateResponse('facerecognition', 'settings/personal'); |
||||
92 | } |
||||
93 | |||||
94 | public function getPanel(): TemplateResponse |
||||
95 | { |
||||
96 | return $this->getForm(); |
||||
97 | } |
||||
98 | |||||
99 | } |
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