remove deprecated code - fixes #13119

This commit is contained in:
Thomas Müller 2015-01-14 13:56:49 +01:00
parent 3a6d2fcc10
commit 25806346c2
3 changed files with 51 additions and 50 deletions

View File

@ -29,21 +29,22 @@ class Application extends App {
parent::__construct('files_sharing', $urlParams); parent::__construct('files_sharing', $urlParams);
$container = $this->getContainer(); $container = $this->getContainer();
$server = $container->getServer();
/** /**
* Controllers * Controllers
*/ */
$container->registerService('ShareController', function(SimpleContainer $c) { $container->registerService('ShareController', function(SimpleContainer $c) use ($server) {
return new ShareController( return new ShareController(
$c->query('AppName'), $c->query('AppName'),
$c->query('Request'), $c->query('Request'),
$c->query('UserSession'), $c->query('UserSession'),
$c->query('ServerContainer')->getAppConfig(), $server->getAppConfig(),
$c->query('ServerContainer')->getConfig(), $server->getConfig(),
$c->query('URLGenerator'), $c->query('URLGenerator'),
$c->query('ServerContainer')->getUserManager(), $server->getUserManager(),
$c->query('ServerContainer')->getLogger(), $server->getLogger(),
$c->query('ServerContainer')->getActivityManager() $server->getActivityManager()
); );
}); });
$container->registerService('ExternalSharesController', function(SimpleContainer $c) { $container->registerService('ExternalSharesController', function(SimpleContainer $c) {
@ -58,33 +59,33 @@ class Application extends App {
/** /**
* Core class wrappers * Core class wrappers
*/ */
$container->registerService('UserSession', function(SimpleContainer $c) { $container->registerService('UserSession', function(SimpleContainer $c) use ($server) {
return $c->query('ServerContainer')->getUserSession(); return $server->getUserSession();
}); });
$container->registerService('URLGenerator', function(SimpleContainer $c) { $container->registerService('URLGenerator', function(SimpleContainer $c) use ($server){
return $c->query('ServerContainer')->getUrlGenerator(); return $server->getUrlGenerator();
}); });
$container->registerService('IsIncomingShareEnabled', function(SimpleContainer $c) { $container->registerService('IsIncomingShareEnabled', function(SimpleContainer $c) {
return Helper::isIncomingServer2serverShareEnabled(); return Helper::isIncomingServer2serverShareEnabled();
}); });
$container->registerService('ExternalManager', function(SimpleContainer $c) { $container->registerService('ExternalManager', function(SimpleContainer $c) use ($server){
return new \OCA\Files_Sharing\External\Manager( return new \OCA\Files_Sharing\External\Manager(
\OC::$server->getDatabaseConnection(), $server->getDatabaseConnection(),
\OC\Files\Filesystem::getMountManager(), \OC\Files\Filesystem::getMountManager(),
\OC\Files\Filesystem::getLoader(), \OC\Files\Filesystem::getLoader(),
\OC::$server->getUserSession(), $server->getUserSession(),
\OC::$server->getHTTPHelper() $server->getHTTPHelper()
); );
}); });
/** /**
* Middleware * Middleware
*/ */
$container->registerService('SharingCheckMiddleware', function(SimpleContainer $c){ $container->registerService('SharingCheckMiddleware', function(SimpleContainer $c) use ($server){
return new SharingCheckMiddleware( return new SharingCheckMiddleware(
$c->query('AppName'), $c->query('AppName'),
$c->query('ServerContainer')->getAppConfig(), $server->getConfig(),
$c->getCoreApi() $server->getAppManager()
); );
}); });

View File

@ -10,10 +10,10 @@
namespace OCA\Files_Sharing\Middleware; namespace OCA\Files_Sharing\Middleware;
use OCP\AppFramework\IApi; use OCP\App\IAppManager;
use \OCP\AppFramework\Middleware; use OCP\AppFramework\Middleware;
use OCP\AppFramework\Http\TemplateResponse; use OCP\AppFramework\Http\TemplateResponse;
use OCP\IAppConfig; use OCP\IConfig;
/** /**
* Checks whether the "sharing check" is enabled * Checks whether the "sharing check" is enabled
@ -24,22 +24,22 @@ class SharingCheckMiddleware extends Middleware {
/** @var string */ /** @var string */
protected $appName; protected $appName;
/** @var IAppConfig */ /** @var IConfig */
protected $appConfig; protected $config;
/** @var IApi */ /** @var IAppManager */
protected $api; protected $appManager;
/*** /***
* @param string $appName * @param string $appName
* @param IAppConfig $appConfig * @param IConfig $config
* @param IApi $api * @param IAppManager $appManager
*/ */
public function __construct($appName, public function __construct($appName,
IAppConfig $appConfig, IConfig $config,
IApi $api) { IAppManager $appManager) {
$this->appName = $appName; $this->appName = $appName;
$this->appConfig = $appConfig; $this->config = $config;
$this->api = $api; $this->appManager = $appManager;
} }
/** /**
@ -69,12 +69,12 @@ class SharingCheckMiddleware extends Middleware {
private function isSharingEnabled() { private function isSharingEnabled() {
// FIXME: This check is done here since the route is globally defined and not inside the files_sharing app // FIXME: This check is done here since the route is globally defined and not inside the files_sharing app
// Check whether the sharing application is enabled // Check whether the sharing application is enabled
if(!$this->api->isAppEnabled($this->appName)) { if(!$this->appManager->isEnabledForUser($this->appName)) {
return false; return false;
} }
// Check whether public sharing is enabled // Check whether public sharing is enabled
if($this->appConfig->getValue('core', 'shareapi_allow_links', 'yes') !== 'yes') { if($this->config->getAppValue('core', 'shareapi_allow_links', 'yes') !== 'yes') {
return false; return false;
} }

View File

@ -14,34 +14,34 @@ namespace OCA\Files_Sharing\Middleware;
/** /**
* @package OCA\Files_Sharing\Middleware\SharingCheckMiddleware * @package OCA\Files_Sharing\Middleware\SharingCheckMiddleware
*/ */
class SharingCheckMiddlewareTest extends \PHPUnit_Framework_TestCase { class SharingCheckMiddlewareTest extends \Test\TestCase {
/** @var \OCP\IAppConfig */ /** @var \OCP\IConfig */
private $appConfig; private $config;
/** @var \OCP\AppFramework\IApi */ /** @var \OCP\App\IAppManager */
private $api; private $appManager;
/** @var SharingCheckMiddleware */ /** @var SharingCheckMiddleware */
private $sharingCheckMiddleware; private $sharingCheckMiddleware;
protected function setUp() { protected function setUp() {
$this->appConfig = $this->getMockBuilder('\OCP\IAppConfig') $this->config = $this->getMockBuilder('\OCP\IConfig')
->disableOriginalConstructor()->getMock(); ->disableOriginalConstructor()->getMock();
$this->api = $this->getMockBuilder('\OCP\AppFramework\IApi') $this->appManager = $this->getMockBuilder('\OCP\App\IAppManager')
->disableOriginalConstructor()->getMock(); ->disableOriginalConstructor()->getMock();
$this->sharingCheckMiddleware = new SharingCheckMiddleware('files_sharing', $this->appConfig, $this->api); $this->sharingCheckMiddleware = new SharingCheckMiddleware('files_sharing', $this->config, $this->appManager);
} }
public function testIsSharingEnabledWithEverythingEnabled() { public function testIsSharingEnabledWithEverythingEnabled() {
$this->api $this->appManager
->expects($this->once()) ->expects($this->once())
->method('isAppEnabled') ->method('isEnabledForUser')
->with('files_sharing') ->with('files_sharing')
->will($this->returnValue(true)); ->will($this->returnValue(true));
$this->appConfig $this->config
->expects($this->once()) ->expects($this->once())
->method('getValue') ->method('getAppValue')
->with('core', 'shareapi_allow_links', 'yes') ->with('core', 'shareapi_allow_links', 'yes')
->will($this->returnValue('yes')); ->will($this->returnValue('yes'));
@ -49,9 +49,9 @@ class SharingCheckMiddlewareTest extends \PHPUnit_Framework_TestCase {
} }
public function testIsSharingEnabledWithAppDisabled() { public function testIsSharingEnabledWithAppDisabled() {
$this->api $this->appManager
->expects($this->once()) ->expects($this->once())
->method('isAppEnabled') ->method('isEnabledForUser')
->with('files_sharing') ->with('files_sharing')
->will($this->returnValue(false)); ->will($this->returnValue(false));
@ -59,15 +59,15 @@ class SharingCheckMiddlewareTest extends \PHPUnit_Framework_TestCase {
} }
public function testIsSharingEnabledWithSharingDisabled() { public function testIsSharingEnabledWithSharingDisabled() {
$this->api $this->appManager
->expects($this->once()) ->expects($this->once())
->method('isAppEnabled') ->method('isEnabledForUser')
->with('files_sharing') ->with('files_sharing')
->will($this->returnValue(true)); ->will($this->returnValue(true));
$this->appConfig $this->config
->expects($this->once()) ->expects($this->once())
->method('getValue') ->method('getAppValue')
->with('core', 'shareapi_allow_links', 'yes') ->with('core', 'shareapi_allow_links', 'yes')
->will($this->returnValue('no')); ->will($this->returnValue('no'));