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

View File

@ -10,10 +10,10 @@
namespace OCA\Files_Sharing\Middleware;
use OCP\AppFramework\IApi;
use \OCP\AppFramework\Middleware;
use OCP\App\IAppManager;
use OCP\AppFramework\Middleware;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\IAppConfig;
use OCP\IConfig;
/**
* Checks whether the "sharing check" is enabled
@ -24,22 +24,22 @@ class SharingCheckMiddleware extends Middleware {
/** @var string */
protected $appName;
/** @var IAppConfig */
protected $appConfig;
/** @var IApi */
protected $api;
/** @var IConfig */
protected $config;
/** @var IAppManager */
protected $appManager;
/***
* @param string $appName
* @param IAppConfig $appConfig
* @param IApi $api
* @param IConfig $config
* @param IAppManager $appManager
*/
public function __construct($appName,
IAppConfig $appConfig,
IApi $api) {
IConfig $config,
IAppManager $appManager) {
$this->appName = $appName;
$this->appConfig = $appConfig;
$this->api = $api;
$this->config = $config;
$this->appManager = $appManager;
}
/**
@ -69,12 +69,12 @@ class SharingCheckMiddleware extends Middleware {
private function isSharingEnabled() {
// 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
if(!$this->api->isAppEnabled($this->appName)) {
if(!$this->appManager->isEnabledForUser($this->appName)) {
return false;
}
// 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;
}

View File

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