1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Nextcloud - OCR |
5
|
|
|
* This file is licensed under the Affero General Public License version 3 or |
6
|
|
|
* later. See the COPYING file. |
7
|
|
|
* |
8
|
|
|
* @author Janis Koehr <[email protected]> |
9
|
|
|
* @copyright Janis Koehr 2017 |
10
|
|
|
*/ |
11
|
|
|
namespace OCA\Ocr\Controller; |
12
|
|
|
|
13
|
|
|
use OCA\Ocr\Service\JobService; |
14
|
|
|
use OCP\AppFramework\Http\DataResponse; |
15
|
|
|
use OCP\IRequest; |
16
|
|
|
use OCP\AppFramework\Controller; |
17
|
|
|
|
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Class JobController |
21
|
|
|
* |
22
|
|
|
* @package OCA\Ocr\Controller |
23
|
|
|
*/ |
24
|
|
|
class JobController extends Controller { |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* |
28
|
|
|
* @var string |
29
|
|
|
*/ |
30
|
|
|
private $userId; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* |
34
|
|
|
* @var OcrService |
35
|
|
|
*/ |
36
|
|
|
private $service; |
37
|
|
|
use Errors; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* JobController constructor. |
41
|
|
|
* |
42
|
|
|
* @param string $AppName |
43
|
|
|
* @param IRequest $request |
44
|
|
|
* @param JobService $service |
45
|
|
|
* @param |
46
|
|
|
* $UserId |
47
|
|
|
*/ |
48
|
7 |
|
public function __construct($AppName, IRequest $request, JobService $service, $UserId) { |
49
|
7 |
|
parent::__construct($AppName, $request); |
50
|
7 |
|
$this->userId = $UserId; |
51
|
7 |
|
$this->service = $service; |
|
|
|
|
52
|
7 |
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Processing the srcFile(s) |
56
|
|
|
* @NoAdminRequired |
57
|
|
|
* |
58
|
|
|
* @param string[] $languages |
59
|
|
|
* - deu, eng... |
60
|
|
|
* @param array $files |
61
|
|
|
* @return DataResponse |
62
|
|
|
*/ |
63
|
2 |
|
public function process($languages, $files) { |
64
|
2 |
|
return $this->handleNotFound( |
65
|
|
|
function () use ($languages, $files) { |
66
|
2 |
|
return $this->service->process($languages, $files); |
67
|
2 |
|
}); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @NoAdminRequired |
72
|
|
|
* |
73
|
|
|
* @return \OCP\AppFramework\Http\DataResponse |
74
|
|
|
*/ |
75
|
2 |
|
public function getAllJobs() { |
76
|
|
|
return $this->handleNotFound(function () { |
77
|
2 |
|
return $this->service->getAllJobsForUser($this->userId); |
78
|
2 |
|
}); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @NoAdminRequired |
83
|
|
|
* |
84
|
|
|
* @param integer $id |
85
|
|
|
* @return \OCP\AppFramework\Http\DataResponse |
86
|
|
|
*/ |
87
|
2 |
|
public function deleteJob($id) { |
88
|
2 |
|
return $this->handleNotFound( |
89
|
2 |
|
function () use ($id) { |
90
|
2 |
|
return $this->service->deleteJob($id, $this->userId); |
91
|
2 |
|
}); |
92
|
|
|
} |
93
|
|
|
} |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..