Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/survey_client.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2018-01-17 22:19:39 +0300
committerBjoern Schiessle <bjoern@schiessle.org>2018-08-03 12:54:18 +0300
commit36cd89985db129961a7f070f2df6345c3a6664e9 (patch)
tree3eda6b05f03d8ce086bcc21dc42ee87fff7332eb /lib
parentb2f4d2dbceac1a7828d31607cad552df996370c2 (diff)
Move over to OCSController
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'lib')
-rw-r--r--lib/AppInfo/Application.php2
-rw-r--r--lib/Collector.php14
-rw-r--r--lib/Controller/EndpointController.php35
3 files changed, 28 insertions, 23 deletions
diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php
index cb1e164..7786ab6 100644
--- a/lib/AppInfo/Application.php
+++ b/lib/AppInfo/Application.php
@@ -27,7 +27,5 @@ use OCP\AppFramework\App;
class Application extends App {
public function __construct (array $urlParams = array()) {
parent::__construct('survey_client', $urlParams);
-
- $this->getContainer()->registerAlias('EndpointController', 'OCA\Survey_Client\Controller\EndpointController');
}
}
diff --git a/lib/Collector.php b/lib/Collector.php
index af70d3d..dfad9a3 100644
--- a/lib/Collector.php
+++ b/lib/Collector.php
@@ -31,6 +31,7 @@ use OCA\Survey_Client\Categories\Php;
use OCA\Survey_Client\Categories\Server;
use OCA\Survey_Client\Categories\Stats;
use OCP\AppFramework\Http;
+use OCP\AppFramework\Http\DataResponse;
use OCP\Http\Client\IClientService;
use OCP\IConfig;
use OCP\IDBConnection;
@@ -151,9 +152,9 @@ class Collector {
}
/**
- * @return \OC\OCS\Result
+ * @return DataResponse
*/
- public function sendReport() {
+ public function sendReport(): DataResponse {
$report = $this->getReport();
$client = $this->clientService->newClient();
@@ -166,7 +167,7 @@ class Collector {
],
]);
} catch (\Exception $e) {
- return new \OC\OCS\Result(
+ return new DataResponse(
$report,
Http::STATUS_INTERNAL_SERVER_ERROR
);
@@ -175,13 +176,12 @@ class Collector {
if ($response->getStatusCode() === Http::STATUS_OK) {
$this->config->setAppValue('survey_client', 'last_sent', time());
$this->config->setAppValue('survey_client', 'last_report', json_encode($report));
- return new \OC\OCS\Result(
- $report,
- 100// HTTP::STATUS_OK, TODO: <status>failure</status><statuscode>200</statuscode>
+ return new DataResponse(
+ $report
);
}
- return new \OC\OCS\Result(
+ return new DataResponse(
$report,
Http::STATUS_INTERNAL_SERVER_ERROR
);
diff --git a/lib/Controller/EndpointController.php b/lib/Controller/EndpointController.php
index bff9895..75dbf6d 100644
--- a/lib/Controller/EndpointController.php
+++ b/lib/Controller/EndpointController.php
@@ -1,4 +1,5 @@
<?php
+declare(strict_types=1);
/**
* @author Joas Schilling <coding@schilljs.com>
*
@@ -22,13 +23,15 @@
namespace OCA\Survey_Client\Controller;
use OCA\Survey_Client\Collector;
-use OCP\AppFramework\Controller;
-use OCP\AppFramework\Http;
+
+use OCP\AppFramework\Http\DataResponse;
+use OCP\AppFramework\OCSController;
use OCP\BackgroundJob\IJobList;
use OCP\IRequest;
use OCP\Notification\IManager;
+use OCA\Survey_Client\BackgroundJobs\MonthlyReport;
-class EndpointController extends Controller {
+class EndpointController extends OCSController {
/** @var Collector */
protected $collector;
@@ -46,7 +49,11 @@ class EndpointController extends Controller {
* @param IJobList $jobList
* @param IManager $manager
*/
- public function __construct($appName, IRequest $request, Collector $collector, IJobList $jobList, IManager $manager) {
+ public function __construct(string $appName,
+ IRequest $request,
+ Collector $collector,
+ IJobList $jobList,
+ IManager $manager) {
parent::__construct($appName, $request);
$this->collector = $collector;
@@ -55,35 +62,35 @@ class EndpointController extends Controller {
}
/**
- * @return \OC\OCS\Result
+ * @return DataResponse
*/
- public function enableMonthly() {
- $this->jobList->add('OCA\Survey_Client\BackgroundJobs\MonthlyReport');
+ public function enableMonthly(): DataResponse {
+ $this->jobList->add(MonthlyReport::class);
$notification = $this->manager->createNotification();
$notification->setApp('survey_client');
$this->manager->markProcessed($notification);
- return new \OC\OCS\Result();
+ return new DataResponse([]);
}
/**
- * @return \OC\OCS\Result
+ * @return DataResponse
*/
- public function disableMonthly() {
- $this->jobList->remove('OCA\Survey_Client\BackgroundJobs\MonthlyReport');
+ public function disableMonthly(): DataResponse {
+ $this->jobList->remove(MonthlyReport::class);
$notification = $this->manager->createNotification();
$notification->setApp('survey_client');
$this->manager->markProcessed($notification);
- return new \OC\OCS\Result();
+ return new DataResponse([]);
}
/**
- * @return \OC\OCS\Result
+ * @return DataResponse
*/
- public function sendReport() {
+ public function sendReport(): DataResponse {
return $this->collector->sendReport();
}
}