Add extendedSupport to Subscription (#15922)
Add extendedSupport to Subscription
This commit is contained in:
commit
21d836364e
|
@ -97,6 +97,7 @@ class OCSController extends \OCP\AppFramework\OCSController {
|
|||
'micro' => $micro,
|
||||
'string' => \OC_Util::getVersionString(),
|
||||
'edition' => '',
|
||||
'extendedSupport' => \OCP\Util::hasExtendedSupport()
|
||||
);
|
||||
|
||||
if($this->userSession->isLoggedIn()) {
|
||||
|
|
|
@ -72,4 +72,16 @@ class Registry implements IRegistry {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if the subscription has extended support
|
||||
*
|
||||
* @since 17.0.0
|
||||
*/
|
||||
public function delegateHasExtendedSupport(): bool {
|
||||
if ($this->subscription instanceof ISubscription && method_exists($this->subscription, 'hasExtendedSupport')) {
|
||||
return $this->subscription->hasExtendedSupport();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,4 +54,11 @@ interface IRegistry {
|
|||
* @since 17.0.0
|
||||
*/
|
||||
public function delegateHasValidSubscription(): bool;
|
||||
|
||||
/**
|
||||
* Indicates if the subscription has extended support
|
||||
*
|
||||
* @since 17.0.0
|
||||
*/
|
||||
public function delegateHasExtendedSupport(): bool;
|
||||
}
|
||||
|
|
|
@ -34,4 +34,11 @@ interface ISubscription {
|
|||
* @since 17.0.0
|
||||
*/
|
||||
public function hasValidSubscription(): bool;
|
||||
|
||||
/**
|
||||
* Indicates if the subscription has extended support
|
||||
*
|
||||
* @since 17.0.0
|
||||
*/
|
||||
public function hasExtendedSupport(): bool;
|
||||
}
|
||||
|
|
|
@ -90,6 +90,18 @@ class Util {
|
|||
return \OC_Util::getVersion();
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 17.0.0
|
||||
*/
|
||||
public static function hasExtendedSupport(): bool {
|
||||
try {
|
||||
/** @var \OCP\Support\Subscription\IRegistry */
|
||||
$subscriptionRegistry = \OC::$server->query(\OCP\Support\Subscription\IRegistry::class);
|
||||
return $subscriptionRegistry->delegateHasExtendedSupport();
|
||||
} catch (AppFramework\QueryException $e) {}
|
||||
return \OC::$server->getConfig()->getSystemValueBool('extendedSupport', false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set current update channel
|
||||
* @param string $channel
|
||||
|
|
|
@ -42,14 +42,16 @@ try {
|
|||
# see core/lib/private/legacy/defaults.php and core/themes/example/defaults.php
|
||||
# for description and defaults
|
||||
$defaults = new \OCP\Defaults();
|
||||
$values=array(
|
||||
$values = [
|
||||
'installed'=>$installed,
|
||||
'maintenance' => $maintenance,
|
||||
'needsDbUpgrade' => \OCP\Util::needUpgrade(),
|
||||
'version'=>implode('.', \OCP\Util::getVersion()),
|
||||
'versionstring'=>OC_Util::getVersionString(),
|
||||
'edition'=> '',
|
||||
'productname'=>$defaults->getName());
|
||||
'productname'=>$defaults->getName(),
|
||||
'extendedSupport' => \OCP\Util::hasExtendedSupport()
|
||||
];
|
||||
if (OC::$CLI) {
|
||||
print_r($values);
|
||||
} else {
|
||||
|
|
|
@ -97,6 +97,7 @@ class OCSControllerTest extends TestCase {
|
|||
'micro' => $micro,
|
||||
'string' => \OC_Util::getVersionString(),
|
||||
'edition' => '',
|
||||
'extendedSupport' => false
|
||||
);
|
||||
|
||||
$capabilities = [
|
||||
|
@ -128,6 +129,7 @@ class OCSControllerTest extends TestCase {
|
|||
'micro' => $micro,
|
||||
'string' => \OC_Util::getVersionString(),
|
||||
'edition' => '',
|
||||
'extendedSupport' => false
|
||||
);
|
||||
|
||||
$capabilities = [
|
||||
|
|
|
@ -74,6 +74,18 @@ class RegistryTest extends TestCase {
|
|||
$this->assertSame(true, $this->registry->delegateHasValidSubscription());
|
||||
}
|
||||
|
||||
public function testDelegateHasExtendedSupport() {
|
||||
/* @var ISubscription|\PHPUnit_Framework_MockObject_MockObject $subscription */
|
||||
$subscription = $this->createMock(ISubscription::class);
|
||||
$subscription->expects($this->once())
|
||||
->method('hasExtendedSupport')
|
||||
->willReturn(true);
|
||||
$this->registry->register($subscription);
|
||||
|
||||
$this->assertSame(true, $this->registry->delegateHasExtendedSupport());
|
||||
}
|
||||
|
||||
|
||||
public function testDelegateGetSupportedApps() {
|
||||
/* @var ISupportedApps|\PHPUnit_Framework_MockObject_MockObject $subscription */
|
||||
$subscription = $this->createMock(ISupportedApps::class);
|
||||
|
|
Loading…
Reference in New Issue