Passed
Push — master ( 61a02b...010b07 )
by Roeland
19:08 queued 08:59
created
lib/public/GroupInterface.php 1 patch
Indentation   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -40,84 +40,84 @@
 block discarded – undo
40 40
  */
41 41
 interface GroupInterface {
42 42
 
43
-	/**
44
-	 * actions that user backends can define
45
-	 */
46
-	const CREATE_GROUP		= 0x00000001;
47
-	const DELETE_GROUP		= 0x00000010;
48
-	const ADD_TO_GROUP		= 0x00000100;
49
-	const REMOVE_FROM_GOUP	= 0x00001000; // oops
50
-	const REMOVE_FROM_GROUP	= 0x00001000;
51
-	//OBSOLETE const GET_DISPLAYNAME	= 0x00010000;
52
-	const COUNT_USERS		= 0x00100000;
53
-	const GROUP_DETAILS		= 0x01000000;
54
-	/**
55
-	 * @since 13.0.0
56
-	 */
57
-	const IS_ADMIN  = 0x10000000;
43
+    /**
44
+     * actions that user backends can define
45
+     */
46
+    const CREATE_GROUP		= 0x00000001;
47
+    const DELETE_GROUP		= 0x00000010;
48
+    const ADD_TO_GROUP		= 0x00000100;
49
+    const REMOVE_FROM_GOUP	= 0x00001000; // oops
50
+    const REMOVE_FROM_GROUP	= 0x00001000;
51
+    //OBSOLETE const GET_DISPLAYNAME	= 0x00010000;
52
+    const COUNT_USERS		= 0x00100000;
53
+    const GROUP_DETAILS		= 0x01000000;
54
+    /**
55
+     * @since 13.0.0
56
+     */
57
+    const IS_ADMIN  = 0x10000000;
58 58
 
59
-	/**
60
-	 * Check if backend implements actions
61
-	 * @param int $actions bitwise-or'ed actions
62
-	 * @return boolean
63
-	 * @since 4.5.0
64
-	 *
65
-	 * Returns the supported actions as int to be
66
-	 * compared with \OC_Group_Backend::CREATE_GROUP etc.
67
-	 */
68
-	public function implementsActions($actions);
59
+    /**
60
+     * Check if backend implements actions
61
+     * @param int $actions bitwise-or'ed actions
62
+     * @return boolean
63
+     * @since 4.5.0
64
+     *
65
+     * Returns the supported actions as int to be
66
+     * compared with \OC_Group_Backend::CREATE_GROUP etc.
67
+     */
68
+    public function implementsActions($actions);
69 69
 
70
-	/**
71
-	 * is user in group?
72
-	 * @param string $uid uid of the user
73
-	 * @param string $gid gid of the group
74
-	 * @return bool
75
-	 * @since 4.5.0
76
-	 *
77
-	 * Checks whether the user is member of a group or not.
78
-	 */
79
-	public function inGroup($uid, $gid);
70
+    /**
71
+     * is user in group?
72
+     * @param string $uid uid of the user
73
+     * @param string $gid gid of the group
74
+     * @return bool
75
+     * @since 4.5.0
76
+     *
77
+     * Checks whether the user is member of a group or not.
78
+     */
79
+    public function inGroup($uid, $gid);
80 80
 
81
-	/**
82
-	 * Get all groups a user belongs to
83
-	 * @param string $uid Name of the user
84
-	 * @return array an array of group names
85
-	 * @since 4.5.0
86
-	 *
87
-	 * This function fetches all groups a user belongs to. It does not check
88
-	 * if the user exists at all.
89
-	 */
90
-	public function getUserGroups($uid);
81
+    /**
82
+     * Get all groups a user belongs to
83
+     * @param string $uid Name of the user
84
+     * @return array an array of group names
85
+     * @since 4.5.0
86
+     *
87
+     * This function fetches all groups a user belongs to. It does not check
88
+     * if the user exists at all.
89
+     */
90
+    public function getUserGroups($uid);
91 91
 
92
-	/**
93
-	 * get a list of all groups
94
-	 * @param string $search
95
-	 * @param int $limit
96
-	 * @param int $offset
97
-	 * @return array an array of group names
98
-	 * @since 4.5.0
99
-	 *
100
-	 * Returns a list with all groups
101
-	 */
102
-	public function getGroups($search = '', $limit = -1, $offset = 0);
92
+    /**
93
+     * get a list of all groups
94
+     * @param string $search
95
+     * @param int $limit
96
+     * @param int $offset
97
+     * @return array an array of group names
98
+     * @since 4.5.0
99
+     *
100
+     * Returns a list with all groups
101
+     */
102
+    public function getGroups($search = '', $limit = -1, $offset = 0);
103 103
 
104
-	/**
105
-	 * check if a group exists
106
-	 * @param string $gid
107
-	 * @return bool
108
-	 * @since 4.5.0
109
-	 */
110
-	public function groupExists($gid);
104
+    /**
105
+     * check if a group exists
106
+     * @param string $gid
107
+     * @return bool
108
+     * @since 4.5.0
109
+     */
110
+    public function groupExists($gid);
111 111
 
112
-	/**
113
-	 * get a list of all users in a group
114
-	 * @param string $gid
115
-	 * @param string $search
116
-	 * @param int $limit
117
-	 * @param int $offset
118
-	 * @return array an array of user ids
119
-	 * @since 4.5.0
120
-	 */
121
-	public function usersInGroup($gid, $search = '', $limit = -1, $offset = 0);
112
+    /**
113
+     * get a list of all users in a group
114
+     * @param string $gid
115
+     * @param string $search
116
+     * @param int $limit
117
+     * @param int $offset
118
+     * @return array an array of user ids
119
+     * @since 4.5.0
120
+     */
121
+    public function usersInGroup($gid, $search = '', $limit = -1, $offset = 0);
122 122
 
123 123
 }
Please login to merge, or discard this patch.
lib/public/Collaboration/Collaborators/ISearchPlugin.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -30,13 +30,13 @@
 block discarded – undo
30 30
  * @since 13.0.0
31 31
  */
32 32
 interface ISearchPlugin {
33
-	/**
34
-	 * @param string $search
35
-	 * @param int $limit
36
-	 * @param int $offset
37
-	 * @param ISearchResult $searchResult
38
-	 * @return bool whether the plugin has more results
39
-	 * @since 13.0.0
40
-	 */
41
-	public function search($search, $limit, $offset, ISearchResult $searchResult);
33
+    /**
34
+     * @param string $search
35
+     * @param int $limit
36
+     * @param int $offset
37
+     * @param ISearchResult $searchResult
38
+     * @return bool whether the plugin has more results
39
+     * @since 13.0.0
40
+     */
41
+    public function search($search, $limit, $offset, ISearchResult $searchResult);
42 42
 }
Please login to merge, or discard this patch.
lib/private/Setup/OCI.php 1 patch
Indentation   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -32,81 +32,81 @@
 block discarded – undo
32 32
 namespace OC\Setup;
33 33
 
34 34
 class OCI extends AbstractDatabase {
35
-	public $dbprettyname = 'Oracle';
35
+    public $dbprettyname = 'Oracle';
36 36
 
37
-	protected $dbtablespace;
37
+    protected $dbtablespace;
38 38
 
39
-	public function initialize($config) {
40
-		parent::initialize($config);
41
-		if (array_key_exists('dbtablespace', $config)) {
42
-			$this->dbtablespace = $config['dbtablespace'];
43
-		} else {
44
-			$this->dbtablespace = 'USERS';
45
-		}
46
-		// allow empty hostname for oracle
47
-		$this->dbHost = $config['dbhost'];
39
+    public function initialize($config) {
40
+        parent::initialize($config);
41
+        if (array_key_exists('dbtablespace', $config)) {
42
+            $this->dbtablespace = $config['dbtablespace'];
43
+        } else {
44
+            $this->dbtablespace = 'USERS';
45
+        }
46
+        // allow empty hostname for oracle
47
+        $this->dbHost = $config['dbhost'];
48 48
 
49
-		$this->config->setValues([
50
-			'dbhost' => $this->dbHost,
51
-			'dbtablespace' => $this->dbtablespace,
52
-		]);
53
-	}
49
+        $this->config->setValues([
50
+            'dbhost' => $this->dbHost,
51
+            'dbtablespace' => $this->dbtablespace,
52
+        ]);
53
+    }
54 54
 
55
-	public function validate($config) {
56
-		$errors = array();
57
-		if (empty($config['dbuser']) && empty($config['dbname'])) {
58
-			$errors[] = $this->trans->t("%s enter the database username and name.", array($this->dbprettyname));
59
-		} else if (empty($config['dbuser'])) {
60
-			$errors[] = $this->trans->t("%s enter the database username.", array($this->dbprettyname));
61
-		} else if (empty($config['dbname'])) {
62
-			$errors[] = $this->trans->t("%s enter the database name.", array($this->dbprettyname));
63
-		}
64
-		return $errors;
65
-	}
55
+    public function validate($config) {
56
+        $errors = array();
57
+        if (empty($config['dbuser']) && empty($config['dbname'])) {
58
+            $errors[] = $this->trans->t("%s enter the database username and name.", array($this->dbprettyname));
59
+        } else if (empty($config['dbuser'])) {
60
+            $errors[] = $this->trans->t("%s enter the database username.", array($this->dbprettyname));
61
+        } else if (empty($config['dbname'])) {
62
+            $errors[] = $this->trans->t("%s enter the database name.", array($this->dbprettyname));
63
+        }
64
+        return $errors;
65
+    }
66 66
 
67
-	public function setupDatabase($username) {
68
-		try {
69
-			$this->connect();
70
-		} catch (\Exception $e) {
71
-			$errorMessage = $this->getLastError();
72
-			if ($errorMessage) {
73
-				throw new \OC\DatabaseSetupException($this->trans->t('Oracle connection could not be established'),
74
-					$errorMessage . ' Check environment: ORACLE_HOME=' . getenv('ORACLE_HOME')
75
-					. ' ORACLE_SID=' . getenv('ORACLE_SID')
76
-					. ' LD_LIBRARY_PATH=' . getenv('LD_LIBRARY_PATH')
77
-					. ' NLS_LANG=' . getenv('NLS_LANG')
78
-					. ' tnsnames.ora is ' . (is_readable(getenv('ORACLE_HOME') . '/network/admin/tnsnames.ora') ? '' : 'not ') . 'readable');
79
-			}
80
-			throw new \OC\DatabaseSetupException($this->trans->t('Oracle username and/or password not valid'),
81
-				'Check environment: ORACLE_HOME=' . getenv('ORACLE_HOME')
82
-				. ' ORACLE_SID=' . getenv('ORACLE_SID')
83
-				. ' LD_LIBRARY_PATH=' . getenv('LD_LIBRARY_PATH')
84
-				. ' NLS_LANG=' . getenv('NLS_LANG')
85
-				. ' tnsnames.ora is ' . (is_readable(getenv('ORACLE_HOME') . '/network/admin/tnsnames.ora') ? '' : 'not ') . 'readable');
86
-		}
67
+    public function setupDatabase($username) {
68
+        try {
69
+            $this->connect();
70
+        } catch (\Exception $e) {
71
+            $errorMessage = $this->getLastError();
72
+            if ($errorMessage) {
73
+                throw new \OC\DatabaseSetupException($this->trans->t('Oracle connection could not be established'),
74
+                    $errorMessage . ' Check environment: ORACLE_HOME=' . getenv('ORACLE_HOME')
75
+                    . ' ORACLE_SID=' . getenv('ORACLE_SID')
76
+                    . ' LD_LIBRARY_PATH=' . getenv('LD_LIBRARY_PATH')
77
+                    . ' NLS_LANG=' . getenv('NLS_LANG')
78
+                    . ' tnsnames.ora is ' . (is_readable(getenv('ORACLE_HOME') . '/network/admin/tnsnames.ora') ? '' : 'not ') . 'readable');
79
+            }
80
+            throw new \OC\DatabaseSetupException($this->trans->t('Oracle username and/or password not valid'),
81
+                'Check environment: ORACLE_HOME=' . getenv('ORACLE_HOME')
82
+                . ' ORACLE_SID=' . getenv('ORACLE_SID')
83
+                . ' LD_LIBRARY_PATH=' . getenv('LD_LIBRARY_PATH')
84
+                . ' NLS_LANG=' . getenv('NLS_LANG')
85
+                . ' tnsnames.ora is ' . (is_readable(getenv('ORACLE_HOME') . '/network/admin/tnsnames.ora') ? '' : 'not ') . 'readable');
86
+        }
87 87
 
88
-		$this->config->setValues([
89
-			'dbuser' => $this->dbUser,
90
-			'dbname' => $this->dbName,
91
-			'dbpassword' => $this->dbPassword,
92
-		]);
93
-	}
88
+        $this->config->setValues([
89
+            'dbuser' => $this->dbUser,
90
+            'dbname' => $this->dbName,
91
+            'dbpassword' => $this->dbPassword,
92
+        ]);
93
+    }
94 94
 
95
-	/**
96
-	 * @param resource $connection
97
-	 * @return string
98
-	 */
99
-	protected function getLastError($connection = null) {
100
-		if ($connection) {
101
-			$error = oci_error($connection);
102
-		} else {
103
-			$error = oci_error();
104
-		}
105
-		foreach (array('message', 'code') as $key) {
106
-			if (isset($error[$key])) {
107
-				return $error[$key];
108
-			}
109
-		}
110
-		return '';
111
-	}
95
+    /**
96
+     * @param resource $connection
97
+     * @return string
98
+     */
99
+    protected function getLastError($connection = null) {
100
+        if ($connection) {
101
+            $error = oci_error($connection);
102
+        } else {
103
+            $error = oci_error();
104
+        }
105
+        foreach (array('message', 'code') as $key) {
106
+            if (isset($error[$key])) {
107
+                return $error[$key];
108
+            }
109
+        }
110
+        return '';
111
+    }
112 112
 }
Please login to merge, or discard this patch.
lib/public/Collaboration/Collaborators/ISearch.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -30,21 +30,21 @@
 block discarded – undo
30 30
  * @since 13.0.0
31 31
  */
32 32
 interface ISearch {
33
-	/**
34
-	 * @param string $search
35
-	 * @param array $shareTypes
36
-	 * @param bool $lookup
37
-	 * @param int $limit
38
-	 * @param int $offset
39
-	 * @return array with two elements, 1st ISearchResult as array, 2nd a bool indicating whether more result are available
40
-	 * @since 13.0.0
41
-	 */
42
-	public function search($search, array $shareTypes, $lookup, $limit, $offset);
33
+    /**
34
+     * @param string $search
35
+     * @param array $shareTypes
36
+     * @param bool $lookup
37
+     * @param int $limit
38
+     * @param int $offset
39
+     * @return array with two elements, 1st ISearchResult as array, 2nd a bool indicating whether more result are available
40
+     * @since 13.0.0
41
+     */
42
+    public function search($search, array $shareTypes, $lookup, $limit, $offset);
43 43
 
44
-	/**
45
-	 * @param array $pluginInfo with keys 'shareType' containing the name of a corresponding constant in \OCP\Share and
46
-	 * 	'class' with the class name of the plugin
47
-	 * @since 13.0.0
48
-	 */
49
-	public function registerPlugin(array $pluginInfo);
44
+    /**
45
+     * @param array $pluginInfo with keys 'shareType' containing the name of a corresponding constant in \OCP\Share and
46
+     * 	'class' with the class name of the plugin
47
+     * @since 13.0.0
48
+     */
49
+    public function registerPlugin(array $pluginInfo);
50 50
 }
Please login to merge, or discard this patch.
lib/public/Collaboration/Collaborators/ISearchResult.php 1 patch
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -30,44 +30,44 @@
 block discarded – undo
30 30
  * @since 13.0.0
31 31
  */
32 32
 interface ISearchResult {
33
-	/**
34
-	 * @param SearchResultType $type
35
-	 * @param array $matches
36
-	 * @param array|null $exactMatches
37
-	 * @since 13.0.0
38
-	 */
39
-	public function addResultSet(SearchResultType $type, array $matches, array $exactMatches = null);
33
+    /**
34
+     * @param SearchResultType $type
35
+     * @param array $matches
36
+     * @param array|null $exactMatches
37
+     * @since 13.0.0
38
+     */
39
+    public function addResultSet(SearchResultType $type, array $matches, array $exactMatches = null);
40 40
 
41
-	/**
42
-	 * @param SearchResultType $type
43
-	 * @param string $collaboratorId
44
-	 * @return bool
45
-	 * @since 13.0.0
46
-	 */
47
-	public function hasResult(SearchResultType $type, $collaboratorId);
41
+    /**
42
+     * @param SearchResultType $type
43
+     * @param string $collaboratorId
44
+     * @return bool
45
+     * @since 13.0.0
46
+     */
47
+    public function hasResult(SearchResultType $type, $collaboratorId);
48 48
 
49
-	/**
50
-	 * @param SearchResultType $type
51
-	 * @since 13.0.0
52
-	 */
53
-	public function unsetResult(SearchResultType $type);
49
+    /**
50
+     * @param SearchResultType $type
51
+     * @since 13.0.0
52
+     */
53
+    public function unsetResult(SearchResultType $type);
54 54
 
55
-	/**
56
-	 * @param SearchResultType $type
57
-	 * @since 13.0.0
58
-	 */
59
-	public function markExactIdMatch(SearchResultType $type);
55
+    /**
56
+     * @param SearchResultType $type
57
+     * @since 13.0.0
58
+     */
59
+    public function markExactIdMatch(SearchResultType $type);
60 60
 
61
-	/**
62
-	 * @param SearchResultType $type
63
-	 * @return bool
64
-	 * @since 13.0.0
65
-	 */
66
-	public function hasExactIdMatch(SearchResultType $type);
61
+    /**
62
+     * @param SearchResultType $type
63
+     * @return bool
64
+     * @since 13.0.0
65
+     */
66
+    public function hasExactIdMatch(SearchResultType $type);
67 67
 
68
-	/**
69
-	 * @return array
70
-	 * @since 13.0.0
71
-	 */
72
-	public function asArray();
68
+    /**
69
+     * @return array
70
+     * @since 13.0.0
71
+     */
72
+    public function asArray();
73 73
 }
Please login to merge, or discard this patch.
apps/files_trashbin/lib/Events/MoveToTrashEvent.php 1 patch
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -35,39 +35,39 @@
 block discarded – undo
35 35
  */
36 36
 class MoveToTrashEvent extends Event {
37 37
 
38
-	/** @var bool */
39
-	private $moveToTrashBin;
38
+    /** @var bool */
39
+    private $moveToTrashBin;
40 40
 
41
-	/** @var Node */
42
-	private $node;
41
+    /** @var Node */
42
+    private $node;
43 43
 
44
-	public function __construct(Node $node) {
45
-		$this->moveToTrashBin = true;
46
-		$this->node = $node;
47
-	}
44
+    public function __construct(Node $node) {
45
+        $this->moveToTrashBin = true;
46
+        $this->node = $node;
47
+    }
48 48
 
49
-	/**
50
-	 * get Node which will be deleted
51
-	 *
52
-	 * @return Node
53
-	 */
54
-	public function getNode() {
55
-		return $this->node;
56
-	}
49
+    /**
50
+     * get Node which will be deleted
51
+     *
52
+     * @return Node
53
+     */
54
+    public function getNode() {
55
+        return $this->node;
56
+    }
57 57
 
58
-	/**
59
-	 * disable trash bin for this operation
60
-	 */
61
-	public function disableTrashBin() {
62
-		$this->moveToTrashBin = false;
63
-	}
58
+    /**
59
+     * disable trash bin for this operation
60
+     */
61
+    public function disableTrashBin() {
62
+        $this->moveToTrashBin = false;
63
+    }
64 64
 
65
-	/**
66
-	 * should the file be moved to the trash bin?
67
-	 *
68
-	 * @return bool
69
-	 */
70
-	public function shouldMoveToTrashBin() {
71
-		return $this->moveToTrashBin;
72
-	}
65
+    /**
66
+     * should the file be moved to the trash bin?
67
+     *
68
+     * @return bool
69
+     */
70
+    public function shouldMoveToTrashBin() {
71
+        return $this->moveToTrashBin;
72
+    }
73 73
 }
Please login to merge, or discard this patch.
apps/files_versions/lib/Events/CreateVersionEvent.php 1 patch
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -37,45 +37,45 @@
 block discarded – undo
37 37
 class CreateVersionEvent extends Event {
38 38
 
39 39
 
40
-	/** @var bool */
41
-	private $createVersion;
40
+    /** @var bool */
41
+    private $createVersion;
42 42
 
43
-	/** @var Node */
44
-	private $node;
43
+    /** @var Node */
44
+    private $node;
45 45
 
46
-	/**
47
-	 * CreateVersionEvent constructor.
48
-	 *
49
-	 * @param Node $node
50
-	 */
51
-	public function __construct(Node $node) {
52
-		$this->createVersion = true;
53
-		$this->node = $node;
54
-	}
46
+    /**
47
+     * CreateVersionEvent constructor.
48
+     *
49
+     * @param Node $node
50
+     */
51
+    public function __construct(Node $node) {
52
+        $this->createVersion = true;
53
+        $this->node = $node;
54
+    }
55 55
 
56
-	/**
57
-	 * get Node of the file which should be versioned
58
-	 *
59
-	 * @return Node
60
-	 */
61
-	public function getNode() {
62
-		return $this->node;
63
-	}
56
+    /**
57
+     * get Node of the file which should be versioned
58
+     *
59
+     * @return Node
60
+     */
61
+    public function getNode() {
62
+        return $this->node;
63
+    }
64 64
 
65
-	/**
66
-	 * disable versions for this file
67
-	 */
68
-	public function disableVersions() {
69
-		$this->createVersion = false;
70
-	}
65
+    /**
66
+     * disable versions for this file
67
+     */
68
+    public function disableVersions() {
69
+        $this->createVersion = false;
70
+    }
71 71
 
72
-	/**
73
-	 * should a version be created for this file?
74
-	 *
75
-	 * @return bool
76
-	 */
77
-	public function shouldCreateVersion() {
78
-		return $this->createVersion;
79
-	}
72
+    /**
73
+     * should a version be created for this file?
74
+     *
75
+     * @return bool
76
+     */
77
+    public function shouldCreateVersion() {
78
+        return $this->createVersion;
79
+    }
80 80
 
81 81
 }
Please login to merge, or discard this patch.
apps/files_trashbin/appinfo/app.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -29,13 +29,13 @@
 block discarded – undo
29 29
 \OCA\Files_Trashbin\Trashbin::registerHooks();
30 30
 
31 31
 \OCA\Files\App::getNavigationManager()->add(function () {
32
-	$l = \OC::$server->getL10N('files_trashbin');
33
-	return [
34
-		'id' => 'trashbin',
35
-		'appname' => 'files_trashbin',
36
-		'script' => 'list.php',
37
-		'order' => 50,
38
-		'name' => $l->t('Deleted files'),
39
-		'classes' => 'pinned',
40
-	];
32
+    $l = \OC::$server->getL10N('files_trashbin');
33
+    return [
34
+        'id' => 'trashbin',
35
+        'appname' => 'files_trashbin',
36
+        'script' => 'list.php',
37
+        'order' => 50,
38
+        'name' => $l->t('Deleted files'),
39
+        'classes' => 'pinned',
40
+    ];
41 41
 });
Please login to merge, or discard this patch.
lib/private/Template/ResourceLocator.php 1 patch
Indentation   +169 added lines, -169 removed lines patch added patch discarded remove patch
@@ -27,173 +27,173 @@
 block discarded – undo
27 27
 namespace OC\Template;
28 28
 
29 29
 abstract class ResourceLocator {
30
-	protected $theme;
31
-
32
-	protected $mapping;
33
-	protected $serverroot;
34
-	protected $thirdpartyroot;
35
-	protected $webroot;
36
-
37
-	protected $resources = array();
38
-
39
-	/** @var \OCP\ILogger */
40
-	protected $logger;
41
-
42
-	/**
43
-	 * @param \OCP\ILogger $logger
44
-	 * @param string $theme
45
-	 * @param array $core_map
46
-	 * @param array $party_map
47
-	 */
48
-	public function __construct(\OCP\ILogger $logger, $theme, $core_map, $party_map) {
49
-		$this->logger = $logger;
50
-		$this->theme = $theme;
51
-		$this->mapping = $core_map + $party_map;
52
-		$this->serverroot = key($core_map);
53
-		$this->thirdpartyroot = key($party_map);
54
-		$this->webroot = $this->mapping[$this->serverroot];
55
-	}
56
-
57
-	/**
58
-	 * @param string $resource
59
-	 */
60
-	abstract public function doFind($resource);
61
-
62
-	/**
63
-	 * @param string $resource
64
-	 */
65
-	abstract public function doFindTheme($resource);
66
-
67
-	/**
68
-	 * Finds the resources and adds them to the list
69
-	 *
70
-	 * @param array $resources
71
-	 */
72
-	public function find($resources) {
73
-		foreach ($resources as $resource) {
74
-			try {
75
-				$this->doFind($resource);
76
-			} catch (ResourceNotFoundException $e) {
77
-				$resourceApp = substr($resource, 0, strpos($resource, '/'));
78
-				$this->logger->debug('Could not find resource file "' . $e->getResourcePath() . '"', ['app' => $resourceApp]);
79
-			}
80
-		}
81
-		if (!empty($this->theme)) {
82
-			foreach ($resources as $resource) {
83
-				try {
84
-					$this->doFindTheme($resource);
85
-				} catch (ResourceNotFoundException $e) {
86
-					$resourceApp = substr($resource, 0, strpos($resource, '/'));
87
-					$this->logger->debug('Could not find resource file in theme "' . $e->getResourcePath() . '"', ['app' => $resourceApp]);
88
-				}
89
-			}
90
-		}
91
-	}
92
-
93
-	/**
94
-	 * append the $file resource if exist at $root
95
-	 *
96
-	 * @param string $root path to check
97
-	 * @param string $file the filename
98
-	 * @param string|null $webRoot base for path, default map $root to $webRoot
99
-	 * @return bool True if the resource was found, false otherwise
100
-	 */
101
-	protected function appendIfExist($root, $file, $webRoot = null) {
102
-		if (is_file($root.'/'.$file)) {
103
-			$this->append($root, $file, $webRoot, false);
104
-			return true;
105
-		}
106
-		return false;
107
-	}
108
-
109
-	/**
110
-	 * Attempt to find the webRoot
111
-	 *
112
-	 * traverse the potential web roots upwards in the path
113
-	 *
114
-	 * example:
115
-	 *   - root: /srv/www/apps/myapp
116
-	 *   - available mappings: ['/srv/www']
117
-	 *
118
-	 * First we check if a mapping for /srv/www/apps/myapp is available,
119
-	 * then /srv/www/apps, /srv/www/apps, /srv/www, ... until we find a
120
-	 * valid web root
121
-	 *
122
-	 * @param string $root
123
-	 * @return string|null The web root or null on failure
124
-	 */
125
-	protected function findWebRoot($root) {
126
-		$webRoot = null;
127
-		$tmpRoot = $root;
128
-
129
-		while ($webRoot === null) {
130
-			if (isset($this->mapping[$tmpRoot])) {
131
-				$webRoot = $this->mapping[$tmpRoot];
132
-				break;
133
-			}
134
-
135
-			if ($tmpRoot === '/') {
136
-				break;
137
-			}
138
-
139
-			$tmpRoot = dirname($tmpRoot);
140
-		}
141
-
142
-		if ($webRoot === null) {
143
-			$realpath = realpath($root);
144
-
145
-			if ($realpath && ($realpath !== $root)) {
146
-				return $this->findWebRoot($realpath);
147
-			}
148
-		}
149
-
150
-		return $webRoot;
151
-	}
152
-
153
-	/**
154
-	 * append the $file resource at $root
155
-	 *
156
-	 * @param string $root path to check
157
-	 * @param string $file the filename
158
-	 * @param string|null $webRoot base for path, default map $root to $webRoot
159
-	 * @param bool $throw Throw an exception, when the route does not exist
160
-	 * @throws ResourceNotFoundException Only thrown when $throw is true and the resource is missing
161
-	 */
162
-	protected function append($root, $file, $webRoot = null, $throw = true) {
163
-
164
-		if (!is_string($root)) {
165
-			if ($throw) {
166
-				throw new ResourceNotFoundException($file, $webRoot);
167
-			}
168
-			return;
169
-		}
170
-
171
-		if (!$webRoot) {
172
-			$webRoot = $this->findWebRoot($root);
173
-
174
-			if ($webRoot === null) {
175
-				$webRoot = '';
176
-				$this->logger->error('ResourceLocator can not find a web root (root: {root}, file: {file}, webRoot: {webRoot}, throw: {throw})', [
177
-					'app' => 'lib',
178
-					'root' => $root,
179
-					'file' => $file,
180
-					'webRoot' => $webRoot,
181
-					'throw' => $throw ? 'true' : 'false'
182
-				]);
183
-			}
184
-		}
185
-		$this->resources[] = array($root, $webRoot, $file);
186
-
187
-		if ($throw && !is_file($root . '/' . $file)) {
188
-			throw new ResourceNotFoundException($file, $webRoot);
189
-		}
190
-	}
191
-
192
-	/**
193
-	 * Returns the list of all resources that should be loaded
194
-	 * @return array
195
-	 */
196
-	public function getResources() {
197
-		return $this->resources;
198
-	}
30
+    protected $theme;
31
+
32
+    protected $mapping;
33
+    protected $serverroot;
34
+    protected $thirdpartyroot;
35
+    protected $webroot;
36
+
37
+    protected $resources = array();
38
+
39
+    /** @var \OCP\ILogger */
40
+    protected $logger;
41
+
42
+    /**
43
+     * @param \OCP\ILogger $logger
44
+     * @param string $theme
45
+     * @param array $core_map
46
+     * @param array $party_map
47
+     */
48
+    public function __construct(\OCP\ILogger $logger, $theme, $core_map, $party_map) {
49
+        $this->logger = $logger;
50
+        $this->theme = $theme;
51
+        $this->mapping = $core_map + $party_map;
52
+        $this->serverroot = key($core_map);
53
+        $this->thirdpartyroot = key($party_map);
54
+        $this->webroot = $this->mapping[$this->serverroot];
55
+    }
56
+
57
+    /**
58
+     * @param string $resource
59
+     */
60
+    abstract public function doFind($resource);
61
+
62
+    /**
63
+     * @param string $resource
64
+     */
65
+    abstract public function doFindTheme($resource);
66
+
67
+    /**
68
+     * Finds the resources and adds them to the list
69
+     *
70
+     * @param array $resources
71
+     */
72
+    public function find($resources) {
73
+        foreach ($resources as $resource) {
74
+            try {
75
+                $this->doFind($resource);
76
+            } catch (ResourceNotFoundException $e) {
77
+                $resourceApp = substr($resource, 0, strpos($resource, '/'));
78
+                $this->logger->debug('Could not find resource file "' . $e->getResourcePath() . '"', ['app' => $resourceApp]);
79
+            }
80
+        }
81
+        if (!empty($this->theme)) {
82
+            foreach ($resources as $resource) {
83
+                try {
84
+                    $this->doFindTheme($resource);
85
+                } catch (ResourceNotFoundException $e) {
86
+                    $resourceApp = substr($resource, 0, strpos($resource, '/'));
87
+                    $this->logger->debug('Could not find resource file in theme "' . $e->getResourcePath() . '"', ['app' => $resourceApp]);
88
+                }
89
+            }
90
+        }
91
+    }
92
+
93
+    /**
94
+     * append the $file resource if exist at $root
95
+     *
96
+     * @param string $root path to check
97
+     * @param string $file the filename
98
+     * @param string|null $webRoot base for path, default map $root to $webRoot
99
+     * @return bool True if the resource was found, false otherwise
100
+     */
101
+    protected function appendIfExist($root, $file, $webRoot = null) {
102
+        if (is_file($root.'/'.$file)) {
103
+            $this->append($root, $file, $webRoot, false);
104
+            return true;
105
+        }
106
+        return false;
107
+    }
108
+
109
+    /**
110
+     * Attempt to find the webRoot
111
+     *
112
+     * traverse the potential web roots upwards in the path
113
+     *
114
+     * example:
115
+     *   - root: /srv/www/apps/myapp
116
+     *   - available mappings: ['/srv/www']
117
+     *
118
+     * First we check if a mapping for /srv/www/apps/myapp is available,
119
+     * then /srv/www/apps, /srv/www/apps, /srv/www, ... until we find a
120
+     * valid web root
121
+     *
122
+     * @param string $root
123
+     * @return string|null The web root or null on failure
124
+     */
125
+    protected function findWebRoot($root) {
126
+        $webRoot = null;
127
+        $tmpRoot = $root;
128
+
129
+        while ($webRoot === null) {
130
+            if (isset($this->mapping[$tmpRoot])) {
131
+                $webRoot = $this->mapping[$tmpRoot];
132
+                break;
133
+            }
134
+
135
+            if ($tmpRoot === '/') {
136
+                break;
137
+            }
138
+
139
+            $tmpRoot = dirname($tmpRoot);
140
+        }
141
+
142
+        if ($webRoot === null) {
143
+            $realpath = realpath($root);
144
+
145
+            if ($realpath && ($realpath !== $root)) {
146
+                return $this->findWebRoot($realpath);
147
+            }
148
+        }
149
+
150
+        return $webRoot;
151
+    }
152
+
153
+    /**
154
+     * append the $file resource at $root
155
+     *
156
+     * @param string $root path to check
157
+     * @param string $file the filename
158
+     * @param string|null $webRoot base for path, default map $root to $webRoot
159
+     * @param bool $throw Throw an exception, when the route does not exist
160
+     * @throws ResourceNotFoundException Only thrown when $throw is true and the resource is missing
161
+     */
162
+    protected function append($root, $file, $webRoot = null, $throw = true) {
163
+
164
+        if (!is_string($root)) {
165
+            if ($throw) {
166
+                throw new ResourceNotFoundException($file, $webRoot);
167
+            }
168
+            return;
169
+        }
170
+
171
+        if (!$webRoot) {
172
+            $webRoot = $this->findWebRoot($root);
173
+
174
+            if ($webRoot === null) {
175
+                $webRoot = '';
176
+                $this->logger->error('ResourceLocator can not find a web root (root: {root}, file: {file}, webRoot: {webRoot}, throw: {throw})', [
177
+                    'app' => 'lib',
178
+                    'root' => $root,
179
+                    'file' => $file,
180
+                    'webRoot' => $webRoot,
181
+                    'throw' => $throw ? 'true' : 'false'
182
+                ]);
183
+            }
184
+        }
185
+        $this->resources[] = array($root, $webRoot, $file);
186
+
187
+        if ($throw && !is_file($root . '/' . $file)) {
188
+            throw new ResourceNotFoundException($file, $webRoot);
189
+        }
190
+    }
191
+
192
+    /**
193
+     * Returns the list of all resources that should be loaded
194
+     * @return array
195
+     */
196
+    public function getResources() {
197
+        return $this->resources;
198
+    }
199 199
 }
Please login to merge, or discard this patch.