File tree Expand file tree Collapse file tree 4 files changed +17
-9
lines changed
Expand file tree Collapse file tree 4 files changed +17
-9
lines changed Original file line number Diff line number Diff line change @@ -140,7 +140,7 @@ protected function validate(StorageConfig $storage) {
140140 $ backend = $ storage ->getBackend ();
141141 /** @var AuthMechanism */
142142 $ authMechanism = $ storage ->getAuthMechanism ();
143- if ($ backend ->checkDependencies ()) {
143+ if ($ backend ->checkRequiredDependencies ()) {
144144 // invalid backend
145145 return new DataResponse (
146146 [
Original file line number Diff line number Diff line change 1313trait DependencyTrait {
1414
1515 /**
16- * Check if object is valid for use
16+ * Check if object has unsatisfied required or optional dependencies
1717 *
1818 * @return MissingDependency[] Unsatisfied dependencies
1919 */
2020 public function checkDependencies () {
2121 return []; // no dependencies by default
2222 }
23+
24+ /**
25+ * Check if object has unsatisfied required dependencies
26+ *
27+ * @return MissingDependency[] Unsatisfied required dependencies
28+ */
29+ public function checkRequiredDependencies () {
30+ return array_filter (
31+ $ this ->checkDependencies (),
32+ fn (MissingDependency $ dependency ) => !$ dependency ->isOptional ()
33+ );
34+ }
2335}
Original file line number Diff line number Diff line change 1313use OCA \Files_External \Lib \Backend \Backend ;
1414use OCA \Files_External \Lib \Config \IAuthMechanismProvider ;
1515use OCA \Files_External \Lib \Config \IBackendProvider ;
16- use OCA \Files_External \Lib \MissingDependency ;
1716use OCP \EventDispatcher \GenericEvent ;
1817use OCP \EventDispatcher \IEventDispatcher ;
1918use OCP \IAppConfig ;
@@ -188,10 +187,7 @@ public function getBackends() {
188187 * @return Backend[]
189188 */
190189 public function getAvailableBackends () {
191- return array_filter ($ this ->getBackends (), function ($ backend ) {
192- $ missing = array_filter ($ backend ->checkDependencies (), fn (MissingDependency $ dependency ) => !$ dependency ->isOptional ());
193- return count ($ missing ) === 0 ;
194- });
190+ return array_filter ($ this ->getBackends (), fn (Backend $ backend ) => !$ backend ->checkRequiredDependencies ());
195191 }
196192
197193 /**
Original file line number Diff line number Diff line change @@ -175,11 +175,11 @@ public function testGetAvailableBackends(): void {
175175
176176 $ backendAvailable = $ this ->getBackendMock ('\Backend\Available ' );
177177 $ backendAvailable ->expects ($ this ->once ())
178- ->method ('checkDependencies ' )
178+ ->method ('checkRequiredDependencies ' )
179179 ->willReturn ([]);
180180 $ backendNotAvailable = $ this ->getBackendMock ('\Backend\NotAvailable ' );
181181 $ backendNotAvailable ->expects ($ this ->once ())
182- ->method ('checkDependencies ' )
182+ ->method ('checkRequiredDependencies ' )
183183 ->willReturn ([
184184 $ this ->getMockBuilder ('\OCA\Files_External\Lib\MissingDependency ' )
185185 ->disableOriginalConstructor ()
You can’t perform that action at this time.
0 commit comments