1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @copyright Copyright (c) 2021 Matias De lellis <[email protected]> |
4
|
|
|
* |
5
|
|
|
* @author Matias De lellis <[email protected]> |
6
|
|
|
* |
7
|
|
|
* @license AGPL-3.0 |
8
|
|
|
* |
9
|
|
|
* This code is free software: you can redistribute it and/or modify |
10
|
|
|
* it under the terms of the GNU Affero General Public License, version 3, |
11
|
|
|
* as published by the Free Software Foundation. |
12
|
|
|
* |
13
|
|
|
* This program is distributed in the hope that it will be useful, |
14
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
15
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16
|
|
|
* GNU Affero General Public License for more details. |
17
|
|
|
* |
18
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3, |
19
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/> |
20
|
|
|
* |
21
|
|
|
*/ |
22
|
|
|
namespace OCA\FaceRecognition\Dav; |
23
|
|
|
|
24
|
|
|
use OCA\FaceRecognition\AppInfo\Application; |
25
|
|
|
|
26
|
|
|
use Sabre\Xml\Writer; |
|
|
|
|
27
|
|
|
use Sabre\Xml\XmlSerializable; |
|
|
|
|
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Persons property |
31
|
|
|
* |
32
|
|
|
* This property encodes the list of 'persons' property. |
33
|
|
|
*/ |
34
|
|
|
class PersonsList implements XmlSerializable { |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* The list of persons |
38
|
|
|
* |
39
|
|
|
* @var array |
40
|
|
|
*/ |
41
|
|
|
protected $persons; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Creates the property. |
45
|
|
|
* |
46
|
|
|
* Persons is an array. Each element of the array has the following |
47
|
|
|
* properties: |
48
|
|
|
* |
49
|
|
|
* * name - Optional, name of person. |
50
|
|
|
* * id - Optional, id of person cluster. |
51
|
|
|
* * top - Top position of the face in the image |
52
|
|
|
* * left - Left position of the face in the image. |
53
|
|
|
* * width - Width of the face in the image |
54
|
|
|
* * height - Height of the face in the image. |
55
|
|
|
* |
56
|
|
|
* @param array $persons |
57
|
|
|
*/ |
58
|
|
|
public function __construct(array $persons) { |
59
|
|
|
$this->persons = $persons; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Returns the list of person, as it was passed to the constructor. |
64
|
|
|
* |
65
|
|
|
* @return array |
66
|
|
|
*/ |
67
|
|
|
public function getValue() { |
68
|
|
|
return $this->persons; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* The xmlSerialize metod is called during xml writing. |
73
|
|
|
* |
74
|
|
|
* Use the $writer argument to write its own xml serialization. |
75
|
|
|
* |
76
|
|
|
* An important note: do _not_ create a parent element. Any element |
77
|
|
|
* implementing XmlSerializble should only ever write what's considered |
78
|
|
|
* its 'inner xml'. |
79
|
|
|
* |
80
|
|
|
* The parent of the current element is responsible for writing a |
81
|
|
|
* containing element. |
82
|
|
|
* |
83
|
|
|
* This allows serializers to be re-used for different element names. |
84
|
|
|
* |
85
|
|
|
* If you are opening new elements, you must also close them again. |
86
|
|
|
* |
87
|
|
|
* @param Writer $writer |
88
|
|
|
* @return void |
89
|
|
|
*/ |
90
|
|
|
public function xmlSerialize(Writer $writer) { |
91
|
|
|
$cs = '{' . Application::DAV_NS_FACE_RECOGNITION . '}'; |
92
|
|
|
|
93
|
|
|
foreach ($this->persons as $person) { |
94
|
|
|
$writer->startElement($cs . 'person'); |
95
|
|
|
if (isset($person['id'])) { |
96
|
|
|
$writer->writeElement($cs . 'id', $person['id']); |
97
|
|
|
} |
98
|
|
|
if (isset($person['name'])) { |
99
|
|
|
$writer->writeElement($cs . 'name', $person['name']); |
100
|
|
|
} |
101
|
|
|
$writer->writeElement($cs . 'top', $person['top']); |
102
|
|
|
$writer->writeElement($cs . 'left', $person['left']); |
103
|
|
|
$writer->writeElement($cs . 'width', $person['width']); |
104
|
|
|
$writer->writeElement($cs . 'height', $person['height']); |
105
|
|
|
$writer->endElement(); |
106
|
|
|
} |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
} |
110
|
|
|
|
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