|
1
|
|
|
<?php |
|
2
|
|
|
namespace OCA\FaceRecognition\Controller; |
|
3
|
|
|
|
|
4
|
|
|
use OCP\IRequest; |
|
5
|
|
|
use OCP\Files\IRootFolder; |
|
6
|
|
|
use OCP\AppFramework\Http; |
|
7
|
|
|
use OCP\AppFramework\Http\DataResponse; |
|
8
|
|
|
use OCP\AppFramework\Http\JSONResponse; |
|
9
|
|
|
use OCP\AppFramework\Http\DataDisplayResponse; |
|
10
|
|
|
use OCP\AppFramework\Controller; |
|
11
|
|
|
|
|
12
|
|
|
use OCA\FaceRecognition\Db\Face; |
|
13
|
|
|
use OCA\FaceRecognition\Db\FaceMapper; |
|
14
|
|
|
|
|
15
|
|
|
class PersonController extends Controller { |
|
16
|
|
|
|
|
17
|
|
|
private $rootFolder; |
|
18
|
|
|
private $faceMapper; |
|
19
|
|
|
private $userId; |
|
20
|
|
|
|
|
21
|
|
View Code Duplication |
public function __construct($AppName, IRequest $request, IRootFolder $rootFolder, FaceMapper $facemapper, $UserId) { |
|
22
|
|
|
parent::__construct($AppName, $request); |
|
23
|
|
|
$this->rootFolder = $rootFolder; |
|
24
|
|
|
$this->faceMapper = $facemapper; |
|
25
|
|
|
$this->userId = $UserId; |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @NoAdminRequired |
|
30
|
|
|
*/ |
|
31
|
|
|
public function index() { |
|
32
|
|
|
$resp = array(); |
|
33
|
|
|
$groups = $this->faceMapper->getGroups($this->userId); |
|
34
|
|
|
foreach ($groups as $group) { |
|
35
|
|
|
$resp[$group->getName()] = $this->faceMapper->findAllNamed($this->userId, $group->getName(), 12); |
|
36
|
|
|
} |
|
37
|
|
|
return new DataResponse($resp); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* @NoAdminRequired |
|
42
|
|
|
* |
|
43
|
|
|
* @param string $name |
|
44
|
|
|
*/ |
|
45
|
|
|
public function getFaces($name) { |
|
46
|
|
|
$faces = $this->faceMapper->findAllNamed($this->userId, $name); |
|
47
|
|
|
return new DataResponse($faces); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* @NoAdminRequired |
|
52
|
|
|
* |
|
53
|
|
|
* @param string $oldName |
|
|
|
|
|
|
54
|
|
|
* @param string $newName |
|
55
|
|
|
*/ |
|
56
|
|
|
public function updateName($name, $newName) { |
|
57
|
|
|
$faces = $this->faceMapper->findAllNamed($this->userId, $name); |
|
58
|
|
|
foreach ($faces as $face) { |
|
59
|
|
|
$face->setName($newName); |
|
60
|
|
|
$this->faceMapper->update($face); |
|
61
|
|
|
} |
|
62
|
|
|
$newFaces = $this->faceMapper->findAllNamed($this->userId, $newName); |
|
63
|
|
|
return new DataResponse($newFaces); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
} |
|
67
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italyis not defined by the methodfinale(...).The most likely cause is that the parameter was removed, but the annotation was not.