Passed
Push — master ( 730af0...3b14ce )
by Roeland
12:25 queued 11s
created
apps/files_external/lib/Lib/FrontendDefinitionTrait.php 1 patch
Indentation   +124 added lines, -124 removed lines patch added patch discarded remove patch
@@ -31,129 +31,129 @@
 block discarded – undo
31 31
  */
32 32
 trait FrontendDefinitionTrait {
33 33
 
34
-	/** @var string human-readable mechanism name */
35
-	private $text;
36
-
37
-	/** @var DefinitionParameter[] parameters for mechanism */
38
-	private $parameters = [];
39
-
40
-	/** @var string[] custom JS */
41
-	private $customJs = [];
42
-
43
-	/**
44
-	 * @return string
45
-	 */
46
-	public function getText() {
47
-		return $this->text;
48
-	}
49
-
50
-	/**
51
-	 * @param string $text
52
-	 * @return $this
53
-	 */
54
-	public function setText($text) {
55
-		$this->text = $text;
56
-		return $this;
57
-	}
58
-
59
-	/**
60
-	 * @param FrontendDefinitionTrait $a
61
-	 * @param FrontendDefinitionTrait $b
62
-	 * @return int
63
-	 */
64
-	public static function lexicalCompare(FrontendDefinitionTrait $a, FrontendDefinitionTrait $b) {
65
-		return strcmp($a->getText(), $b->getText());
66
-	}
67
-
68
-	/**
69
-	 * @return DefinitionParameter[]
70
-	 */
71
-	public function getParameters() {
72
-		return $this->parameters;
73
-	}
74
-
75
-	/**
76
-	 * @param DefinitionParameter[] $parameters
77
-	 * @return self
78
-	 */
79
-	public function addParameters(array $parameters) {
80
-		foreach ($parameters as $parameter) {
81
-			$this->addParameter($parameter);
82
-		}
83
-		return $this;
84
-	}
85
-
86
-	/**
87
-	 * @param DefinitionParameter $parameter
88
-	 * @return self
89
-	 */
90
-	public function addParameter(DefinitionParameter $parameter) {
91
-		$this->parameters[$parameter->getName()] = $parameter;
92
-		return $this;
93
-	}
94
-
95
-	/**
96
-	 * @return string[]
97
-	 */
98
-	public function getCustomJs() {
99
-		return $this->customJs;
100
-	}
101
-
102
-	/**
103
-	 * @param string $custom
104
-	 * @return self
105
-	 */
106
-	public function addCustomJs($custom) {
107
-		$this->customJs[] = $custom;
108
-		return $this;
109
-	}
110
-
111
-	/**
112
-	 * @param string $custom
113
-	 * @return self
114
-	 * @deprecated 9.1.0, use addCustomJs() instead
115
-	 */
116
-	public function setCustomJs($custom) {
117
-		$this->customJs = [$custom];
118
-		return $this;
119
-	}
120
-
121
-	/**
122
-	 * Serialize into JSON for client-side JS
123
-	 *
124
-	 * @return array
125
-	 */
126
-	public function jsonSerializeDefinition() {
127
-		$configuration = [];
128
-		foreach ($this->getParameters() as $parameter) {
129
-			$configuration[$parameter->getName()] = $parameter;
130
-		}
131
-
132
-		$data = [
133
-			'name' => $this->getText(),
134
-			'configuration' => $configuration,
135
-			'custom' => $this->getCustomJs(),
136
-		];
137
-		return $data;
138
-	}
139
-
140
-	/**
141
-	 * Check if parameters are satisfied in a StorageConfig
142
-	 *
143
-	 * @param StorageConfig $storage
144
-	 * @return bool
145
-	 */
146
-	public function validateStorageDefinition(StorageConfig $storage) {
147
-		foreach ($this->getParameters() as $name => $parameter) {
148
-			$value = $storage->getBackendOption($name);
149
-			if (!is_null($value) || !$parameter->isOptional()) {
150
-				if (!$parameter->validateValue($value)) {
151
-					return false;
152
-				}
153
-				$storage->setBackendOption($name, $value);
154
-			}
155
-		}
156
-		return true;
157
-	}
34
+    /** @var string human-readable mechanism name */
35
+    private $text;
36
+
37
+    /** @var DefinitionParameter[] parameters for mechanism */
38
+    private $parameters = [];
39
+
40
+    /** @var string[] custom JS */
41
+    private $customJs = [];
42
+
43
+    /**
44
+     * @return string
45
+     */
46
+    public function getText() {
47
+        return $this->text;
48
+    }
49
+
50
+    /**
51
+     * @param string $text
52
+     * @return $this
53
+     */
54
+    public function setText($text) {
55
+        $this->text = $text;
56
+        return $this;
57
+    }
58
+
59
+    /**
60
+     * @param FrontendDefinitionTrait $a
61
+     * @param FrontendDefinitionTrait $b
62
+     * @return int
63
+     */
64
+    public static function lexicalCompare(FrontendDefinitionTrait $a, FrontendDefinitionTrait $b) {
65
+        return strcmp($a->getText(), $b->getText());
66
+    }
67
+
68
+    /**
69
+     * @return DefinitionParameter[]
70
+     */
71
+    public function getParameters() {
72
+        return $this->parameters;
73
+    }
74
+
75
+    /**
76
+     * @param DefinitionParameter[] $parameters
77
+     * @return self
78
+     */
79
+    public function addParameters(array $parameters) {
80
+        foreach ($parameters as $parameter) {
81
+            $this->addParameter($parameter);
82
+        }
83
+        return $this;
84
+    }
85
+
86
+    /**
87
+     * @param DefinitionParameter $parameter
88
+     * @return self
89
+     */
90
+    public function addParameter(DefinitionParameter $parameter) {
91
+        $this->parameters[$parameter->getName()] = $parameter;
92
+        return $this;
93
+    }
94
+
95
+    /**
96
+     * @return string[]
97
+     */
98
+    public function getCustomJs() {
99
+        return $this->customJs;
100
+    }
101
+
102
+    /**
103
+     * @param string $custom
104
+     * @return self
105
+     */
106
+    public function addCustomJs($custom) {
107
+        $this->customJs[] = $custom;
108
+        return $this;
109
+    }
110
+
111
+    /**
112
+     * @param string $custom
113
+     * @return self
114
+     * @deprecated 9.1.0, use addCustomJs() instead
115
+     */
116
+    public function setCustomJs($custom) {
117
+        $this->customJs = [$custom];
118
+        return $this;
119
+    }
120
+
121
+    /**
122
+     * Serialize into JSON for client-side JS
123
+     *
124
+     * @return array
125
+     */
126
+    public function jsonSerializeDefinition() {
127
+        $configuration = [];
128
+        foreach ($this->getParameters() as $parameter) {
129
+            $configuration[$parameter->getName()] = $parameter;
130
+        }
131
+
132
+        $data = [
133
+            'name' => $this->getText(),
134
+            'configuration' => $configuration,
135
+            'custom' => $this->getCustomJs(),
136
+        ];
137
+        return $data;
138
+    }
139
+
140
+    /**
141
+     * Check if parameters are satisfied in a StorageConfig
142
+     *
143
+     * @param StorageConfig $storage
144
+     * @return bool
145
+     */
146
+    public function validateStorageDefinition(StorageConfig $storage) {
147
+        foreach ($this->getParameters() as $name => $parameter) {
148
+            $value = $storage->getBackendOption($name);
149
+            if (!is_null($value) || !$parameter->isOptional()) {
150
+                if (!$parameter->validateValue($value)) {
151
+                    return false;
152
+                }
153
+                $storage->setBackendOption($name, $value);
154
+            }
155
+        }
156
+        return true;
157
+    }
158 158
 
159 159
 }
Please login to merge, or discard this patch.
files_external/lib/Lib/InsufficientDataForMeaningfulAnswerException.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -29,15 +29,15 @@
 block discarded – undo
29 29
  * Authentication mechanism or backend has insufficient data
30 30
  */
31 31
 class InsufficientDataForMeaningfulAnswerException extends StorageNotAvailableException {
32
-	/**
33
-	 * StorageNotAvailableException constructor.
34
-	 *
35
-	 * @param string $message
36
-	 * @param int $code
37
-	 * @param \Exception|null $previous
38
-	 * @since 6.0.0
39
-	 */
40
-	public function __construct($message = '', $code = self::STATUS_INDETERMINATE, \Exception $previous = null) {
41
-		parent::__construct($message, $code, $previous);
42
-	}
32
+    /**
33
+     * StorageNotAvailableException constructor.
34
+     *
35
+     * @param string $message
36
+     * @param int $code
37
+     * @param \Exception|null $previous
38
+     * @since 6.0.0
39
+     */
40
+    public function __construct($message = '', $code = self::STATUS_INDETERMINATE, \Exception $previous = null) {
41
+        parent::__construct($message, $code, $previous);
42
+    }
43 43
 }
Please login to merge, or discard this patch.
apps/files_external/lib/Lib/IdentifierTrait.php 1 patch
Indentation   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -28,76 +28,76 @@
 block discarded – undo
28 28
  */
29 29
 trait IdentifierTrait {
30 30
 
31
-	/** @var string */
32
-	protected $identifier;
31
+    /** @var string */
32
+    protected $identifier;
33 33
 
34
-	/** @var string[] */
35
-	protected $identifierAliases = [];
34
+    /** @var string[] */
35
+    protected $identifierAliases = [];
36 36
 
37
-	/** @var IdentifierTrait */
38
-	protected $deprecateTo = null;
37
+    /** @var IdentifierTrait */
38
+    protected $deprecateTo = null;
39 39
 
40
-	/**
41
-	 * @return string
42
-	 */
43
-	public function getIdentifier() {
44
-		return $this->identifier;
45
-	}
40
+    /**
41
+     * @return string
42
+     */
43
+    public function getIdentifier() {
44
+        return $this->identifier;
45
+    }
46 46
 
47
-	/**
48
-	 * @param string $identifier
49
-	 * @return $this
50
-	 */
51
-	public function setIdentifier($identifier) {
52
-		$this->identifier = $identifier;
53
-		$this->identifierAliases[] = $identifier;
54
-		return $this;
55
-	}
47
+    /**
48
+     * @param string $identifier
49
+     * @return $this
50
+     */
51
+    public function setIdentifier($identifier) {
52
+        $this->identifier = $identifier;
53
+        $this->identifierAliases[] = $identifier;
54
+        return $this;
55
+    }
56 56
 
57
-	/**
58
-	 * @return string[]
59
-	 */
60
-	public function getIdentifierAliases() {
61
-		return $this->identifierAliases;
62
-	}
57
+    /**
58
+     * @return string[]
59
+     */
60
+    public function getIdentifierAliases() {
61
+        return $this->identifierAliases;
62
+    }
63 63
 
64
-	/**
65
-	 * @param string $alias
66
-	 * @return $this
67
-	 */
68
-	public function addIdentifierAlias($alias) {
69
-		$this->identifierAliases[] = $alias;
70
-		return $this;
71
-	}
64
+    /**
65
+     * @param string $alias
66
+     * @return $this
67
+     */
68
+    public function addIdentifierAlias($alias) {
69
+        $this->identifierAliases[] = $alias;
70
+        return $this;
71
+    }
72 72
 
73
-	/**
74
-	 * @return object|null
75
-	 */
76
-	public function getDeprecateTo() {
77
-		return $this->deprecateTo;
78
-	}
73
+    /**
74
+     * @return object|null
75
+     */
76
+    public function getDeprecateTo() {
77
+        return $this->deprecateTo;
78
+    }
79 79
 
80
-	/**
81
-	 * @param object $destinationObject
82
-	 * @return self
83
-	 */
84
-	public function deprecateTo($destinationObject) {
85
-		$this->deprecateTo = $destinationObject;
86
-		return $this;
87
-	}
80
+    /**
81
+     * @param object $destinationObject
82
+     * @return self
83
+     */
84
+    public function deprecateTo($destinationObject) {
85
+        $this->deprecateTo = $destinationObject;
86
+        return $this;
87
+    }
88 88
 
89
-	/**
90
-	 * @return array
91
-	 */
92
-	public function jsonSerializeIdentifier() {
93
-		$data = [
94
-			'identifier' => $this->identifier,
95
-			'identifierAliases' => $this->identifierAliases,
96
-		];
97
-		if ($this->deprecateTo) {
98
-			$data['deprecateTo'] = $this->deprecateTo->getIdentifier();
99
-		}
100
-		return $data;
101
-	}
89
+    /**
90
+     * @return array
91
+     */
92
+    public function jsonSerializeIdentifier() {
93
+        $data = [
94
+            'identifier' => $this->identifier,
95
+            'identifierAliases' => $this->identifierAliases,
96
+        ];
97
+        if ($this->deprecateTo) {
98
+            $data['deprecateTo'] = $this->deprecateTo->getIdentifier();
99
+        }
100
+        return $data;
101
+    }
102 102
 
103 103
 }
Please login to merge, or discard this patch.
apps/files_external/lib/Command/Applicable.php 1 patch
Indentation   +107 added lines, -107 removed lines patch added patch discarded remove patch
@@ -35,122 +35,122 @@
 block discarded – undo
35 35
 use Symfony\Component\Console\Output\OutputInterface;
36 36
 
37 37
 class Applicable extends Base {
38
-	/**
39
-	 * @var GlobalStoragesService
40
-	 */
41
-	protected $globalService;
38
+    /**
39
+     * @var GlobalStoragesService
40
+     */
41
+    protected $globalService;
42 42
 
43
-	/**
44
-	 * @var IUserManager
45
-	 */
46
-	private $userManager;
43
+    /**
44
+     * @var IUserManager
45
+     */
46
+    private $userManager;
47 47
 
48
-	/**
49
-	 * @var IGroupManager
50
-	 */
51
-	private $groupManager;
48
+    /**
49
+     * @var IGroupManager
50
+     */
51
+    private $groupManager;
52 52
 
53
-	function __construct(
54
-		GlobalStoragesService $globalService,
55
-		IUserManager $userManager,
56
-		IGroupManager $groupManager
57
-	) {
58
-		parent::__construct();
59
-		$this->globalService = $globalService;
60
-		$this->userManager = $userManager;
61
-		$this->groupManager = $groupManager;
62
-	}
53
+    function __construct(
54
+        GlobalStoragesService $globalService,
55
+        IUserManager $userManager,
56
+        IGroupManager $groupManager
57
+    ) {
58
+        parent::__construct();
59
+        $this->globalService = $globalService;
60
+        $this->userManager = $userManager;
61
+        $this->groupManager = $groupManager;
62
+    }
63 63
 
64
-	protected function configure() {
65
-		$this
66
-			->setName('files_external:applicable')
67
-			->setDescription('Manage applicable users and groups for a mount')
68
-			->addArgument(
69
-				'mount_id',
70
-				InputArgument::REQUIRED,
71
-				'The id of the mount to edit'
72
-			)->addOption(
73
-				'add-user',
74
-				'',
75
-				InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED,
76
-				'user to add as applicable'
77
-			)->addOption(
78
-				'remove-user',
79
-				'',
80
-				InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED,
81
-				'user to remove as applicable'
82
-			)->addOption(
83
-				'add-group',
84
-				'',
85
-				InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED,
86
-				'group to add as applicable'
87
-			)->addOption(
88
-				'remove-group',
89
-				'',
90
-				InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED,
91
-				'group to remove as applicable'
92
-			)->addOption(
93
-				'remove-all',
94
-				'',
95
-				InputOption::VALUE_NONE,
96
-				'Set the mount to be globally applicable'
97
-			);
98
-		parent::configure();
99
-	}
64
+    protected function configure() {
65
+        $this
66
+            ->setName('files_external:applicable')
67
+            ->setDescription('Manage applicable users and groups for a mount')
68
+            ->addArgument(
69
+                'mount_id',
70
+                InputArgument::REQUIRED,
71
+                'The id of the mount to edit'
72
+            )->addOption(
73
+                'add-user',
74
+                '',
75
+                InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED,
76
+                'user to add as applicable'
77
+            )->addOption(
78
+                'remove-user',
79
+                '',
80
+                InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED,
81
+                'user to remove as applicable'
82
+            )->addOption(
83
+                'add-group',
84
+                '',
85
+                InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED,
86
+                'group to add as applicable'
87
+            )->addOption(
88
+                'remove-group',
89
+                '',
90
+                InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED,
91
+                'group to remove as applicable'
92
+            )->addOption(
93
+                'remove-all',
94
+                '',
95
+                InputOption::VALUE_NONE,
96
+                'Set the mount to be globally applicable'
97
+            );
98
+        parent::configure();
99
+    }
100 100
 
101
-	protected function execute(InputInterface $input, OutputInterface $output) {
102
-		$mountId = $input->getArgument('mount_id');
103
-		try {
104
-			$mount = $this->globalService->getStorage($mountId);
105
-		} catch (NotFoundException $e) {
106
-			$output->writeln('<error>Mount with id "' . $mountId . ' not found, check "occ files_external:list" to get available mounts</error>');
107
-			return 404;
108
-		}
101
+    protected function execute(InputInterface $input, OutputInterface $output) {
102
+        $mountId = $input->getArgument('mount_id');
103
+        try {
104
+            $mount = $this->globalService->getStorage($mountId);
105
+        } catch (NotFoundException $e) {
106
+            $output->writeln('<error>Mount with id "' . $mountId . ' not found, check "occ files_external:list" to get available mounts</error>');
107
+            return 404;
108
+        }
109 109
 
110
-		if ($mount->getType() === StorageConfig::MOUNT_TYPE_PERSONAl) {
111
-			$output->writeln('<error>Can\'t change applicables on personal mounts</error>');
112
-			return 1;
113
-		}
110
+        if ($mount->getType() === StorageConfig::MOUNT_TYPE_PERSONAl) {
111
+            $output->writeln('<error>Can\'t change applicables on personal mounts</error>');
112
+            return 1;
113
+        }
114 114
 
115
-		$addUsers = $input->getOption('add-user');
116
-		$removeUsers = $input->getOption('remove-user');
117
-		$addGroups = $input->getOption('add-group');
118
-		$removeGroups = $input->getOption('remove-group');
115
+        $addUsers = $input->getOption('add-user');
116
+        $removeUsers = $input->getOption('remove-user');
117
+        $addGroups = $input->getOption('add-group');
118
+        $removeGroups = $input->getOption('remove-group');
119 119
 
120
-		$applicableUsers = $mount->getApplicableUsers();
121
-		$applicableGroups = $mount->getApplicableGroups();
120
+        $applicableUsers = $mount->getApplicableUsers();
121
+        $applicableGroups = $mount->getApplicableGroups();
122 122
 
123
-		if ((count($addUsers) + count($removeUsers) + count($addGroups) + count($removeGroups) > 0) || $input->getOption('remove-all')) {
124
-			foreach ($addUsers as $addUser) {
125
-				if (!$this->userManager->userExists($addUser)) {
126
-					$output->writeln('<error>User "' . $addUser . '" not found</error>');
127
-					return 404;
128
-				}
129
-			}
130
-			foreach ($addGroups as $addGroup) {
131
-				if (!$this->groupManager->groupExists($addGroup)) {
132
-					$output->writeln('<error>Group "' . $addGroup . '" not found</error>');
133
-					return 404;
134
-				}
135
-			}
123
+        if ((count($addUsers) + count($removeUsers) + count($addGroups) + count($removeGroups) > 0) || $input->getOption('remove-all')) {
124
+            foreach ($addUsers as $addUser) {
125
+                if (!$this->userManager->userExists($addUser)) {
126
+                    $output->writeln('<error>User "' . $addUser . '" not found</error>');
127
+                    return 404;
128
+                }
129
+            }
130
+            foreach ($addGroups as $addGroup) {
131
+                if (!$this->groupManager->groupExists($addGroup)) {
132
+                    $output->writeln('<error>Group "' . $addGroup . '" not found</error>');
133
+                    return 404;
134
+                }
135
+            }
136 136
 
137
-			if ($input->getOption('remove-all')) {
138
-				$applicableUsers = [];
139
-				$applicableGroups = [];
140
-			} else {
141
-				$applicableUsers = array_unique(array_merge($applicableUsers, $addUsers));
142
-				$applicableUsers = array_values(array_diff($applicableUsers, $removeUsers));
143
-				$applicableGroups = array_unique(array_merge($applicableGroups, $addGroups));
144
-				$applicableGroups = array_values(array_diff($applicableGroups, $removeGroups));
145
-			}
146
-			$mount->setApplicableUsers($applicableUsers);
147
-			$mount->setApplicableGroups($applicableGroups);
148
-			$this->globalService->updateStorage($mount);
149
-		}
137
+            if ($input->getOption('remove-all')) {
138
+                $applicableUsers = [];
139
+                $applicableGroups = [];
140
+            } else {
141
+                $applicableUsers = array_unique(array_merge($applicableUsers, $addUsers));
142
+                $applicableUsers = array_values(array_diff($applicableUsers, $removeUsers));
143
+                $applicableGroups = array_unique(array_merge($applicableGroups, $addGroups));
144
+                $applicableGroups = array_values(array_diff($applicableGroups, $removeGroups));
145
+            }
146
+            $mount->setApplicableUsers($applicableUsers);
147
+            $mount->setApplicableGroups($applicableGroups);
148
+            $this->globalService->updateStorage($mount);
149
+        }
150 150
 
151
-		$this->writeArrayInOutputFormat($input, $output, [
152
-			'users' => $applicableUsers,
153
-			'groups' => $applicableGroups
154
-		]);
155
-	}
151
+        $this->writeArrayInOutputFormat($input, $output, [
152
+            'users' => $applicableUsers,
153
+            'groups' => $applicableGroups
154
+        ]);
155
+    }
156 156
 }
Please login to merge, or discard this patch.
apps/files_external/lib/Command/Create.php 1 patch
Indentation   +178 added lines, -178 removed lines patch added patch discarded remove patch
@@ -42,182 +42,182 @@
 block discarded – undo
42 42
 use Symfony\Component\Console\Output\OutputInterface;
43 43
 
44 44
 class Create extends Base {
45
-	/**
46
-	 * @var GlobalStoragesService
47
-	 */
48
-	private $globalService;
49
-
50
-	/**
51
-	 * @var UserStoragesService
52
-	 */
53
-	private $userService;
54
-
55
-	/**
56
-	 * @var IUserManager
57
-	 */
58
-	private $userManager;
59
-
60
-	/** @var BackendService */
61
-	private $backendService;
62
-
63
-	/** @var IUserSession */
64
-	private $userSession;
65
-
66
-	function __construct(GlobalStoragesService $globalService,
67
-						 UserStoragesService $userService,
68
-						 IUserManager $userManager,
69
-						 IUserSession $userSession,
70
-						 BackendService $backendService
71
-	) {
72
-		parent::__construct();
73
-		$this->globalService = $globalService;
74
-		$this->userService = $userService;
75
-		$this->userManager = $userManager;
76
-		$this->userSession = $userSession;
77
-		$this->backendService = $backendService;
78
-	}
79
-
80
-	protected function configure() {
81
-		$this
82
-			->setName('files_external:create')
83
-			->setDescription('Create a new mount configuration')
84
-			->addOption(
85
-				'user',
86
-				'',
87
-				InputOption::VALUE_OPTIONAL,
88
-				'user to add the mount configuration for, if not set the mount will be added as system mount'
89
-			)
90
-			->addArgument(
91
-				'mount_point',
92
-				InputArgument::REQUIRED,
93
-				'mount point for the new mount'
94
-			)
95
-			->addArgument(
96
-				'storage_backend',
97
-				InputArgument::REQUIRED,
98
-				'storage backend identifier for the new mount, see `occ files_external:backends` for possible values'
99
-			)
100
-			->addArgument(
101
-				'authentication_backend',
102
-				InputArgument::REQUIRED,
103
-				'authentication backend identifier for the new mount, see `occ files_external:backends` for possible values'
104
-			)
105
-			->addOption(
106
-				'config',
107
-				'c',
108
-				InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY,
109
-				'Mount configuration option in key=value format'
110
-			)
111
-			->addOption(
112
-				'dry',
113
-				'',
114
-				InputOption::VALUE_NONE,
115
-				'Don\'t save the created mount, only list the new mount'
116
-			);
117
-		parent::configure();
118
-	}
119
-
120
-	protected function execute(InputInterface $input, OutputInterface $output) {
121
-		$user = $input->getOption('user');
122
-		$mountPoint = $input->getArgument('mount_point');
123
-		$storageIdentifier = $input->getArgument('storage_backend');
124
-		$authIdentifier = $input->getArgument('authentication_backend');
125
-		$configInput = $input->getOption('config');
126
-
127
-		$storageBackend = $this->backendService->getBackend($storageIdentifier);
128
-		$authBackend = $this->backendService->getAuthMechanism($authIdentifier);
129
-
130
-		if (!Filesystem::isValidPath($mountPoint)) {
131
-			$output->writeln('<error>Invalid mountpoint "' . $mountPoint . '"</error>');
132
-			return 1;
133
-		}
134
-		if (is_null($storageBackend)) {
135
-			$output->writeln('<error>Storage backend with identifier "' . $storageIdentifier . '" not found (see `occ files_external:backends` for possible values)</error>');
136
-			return 404;
137
-		}
138
-		if (is_null($authBackend)) {
139
-			$output->writeln('<error>Authentication backend with identifier "' . $authIdentifier . '" not found (see `occ files_external:backends` for possible values)</error>');
140
-			return 404;
141
-		}
142
-		$supportedSchemes = array_keys($storageBackend->getAuthSchemes());
143
-		if (!in_array($authBackend->getScheme(), $supportedSchemes)) {
144
-			$output->writeln('<error>Authentication backend "' . $authIdentifier . '" not valid for storage backend "' . $storageIdentifier . '" (see `occ files_external:backends storage ' . $storageIdentifier . '` for possible values)</error>');
145
-			return 1;
146
-		}
147
-
148
-		$config = [];
149
-		foreach ($configInput as $configOption) {
150
-			if (!strpos($configOption, '=')) {
151
-				$output->writeln('<error>Invalid mount configuration option "' . $configOption . '"</error>');
152
-				return 1;
153
-			}
154
-			list($key, $value) = explode('=', $configOption, 2);
155
-			if (!$this->validateParam($key, $value, $storageBackend, $authBackend)) {
156
-				$output->writeln('<error>Unknown configuration for backends "' . $key . '"</error>');
157
-				return 1;
158
-			}
159
-			$config[$key] = $value;
160
-		}
161
-
162
-		$mount = new StorageConfig();
163
-		$mount->setMountPoint($mountPoint);
164
-		$mount->setBackend($storageBackend);
165
-		$mount->setAuthMechanism($authBackend);
166
-		$mount->setBackendOptions($config);
167
-
168
-		if ($user) {
169
-			if (!$this->userManager->userExists($user)) {
170
-				$output->writeln('<error>User "' . $user . '" not found</error>');
171
-				return 1;
172
-			}
173
-			$mount->setApplicableUsers([$user]);
174
-		}
175
-
176
-		if ($input->getOption('dry')) {
177
-			$this->showMount($user, $mount, $input, $output);
178
-		} else {
179
-			$this->getStorageService($user)->addStorage($mount);
180
-			if ($input->getOption('output') === self::OUTPUT_FORMAT_PLAIN) {
181
-				$output->writeln('<info>Storage created with id ' . $mount->getId() . '</info>');
182
-			} else {
183
-				$output->writeln((string)$mount->getId());
184
-			}
185
-		}
186
-		return 0;
187
-	}
188
-
189
-	private function validateParam($key, &$value, Backend $storageBackend, AuthMechanism $authBackend) {
190
-		$params = array_merge($storageBackend->getParameters(), $authBackend->getParameters());
191
-		foreach ($params as $param) {
192
-			/** @var DefinitionParameter $param */
193
-			if ($param->getName() === $key) {
194
-				if ($param->getType() === DefinitionParameter::VALUE_BOOLEAN) {
195
-					$value = ($value === 'true');
196
-				}
197
-				return true;
198
-			}
199
-		}
200
-		return false;
201
-	}
202
-
203
-	private function showMount($user, StorageConfig $mount, InputInterface $input, OutputInterface $output) {
204
-		$listCommand = new ListCommand($this->globalService, $this->userService, $this->userSession, $this->userManager);
205
-		$listInput = new ArrayInput([], $listCommand->getDefinition());
206
-		$listInput->setOption('output', $input->getOption('output'));
207
-		$listInput->setOption('show-password', true);
208
-		$listCommand->listMounts($user, [$mount], $listInput, $output);
209
-	}
210
-
211
-	protected function getStorageService($userId) {
212
-		if (!empty($userId)) {
213
-			$user = $this->userManager->get($userId);
214
-			if (is_null($user)) {
215
-				throw new NoUserException("user $userId not found");
216
-			}
217
-			$this->userSession->setUser($user);
218
-			return $this->userService;
219
-		} else {
220
-			return $this->globalService;
221
-		}
222
-	}
45
+    /**
46
+     * @var GlobalStoragesService
47
+     */
48
+    private $globalService;
49
+
50
+    /**
51
+     * @var UserStoragesService
52
+     */
53
+    private $userService;
54
+
55
+    /**
56
+     * @var IUserManager
57
+     */
58
+    private $userManager;
59
+
60
+    /** @var BackendService */
61
+    private $backendService;
62
+
63
+    /** @var IUserSession */
64
+    private $userSession;
65
+
66
+    function __construct(GlobalStoragesService $globalService,
67
+                            UserStoragesService $userService,
68
+                            IUserManager $userManager,
69
+                            IUserSession $userSession,
70
+                            BackendService $backendService
71
+    ) {
72
+        parent::__construct();
73
+        $this->globalService = $globalService;
74
+        $this->userService = $userService;
75
+        $this->userManager = $userManager;
76
+        $this->userSession = $userSession;
77
+        $this->backendService = $backendService;
78
+    }
79
+
80
+    protected function configure() {
81
+        $this
82
+            ->setName('files_external:create')
83
+            ->setDescription('Create a new mount configuration')
84
+            ->addOption(
85
+                'user',
86
+                '',
87
+                InputOption::VALUE_OPTIONAL,
88
+                'user to add the mount configuration for, if not set the mount will be added as system mount'
89
+            )
90
+            ->addArgument(
91
+                'mount_point',
92
+                InputArgument::REQUIRED,
93
+                'mount point for the new mount'
94
+            )
95
+            ->addArgument(
96
+                'storage_backend',
97
+                InputArgument::REQUIRED,
98
+                'storage backend identifier for the new mount, see `occ files_external:backends` for possible values'
99
+            )
100
+            ->addArgument(
101
+                'authentication_backend',
102
+                InputArgument::REQUIRED,
103
+                'authentication backend identifier for the new mount, see `occ files_external:backends` for possible values'
104
+            )
105
+            ->addOption(
106
+                'config',
107
+                'c',
108
+                InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY,
109
+                'Mount configuration option in key=value format'
110
+            )
111
+            ->addOption(
112
+                'dry',
113
+                '',
114
+                InputOption::VALUE_NONE,
115
+                'Don\'t save the created mount, only list the new mount'
116
+            );
117
+        parent::configure();
118
+    }
119
+
120
+    protected function execute(InputInterface $input, OutputInterface $output) {
121
+        $user = $input->getOption('user');
122
+        $mountPoint = $input->getArgument('mount_point');
123
+        $storageIdentifier = $input->getArgument('storage_backend');
124
+        $authIdentifier = $input->getArgument('authentication_backend');
125
+        $configInput = $input->getOption('config');
126
+
127
+        $storageBackend = $this->backendService->getBackend($storageIdentifier);
128
+        $authBackend = $this->backendService->getAuthMechanism($authIdentifier);
129
+
130
+        if (!Filesystem::isValidPath($mountPoint)) {
131
+            $output->writeln('<error>Invalid mountpoint "' . $mountPoint . '"</error>');
132
+            return 1;
133
+        }
134
+        if (is_null($storageBackend)) {
135
+            $output->writeln('<error>Storage backend with identifier "' . $storageIdentifier . '" not found (see `occ files_external:backends` for possible values)</error>');
136
+            return 404;
137
+        }
138
+        if (is_null($authBackend)) {
139
+            $output->writeln('<error>Authentication backend with identifier "' . $authIdentifier . '" not found (see `occ files_external:backends` for possible values)</error>');
140
+            return 404;
141
+        }
142
+        $supportedSchemes = array_keys($storageBackend->getAuthSchemes());
143
+        if (!in_array($authBackend->getScheme(), $supportedSchemes)) {
144
+            $output->writeln('<error>Authentication backend "' . $authIdentifier . '" not valid for storage backend "' . $storageIdentifier . '" (see `occ files_external:backends storage ' . $storageIdentifier . '` for possible values)</error>');
145
+            return 1;
146
+        }
147
+
148
+        $config = [];
149
+        foreach ($configInput as $configOption) {
150
+            if (!strpos($configOption, '=')) {
151
+                $output->writeln('<error>Invalid mount configuration option "' . $configOption . '"</error>');
152
+                return 1;
153
+            }
154
+            list($key, $value) = explode('=', $configOption, 2);
155
+            if (!$this->validateParam($key, $value, $storageBackend, $authBackend)) {
156
+                $output->writeln('<error>Unknown configuration for backends "' . $key . '"</error>');
157
+                return 1;
158
+            }
159
+            $config[$key] = $value;
160
+        }
161
+
162
+        $mount = new StorageConfig();
163
+        $mount->setMountPoint($mountPoint);
164
+        $mount->setBackend($storageBackend);
165
+        $mount->setAuthMechanism($authBackend);
166
+        $mount->setBackendOptions($config);
167
+
168
+        if ($user) {
169
+            if (!$this->userManager->userExists($user)) {
170
+                $output->writeln('<error>User "' . $user . '" not found</error>');
171
+                return 1;
172
+            }
173
+            $mount->setApplicableUsers([$user]);
174
+        }
175
+
176
+        if ($input->getOption('dry')) {
177
+            $this->showMount($user, $mount, $input, $output);
178
+        } else {
179
+            $this->getStorageService($user)->addStorage($mount);
180
+            if ($input->getOption('output') === self::OUTPUT_FORMAT_PLAIN) {
181
+                $output->writeln('<info>Storage created with id ' . $mount->getId() . '</info>');
182
+            } else {
183
+                $output->writeln((string)$mount->getId());
184
+            }
185
+        }
186
+        return 0;
187
+    }
188
+
189
+    private function validateParam($key, &$value, Backend $storageBackend, AuthMechanism $authBackend) {
190
+        $params = array_merge($storageBackend->getParameters(), $authBackend->getParameters());
191
+        foreach ($params as $param) {
192
+            /** @var DefinitionParameter $param */
193
+            if ($param->getName() === $key) {
194
+                if ($param->getType() === DefinitionParameter::VALUE_BOOLEAN) {
195
+                    $value = ($value === 'true');
196
+                }
197
+                return true;
198
+            }
199
+        }
200
+        return false;
201
+    }
202
+
203
+    private function showMount($user, StorageConfig $mount, InputInterface $input, OutputInterface $output) {
204
+        $listCommand = new ListCommand($this->globalService, $this->userService, $this->userSession, $this->userManager);
205
+        $listInput = new ArrayInput([], $listCommand->getDefinition());
206
+        $listInput->setOption('output', $input->getOption('output'));
207
+        $listInput->setOption('show-password', true);
208
+        $listCommand->listMounts($user, [$mount], $listInput, $output);
209
+    }
210
+
211
+    protected function getStorageService($userId) {
212
+        if (!empty($userId)) {
213
+            $user = $this->userManager->get($userId);
214
+            if (is_null($user)) {
215
+                throw new NoUserException("user $userId not found");
216
+            }
217
+            $this->userSession->setUser($user);
218
+            return $this->userService;
219
+        } else {
220
+            return $this->globalService;
221
+        }
222
+    }
223 223
 }
Please login to merge, or discard this patch.
apps/files_external/lib/Command/Delete.php 1 patch
Indentation   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -37,76 +37,76 @@
 block discarded – undo
37 37
 use Symfony\Component\Console\Question\ConfirmationQuestion;
38 38
 
39 39
 class Delete extends Base {
40
-	/**
41
-	 * @var GlobalStoragesService
42
-	 */
43
-	protected $globalService;
40
+    /**
41
+     * @var GlobalStoragesService
42
+     */
43
+    protected $globalService;
44 44
 
45
-	/**
46
-	 * @var UserStoragesService
47
-	 */
48
-	protected $userService;
45
+    /**
46
+     * @var UserStoragesService
47
+     */
48
+    protected $userService;
49 49
 
50
-	/**
51
-	 * @var IUserSession
52
-	 */
53
-	protected $userSession;
50
+    /**
51
+     * @var IUserSession
52
+     */
53
+    protected $userSession;
54 54
 
55
-	/**
56
-	 * @var IUserManager
57
-	 */
58
-	protected $userManager;
55
+    /**
56
+     * @var IUserManager
57
+     */
58
+    protected $userManager;
59 59
 
60
-	function __construct(GlobalStoragesService $globalService, UserStoragesService $userService, IUserSession $userSession, IUserManager $userManager) {
61
-		parent::__construct();
62
-		$this->globalService = $globalService;
63
-		$this->userService = $userService;
64
-		$this->userSession = $userSession;
65
-		$this->userManager = $userManager;
66
-	}
60
+    function __construct(GlobalStoragesService $globalService, UserStoragesService $userService, IUserSession $userSession, IUserManager $userManager) {
61
+        parent::__construct();
62
+        $this->globalService = $globalService;
63
+        $this->userService = $userService;
64
+        $this->userSession = $userSession;
65
+        $this->userManager = $userManager;
66
+    }
67 67
 
68
-	protected function configure() {
69
-		$this
70
-			->setName('files_external:delete')
71
-			->setDescription('Delete an external mount')
72
-			->addArgument(
73
-				'mount_id',
74
-				InputArgument::REQUIRED,
75
-				'The id of the mount to edit'
76
-			)->addOption(
77
-				'yes',
78
-				'y',
79
-				InputOption::VALUE_NONE,
80
-				'Skip confirmation'
81
-			);
82
-		parent::configure();
83
-	}
68
+    protected function configure() {
69
+        $this
70
+            ->setName('files_external:delete')
71
+            ->setDescription('Delete an external mount')
72
+            ->addArgument(
73
+                'mount_id',
74
+                InputArgument::REQUIRED,
75
+                'The id of the mount to edit'
76
+            )->addOption(
77
+                'yes',
78
+                'y',
79
+                InputOption::VALUE_NONE,
80
+                'Skip confirmation'
81
+            );
82
+        parent::configure();
83
+    }
84 84
 
85
-	protected function execute(InputInterface $input, OutputInterface $output) {
86
-		$mountId = $input->getArgument('mount_id');
87
-		try {
88
-			$mount = $this->globalService->getStorage($mountId);
89
-		} catch (NotFoundException $e) {
90
-			$output->writeln('<error>Mount with id "' . $mountId . ' not found, check "occ files_external:list" to get available mounts"</error>');
91
-			return 404;
92
-		}
85
+    protected function execute(InputInterface $input, OutputInterface $output) {
86
+        $mountId = $input->getArgument('mount_id');
87
+        try {
88
+            $mount = $this->globalService->getStorage($mountId);
89
+        } catch (NotFoundException $e) {
90
+            $output->writeln('<error>Mount with id "' . $mountId . ' not found, check "occ files_external:list" to get available mounts"</error>');
91
+            return 404;
92
+        }
93 93
 
94
-		$noConfirm = $input->getOption('yes');
94
+        $noConfirm = $input->getOption('yes');
95 95
 
96
-		if (!$noConfirm) {
97
-			$listCommand = new ListCommand($this->globalService, $this->userService, $this->userSession, $this->userManager);
98
-			$listInput = new ArrayInput([], $listCommand->getDefinition());
99
-			$listInput->setOption('output', $input->getOption('output'));
100
-			$listCommand->listMounts(null, [$mount], $listInput, $output);
96
+        if (!$noConfirm) {
97
+            $listCommand = new ListCommand($this->globalService, $this->userService, $this->userSession, $this->userManager);
98
+            $listInput = new ArrayInput([], $listCommand->getDefinition());
99
+            $listInput->setOption('output', $input->getOption('output'));
100
+            $listCommand->listMounts(null, [$mount], $listInput, $output);
101 101
 
102
-			$questionHelper = $this->getHelper('question');
103
-			$question = new ConfirmationQuestion('Delete this mount? [y/N] ', false);
102
+            $questionHelper = $this->getHelper('question');
103
+            $question = new ConfirmationQuestion('Delete this mount? [y/N] ', false);
104 104
 
105
-			if (!$questionHelper->ask($input, $output, $question)) {
106
-				return null;
107
-			}
108
-		}
105
+            if (!$questionHelper->ask($input, $output, $question)) {
106
+                return null;
107
+            }
108
+        }
109 109
 
110
-		$this->globalService->removeStorage($mountId);
111
-	}
110
+        $this->globalService->removeStorage($mountId);
111
+    }
112 112
 }
Please login to merge, or discard this patch.
apps/testing/appinfo/routes.php 1 patch
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -21,62 +21,62 @@
 block discarded – undo
21 21
  */
22 22
 
23 23
 return [
24
-	'routes' => [
25
-		[
26
-			'name' => 'RateLimitTest#userAndAnonProtected',
27
-			'url' => '/userAndAnonProtected',
28
-			'verb' => 'GET',
29
-		],
30
-		[
31
-			'name' => 'RateLimitTest#onlyAnonProtected',
32
-			'url' => '/anonProtected',
33
-			'verb' => 'GET',
34
-		],
35
-	],
24
+    'routes' => [
25
+        [
26
+            'name' => 'RateLimitTest#userAndAnonProtected',
27
+            'url' => '/userAndAnonProtected',
28
+            'verb' => 'GET',
29
+        ],
30
+        [
31
+            'name' => 'RateLimitTest#onlyAnonProtected',
32
+            'url' => '/anonProtected',
33
+            'verb' => 'GET',
34
+        ],
35
+    ],
36 36
 
37
-	'ocs' => [
38
-		[
39
-			'name' => 'Config#setAppValue',
40
-			'url'  => '/api/v1/app/{appid}/{configkey}',
41
-			'verb' => 'POST',
42
-		],
43
-		[
44
-			'name' => 'Config#deleteAppValue',
45
-			'url'  => '/api/v1/app/{appid}/{configkey}',
46
-			'verb' => 'DELETE',
47
-		],
48
-		[
49
-			'name' => 'Locking#isLockingEnabled',
50
-			'url'  => '/api/v1/lockprovisioning',
51
-			'verb' => 'GET',
52
-		],
53
-		[
54
-			'name' => 'Locking#isLocked',
55
-			'url'  => '/api/v1/lockprovisioning/{type}/{user}',
56
-			'verb' => 'GET',
57
-		],
58
-		[
59
-			'name' => 'Locking#acquireLock',
60
-			'url'  => '/api/v1/lockprovisioning/{type}/{user}',
61
-			'verb' => 'POST',
62
-		],
63
-		[
64
-			'name' => 'Locking#changeLock',
65
-			'url'  => '/api/v1/lockprovisioning/{type}/{user}',
66
-			'verb' => 'PUT',
67
-		],
68
-		[
69
-			'name' => 'Locking#releaseLock',
70
-			'url'  => '/api/v1/lockprovisioning/{type}/{user}',
71
-			'verb' => 'DELETE',
72
-		],
73
-		[
74
-			'name' => 'Locking#releaseAll',
75
-			'url'  => '/api/v1/lockprovisioning/{type}',
76
-			'verb' => 'DELETE',
77
-			'defaults' => [
78
-				'type' => null
79
-			]
80
-		],
81
-	],
37
+    'ocs' => [
38
+        [
39
+            'name' => 'Config#setAppValue',
40
+            'url'  => '/api/v1/app/{appid}/{configkey}',
41
+            'verb' => 'POST',
42
+        ],
43
+        [
44
+            'name' => 'Config#deleteAppValue',
45
+            'url'  => '/api/v1/app/{appid}/{configkey}',
46
+            'verb' => 'DELETE',
47
+        ],
48
+        [
49
+            'name' => 'Locking#isLockingEnabled',
50
+            'url'  => '/api/v1/lockprovisioning',
51
+            'verb' => 'GET',
52
+        ],
53
+        [
54
+            'name' => 'Locking#isLocked',
55
+            'url'  => '/api/v1/lockprovisioning/{type}/{user}',
56
+            'verb' => 'GET',
57
+        ],
58
+        [
59
+            'name' => 'Locking#acquireLock',
60
+            'url'  => '/api/v1/lockprovisioning/{type}/{user}',
61
+            'verb' => 'POST',
62
+        ],
63
+        [
64
+            'name' => 'Locking#changeLock',
65
+            'url'  => '/api/v1/lockprovisioning/{type}/{user}',
66
+            'verb' => 'PUT',
67
+        ],
68
+        [
69
+            'name' => 'Locking#releaseLock',
70
+            'url'  => '/api/v1/lockprovisioning/{type}/{user}',
71
+            'verb' => 'DELETE',
72
+        ],
73
+        [
74
+            'name' => 'Locking#releaseAll',
75
+            'url'  => '/api/v1/lockprovisioning/{type}',
76
+            'verb' => 'DELETE',
77
+            'defaults' => [
78
+                'type' => null
79
+            ]
80
+        ],
81
+    ],
82 82
 ];
Please login to merge, or discard this patch.
lib/public/AppFramework/OCS/OCSNotFoundException.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -32,14 +32,14 @@
 block discarded – undo
32 32
  * @since 9.1.0
33 33
  */
34 34
 class OCSNotFoundException extends OCSException {
35
-	/**
36
-	 * OCSNotFoundException constructor.
37
-	 *
38
-	 * @param string $message
39
-	 * @param Exception|null $previous
40
-	 * @since 9.1.0
41
-	 */
42
-	public function __construct($message = '', Exception $previous = null) {
43
-		parent::__construct($message, Http::STATUS_NOT_FOUND, $previous);
44
-	}
35
+    /**
36
+     * OCSNotFoundException constructor.
37
+     *
38
+     * @param string $message
39
+     * @param Exception|null $previous
40
+     * @since 9.1.0
41
+     */
42
+    public function __construct($message = '', Exception $previous = null) {
43
+        parent::__construct($message, Http::STATUS_NOT_FOUND, $previous);
44
+    }
45 45
 }
Please login to merge, or discard this patch.
lib/public/AppFramework/OCS/OCSForbiddenException.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -32,14 +32,14 @@
 block discarded – undo
32 32
  * @since 9.1.0
33 33
  */
34 34
 class OCSForbiddenException extends OCSException {
35
-	/**
36
-	 * OCSForbiddenException constructor.
37
-	 *
38
-	 * @param string $message
39
-	 * @param Exception|null $previous
40
-	 * @since 9.1.0
41
-	 */
42
-	public function __construct($message = '', Exception $previous = null) {
43
-		parent::__construct($message, Http::STATUS_FORBIDDEN, $previous);
44
-	}
35
+    /**
36
+     * OCSForbiddenException constructor.
37
+     *
38
+     * @param string $message
39
+     * @param Exception|null $previous
40
+     * @since 9.1.0
41
+     */
42
+    public function __construct($message = '', Exception $previous = null) {
43
+        parent::__construct($message, Http::STATUS_FORBIDDEN, $previous);
44
+    }
45 45
 }
Please login to merge, or discard this patch.