From f37fa6e45c4357ce9849543fa91551a62f3828b8 Mon Sep 17 00:00:00 2001
From: Joas Schilling <coding@schilljs.com>
Date: Mon, 1 Aug 2016 12:49:41 +0200
Subject: [PATCH] Move Share backends to PSR-4 instead of using class path
 (#24941)

---
 apps/files_sharing/appinfo/app.php                          | 6 ++----
 .../lib/{share/file.php => ShareBackend/File.php}           | 4 +++-
 .../lib/{share/folder.php => ShareBackend/Folder.php}       | 4 +++-
 apps/files_sharing/tests/BackendTest.php                    | 2 +-
 lib/private/Share/Share.php                                 | 2 +-
 tests/lib/Files/EtagTest.php                                | 4 ++--
 6 files changed, 12 insertions(+), 10 deletions(-)
 rename apps/files_sharing/lib/{share/file.php => ShareBackend/File.php} (98%)
 rename apps/files_sharing/lib/{share/folder.php => ShareBackend/Folder.php} (96%)

diff --git a/apps/files_sharing/appinfo/app.php b/apps/files_sharing/appinfo/app.php
index 2df7f099838..11c4614d6c5 100644
--- a/apps/files_sharing/appinfo/app.php
+++ b/apps/files_sharing/appinfo/app.php
@@ -28,14 +28,12 @@
 
 $l = \OC::$server->getL10N('files_sharing');
 
-\OC::$CLASSPATH['OC_Share_Backend_File'] = 'files_sharing/lib/share/file.php';
-\OC::$CLASSPATH['OC_Share_Backend_Folder'] = 'files_sharing/lib/share/folder.php';
 \OC::$CLASSPATH['OC\Files\Storage\Shared'] = 'files_sharing/lib/sharedstorage.php';
 
 \OCA\Files_Sharing\Helper::registerHooks();
 
-\OCP\Share::registerBackend('file', 'OC_Share_Backend_File');
-\OCP\Share::registerBackend('folder', 'OC_Share_Backend_Folder', 'file');
+\OCP\Share::registerBackend('file', 'OCA\Files_Sharing\ShareBackend\File');
+\OCP\Share::registerBackend('folder', 'OCA\Files_Sharing\ShareBackend\Folder', 'file');
 
 $application = new \OCA\Files_Sharing\AppInfo\Application();
 $application->registerMountProviders();
diff --git a/apps/files_sharing/lib/share/file.php b/apps/files_sharing/lib/ShareBackend/File.php
similarity index 98%
rename from apps/files_sharing/lib/share/file.php
rename to apps/files_sharing/lib/ShareBackend/File.php
index 370e755ec80..aecb63c60e4 100644
--- a/apps/files_sharing/lib/share/file.php
+++ b/apps/files_sharing/lib/ShareBackend/File.php
@@ -31,9 +31,11 @@
  *
  */
 
+namespace OCA\Files_Sharing\ShareBackend;
+
 use OCA\FederatedFileSharing\FederatedShareProvider;
 
-class OC_Share_Backend_File implements OCP\Share_Backend_File_Dependent {
+class File implements \OCP\Share_Backend_File_Dependent {
 
 	const FORMAT_SHARED_STORAGE = 0;
 	const FORMAT_GET_FOLDER_CONTENTS = 1;
diff --git a/apps/files_sharing/lib/share/folder.php b/apps/files_sharing/lib/ShareBackend/Folder.php
similarity index 96%
rename from apps/files_sharing/lib/share/folder.php
rename to apps/files_sharing/lib/ShareBackend/Folder.php
index e4d90274db1..4929bebf40b 100644
--- a/apps/files_sharing/lib/share/folder.php
+++ b/apps/files_sharing/lib/ShareBackend/Folder.php
@@ -25,7 +25,9 @@
  *
  */
 
-class OC_Share_Backend_Folder extends OC_Share_Backend_File implements OCP\Share_Backend_Collection {
+namespace OCA\Files_Sharing\ShareBackend;
+
+class Folder extends File implements \OCP\Share_Backend_Collection {
 
 	/**
 	 * get shared parents
diff --git a/apps/files_sharing/tests/BackendTest.php b/apps/files_sharing/tests/BackendTest.php
index f5fd726d637..cea8762a5b4 100644
--- a/apps/files_sharing/tests/BackendTest.php
+++ b/apps/files_sharing/tests/BackendTest.php
@@ -79,7 +79,7 @@ class BackendTest extends TestCase {
 		$this->assertTrue(\OCP\Share::shareItem('folder', $fileinfo2['fileid'], \OCP\Share::SHARE_TYPE_USER,
 				self::TEST_FILES_SHARING_API_USER3, 31));
 
-		$backend = new \OC_Share_Backend_Folder();
+		$backend = new \OCA\Files_Sharing\ShareBackend\Folder();
 
 		$result = $backend->getParents($fileinfo3['fileid']);
 		$this->assertSame(2, count($result));
diff --git a/lib/private/Share/Share.php b/lib/private/Share/Share.php
index fdc5818dbf7..9210dfd1fd1 100644
--- a/lib/private/Share/Share.php
+++ b/lib/private/Share/Share.php
@@ -2533,7 +2533,7 @@ class Share extends Constants {
 				}
 			} else {
 				if ($fileDependent) {
-					if ($format == \OC_Share_Backend_File::FORMAT_GET_FOLDER_CONTENTS || $format == \OC_Share_Backend_File::FORMAT_FILE_APP_ROOT) {
+					if ($format == \OCA\Files_Sharing\ShareBackend\File::FORMAT_GET_FOLDER_CONTENTS || $format == \OCA\Files_Sharing\ShareBackend\File::FORMAT_FILE_APP_ROOT) {
 						$select = '`*PREFIX*share`.`id`, `item_type`, `item_source`, `*PREFIX*share`.`parent`, `uid_owner`, '
 							. '`share_type`, `share_with`, `file_source`, `path`, `file_target`, `stime`, '
 							. '`*PREFIX*share`.`permissions`, `expiration`, `storage`, `*PREFIX*filecache`.`parent` as `file_parent`, '
diff --git a/tests/lib/Files/EtagTest.php b/tests/lib/Files/EtagTest.php
index d8e44000f9c..67ddd6ca514 100644
--- a/tests/lib/Files/EtagTest.php
+++ b/tests/lib/Files/EtagTest.php
@@ -34,8 +34,8 @@ class EtagTest extends \Test\TestCase {
 		\OC_Hook::clear('OC_Filesystem', 'setup');
 		$application = new \OCA\Files_Sharing\AppInfo\Application();
 		$application->registerMountProviders();
-		\OCP\Share::registerBackend('file', 'OC_Share_Backend_File');
-		\OCP\Share::registerBackend('folder', 'OC_Share_Backend_Folder', 'file');
+		\OCP\Share::registerBackend('file', 'OCA\Files_Sharing\ShareBackend\File');
+		\OCP\Share::registerBackend('folder', 'OCA\Files_Sharing\ShareBackend\Folder', 'file');
 
 		$config = \OC::$server->getConfig();
 		$this->datadir = $config->getSystemValue('datadirectory');
-- 
GitLab