aboutsummaryrefslogtreecommitdiffstats
path: root/apps/dav/lib/Provisioning/Apple/AppleProvisioningPlugin.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/dav/lib/Provisioning/Apple/AppleProvisioningPlugin.php')
-rw-r--r--apps/dav/lib/Provisioning/Apple/AppleProvisioningPlugin.php54
1 files changed, 11 insertions, 43 deletions
diff --git a/apps/dav/lib/Provisioning/Apple/AppleProvisioningPlugin.php b/apps/dav/lib/Provisioning/Apple/AppleProvisioningPlugin.php
index 838c1fbb781..258138caa42 100644
--- a/apps/dav/lib/Provisioning/Apple/AppleProvisioningPlugin.php
+++ b/apps/dav/lib/Provisioning/Apple/AppleProvisioningPlugin.php
@@ -1,10 +1,12 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\DAV\Provisioning\Apple;
+use OCP\AppFramework\Http;
use OCP\IL10N;
use OCP\IRequest;
use OCP\IURLGenerator;
@@ -21,52 +23,22 @@ class AppleProvisioningPlugin extends ServerPlugin {
protected $server;
/**
- * @var IURLGenerator
- */
- protected $urlGenerator;
-
- /**
- * @var IUserSession
- */
- protected $userSession;
-
- /**
* @var \OC_Defaults
*/
protected $themingDefaults;
/**
- * @var IRequest
- */
- protected $request;
-
- /**
- * @var IL10N
- */
- protected $l10n;
-
- /**
- * @var \Closure
- */
- protected $uuidClosure;
-
- /**
* AppleProvisioningPlugin constructor.
*/
public function __construct(
- IUserSession $userSession,
- IURLGenerator $urlGenerator,
+ protected IUserSession $userSession,
+ protected IURLGenerator $urlGenerator,
\OC_Defaults $themingDefaults,
- IRequest $request,
- IL10N $l10n,
- \Closure $uuidClosure
+ protected IRequest $request,
+ protected IL10N $l10n,
+ protected \Closure $uuidClosure,
) {
- $this->userSession = $userSession;
- $this->urlGenerator = $urlGenerator;
$this->themingDefaults = $themingDefaults;
- $this->request = $request;
- $this->l10n = $l10n;
- $this->uuidClosure = $uuidClosure;
}
/**
@@ -96,7 +68,7 @@ class AppleProvisioningPlugin extends ServerPlugin {
$useSSL = ($serverProtocol === 'https');
if (!$useSSL) {
- $response->setStatus(200);
+ $response->setStatus(Http::STATUS_OK);
$response->setHeader('Content-Type', 'text/plain; charset=utf-8');
$response->setBody($this->l10n->t('Your %s needs to be configured to use HTTPS in order to use CalDAV and CardDAV with iOS/macOS.', [$this->themingDefaults->getName()]));
@@ -105,11 +77,7 @@ class AppleProvisioningPlugin extends ServerPlugin {
$absoluteURL = $this->urlGenerator->getBaseUrl();
$parsedUrl = parse_url($absoluteURL);
- if (isset($parsedUrl['port'])) {
- $serverPort = $parsedUrl['port'];
- } else {
- $serverPort = 443;
- }
+ $serverPort = $parsedUrl['port'] ?? 443;
$server_url = $parsedUrl['host'];
$description = $this->themingDefaults->getName();
@@ -133,7 +101,7 @@ class AppleProvisioningPlugin extends ServerPlugin {
$filename = $userId . '-' . AppleProvisioningNode::FILENAME;
$xmlSkeleton = $this->getTemplate();
- $body = vsprintf($xmlSkeleton, array_map(function ($v) {
+ $body = vsprintf($xmlSkeleton, array_map(function (string $v) {
return \htmlspecialchars($v, ENT_XML1, 'UTF-8');
}, [
$description,
@@ -158,7 +126,7 @@ class AppleProvisioningPlugin extends ServerPlugin {
]
));
- $response->setStatus(200);
+ $response->setStatus(Http::STATUS_OK);
$response->setHeader('Content-Disposition', 'attachment; filename="' . $filename . '"');
$response->setHeader('Content-Type', 'application/xml; charset=utf-8');
$response->setBody($body);