aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorCôme Chilliet <91878298+come-nc@users.noreply.github.com>2024-05-21 09:11:48 +0200
committerGitHub <noreply@github.com>2024-05-21 09:11:48 +0200
commit9b0e4832bddb3c589a07042e1282e56e175155ca (patch)
tree580398e9db82e52d8cd52f6254090b67c5ad77f0 /lib
parent54afea4b01385106a241a5161b3894e669716107 (diff)
parentd7ed056160a4f32e9e536bea0d934bbf97354ea4 (diff)
downloadnextcloud-server-9b0e4832bddb3c589a07042e1282e56e175155ca.tar.gz
nextcloud-server-9b0e4832bddb3c589a07042e1282e56e175155ca.zip
Merge pull request #45375 from nextcloud/fix/move-eventsource-to-oc
Move EventSource to `OC` namespace
Diffstat (limited to 'lib')
-rw-r--r--lib/composer/composer/autoload_classmap.php2
-rw-r--r--lib/composer/composer/autoload_static.php2
-rw-r--r--lib/private/EventSource.php (renamed from lib/private/legacy/OC_EventSource.php)34
-rw-r--r--lib/private/EventSourceFactory.php19
-rw-r--r--lib/public/IEventSource.php2
5 files changed, 25 insertions, 34 deletions
diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php
index cb57d44ea60..8e1408e121e 100644
--- a/lib/composer/composer/autoload_classmap.php
+++ b/lib/composer/composer/autoload_classmap.php
@@ -1382,6 +1382,7 @@ return array(
'OC\\Encryption\\Util' => $baseDir . '/lib/private/Encryption/Util.php',
'OC\\EventDispatcher\\EventDispatcher' => $baseDir . '/lib/private/EventDispatcher/EventDispatcher.php',
'OC\\EventDispatcher\\ServiceEventListener' => $baseDir . '/lib/private/EventDispatcher/ServiceEventListener.php',
+ 'OC\\EventSource' => $baseDir . '/lib/private/EventSource.php',
'OC\\EventSourceFactory' => $baseDir . '/lib/private/EventSourceFactory.php',
'OC\\Federation\\CloudFederationFactory' => $baseDir . '/lib/private/Federation/CloudFederationFactory.php',
'OC\\Federation\\CloudFederationNotification' => $baseDir . '/lib/private/Federation/CloudFederationNotification.php',
@@ -1905,7 +1906,6 @@ return array(
'OC_API' => $baseDir . '/lib/private/legacy/OC_API.php',
'OC_App' => $baseDir . '/lib/private/legacy/OC_App.php',
'OC_Defaults' => $baseDir . '/lib/private/legacy/OC_Defaults.php',
- 'OC_EventSource' => $baseDir . '/lib/private/legacy/OC_EventSource.php',
'OC_FileChunking' => $baseDir . '/lib/private/legacy/OC_FileChunking.php',
'OC_Files' => $baseDir . '/lib/private/legacy/OC_Files.php',
'OC_Helper' => $baseDir . '/lib/private/legacy/OC_Helper.php',
diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php
index 0a4e9571049..d6939ae36ce 100644
--- a/lib/composer/composer/autoload_static.php
+++ b/lib/composer/composer/autoload_static.php
@@ -1423,6 +1423,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
'OC\\Encryption\\Util' => __DIR__ . '/../../..' . '/lib/private/Encryption/Util.php',
'OC\\EventDispatcher\\EventDispatcher' => __DIR__ . '/../../..' . '/lib/private/EventDispatcher/EventDispatcher.php',
'OC\\EventDispatcher\\ServiceEventListener' => __DIR__ . '/../../..' . '/lib/private/EventDispatcher/ServiceEventListener.php',
+ 'OC\\EventSource' => __DIR__ . '/../../..' . '/lib/private/EventSource.php',
'OC\\EventSourceFactory' => __DIR__ . '/../../..' . '/lib/private/EventSourceFactory.php',
'OC\\Federation\\CloudFederationFactory' => __DIR__ . '/../../..' . '/lib/private/Federation/CloudFederationFactory.php',
'OC\\Federation\\CloudFederationNotification' => __DIR__ . '/../../..' . '/lib/private/Federation/CloudFederationNotification.php',
@@ -1946,7 +1947,6 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
'OC_API' => __DIR__ . '/../../..' . '/lib/private/legacy/OC_API.php',
'OC_App' => __DIR__ . '/../../..' . '/lib/private/legacy/OC_App.php',
'OC_Defaults' => __DIR__ . '/../../..' . '/lib/private/legacy/OC_Defaults.php',
- 'OC_EventSource' => __DIR__ . '/../../..' . '/lib/private/legacy/OC_EventSource.php',
'OC_FileChunking' => __DIR__ . '/../../..' . '/lib/private/legacy/OC_FileChunking.php',
'OC_Files' => __DIR__ . '/../../..' . '/lib/private/legacy/OC_Files.php',
'OC_Helper' => __DIR__ . '/../../..' . '/lib/private/legacy/OC_Helper.php',
diff --git a/lib/private/legacy/OC_EventSource.php b/lib/private/EventSource.php
index 49fde4a214f..b5ab22d026e 100644
--- a/lib/private/legacy/OC_EventSource.php
+++ b/lib/private/EventSource.php
@@ -1,6 +1,6 @@
<?php
-use OCP\IRequest;
+declare(strict_types=1);
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
@@ -29,36 +29,30 @@ use OCP\IRequest;
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
-class OC_EventSource implements \OCP\IEventSource {
- /**
- * @var bool
- */
- private $fallback;
- /**
- * @var int
- */
- private $fallBackId = 0;
+namespace OC;
- /**
- * @var bool
- */
- private $started = false;
+use OCP\IEventSource;
+use OCP\IRequest;
- private IRequest $request;
+class EventSource implements IEventSource {
+ private bool $fallback = false;
+ private int $fallBackId = 0;
+ private bool $started = false;
- public function __construct(IRequest $request) {
- $this->request = $request;
+ public function __construct(
+ private IRequest $request,
+ ) {
}
- protected function init() {
+ protected function init(): void {
if ($this->started) {
return;
}
$this->started = true;
// prevent php output buffering, caching and nginx buffering
- OC_Util::obEnd();
+ \OC_Util::obEnd();
header('Cache-Control: no-cache');
header('X-Accel-Buffering: no');
$this->fallback = isset($_GET['fallback']) and $_GET['fallback'] == 'true';
@@ -104,7 +98,7 @@ class OC_EventSource implements \OCP\IEventSource {
*/
public function send($type, $data = null) {
if ($data and !preg_match('/^[A-Za-z0-9_]+$/', $type)) {
- throw new BadMethodCallException('Type needs to be alphanumeric ('. $type .')');
+ throw new \BadMethodCallException('Type needs to be alphanumeric ('. $type .')');
}
$this->init();
if (is_null($data)) {
diff --git a/lib/private/EventSourceFactory.php b/lib/private/EventSourceFactory.php
index 197c8bf9e6c..52ed0749692 100644
--- a/lib/private/EventSourceFactory.php
+++ b/lib/private/EventSourceFactory.php
@@ -1,4 +1,7 @@
<?php
+
+declare(strict_types=1);
+
/**
* @copyright Copyright (c) 2023 Daniel Kesselberg <mail@danielkesselberg.de>
*
@@ -27,20 +30,12 @@ use OCP\IEventSourceFactory;
use OCP\IRequest;
class EventSourceFactory implements IEventSourceFactory {
- private IRequest $request;
-
-
- public function __construct(IRequest $request) {
- $this->request = $request;
+ public function __construct(
+ private IRequest $request,
+ ) {
}
- /**
- * Create a new event source
- *
- * @return IEventSource
- * @since 28.0.0
- */
public function create(): IEventSource {
- return new \OC_EventSource($this->request);
+ return new EventSource($this->request);
}
}
diff --git a/lib/public/IEventSource.php b/lib/public/IEventSource.php
index 879b365cc77..f24c0311f24 100644
--- a/lib/public/IEventSource.php
+++ b/lib/public/IEventSource.php
@@ -37,6 +37,7 @@ interface IEventSource {
*
* @param string $type One of success, notice, error, failure and done. Used in core/js/update.js
* @param mixed $data
+ * @return void
*
* if only one parameter is given, a typeless message will be send with that parameter as data
* @since 8.0.0
@@ -45,6 +46,7 @@ interface IEventSource {
/**
* close the connection of the event source
+ * @return void
* @since 8.0.0
*/
public function close();