зеркало из https://github.com/nextcloud/server.git
Expose getAppPath to public API
Signed-off-by: Julius Haertl <jus@bitgrid.net>
This commit is contained in:
Родитель
de983e61e3
Коммит
caacb6c261
|
@ -31,6 +31,7 @@
|
||||||
|
|
||||||
namespace OC\App;
|
namespace OC\App;
|
||||||
|
|
||||||
|
use OCP\App\AppPathNotFoundException;
|
||||||
use OCP\App\IAppManager;
|
use OCP\App\IAppManager;
|
||||||
use OCP\App\ManagerEvent;
|
use OCP\App\ManagerEvent;
|
||||||
use OCP\IAppConfig;
|
use OCP\IAppConfig;
|
||||||
|
@ -265,6 +266,21 @@ class AppManager implements IAppManager {
|
||||||
$this->clearAppsCache();
|
$this->clearAppsCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the directory for the given app.
|
||||||
|
*
|
||||||
|
* @param string $appId
|
||||||
|
* @return string
|
||||||
|
* @throws AppPathNotFoundException if app folder can't be found
|
||||||
|
*/
|
||||||
|
public function getAppPath($appId) {
|
||||||
|
$appPath = \OC_App::getAppPath($appId);
|
||||||
|
if($appPath === false) {
|
||||||
|
throw new AppPathNotFoundException('Could not find path for ' . $appId);
|
||||||
|
}
|
||||||
|
return $appPath;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear the cached list of apps when enabling/disabling an app
|
* Clear the cached list of apps when enabling/disabling an app
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @copyright Copyright (c) 2016 Julius Härtl <jus@bitgrid.net>
|
||||||
|
*
|
||||||
|
* @author Julius Härtl <jus@bitgrid.net>
|
||||||
|
*
|
||||||
|
* @license AGPL-3.0
|
||||||
|
*
|
||||||
|
* This code is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License, version 3,
|
||||||
|
* as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License, version 3,
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace OCP\App;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class AppPathNotFoundException
|
||||||
|
*
|
||||||
|
* @package OCP\App
|
||||||
|
* @since 11.0.0
|
||||||
|
*/
|
||||||
|
class AppPathNotFoundException extends \Exception {}
|
|
@ -78,6 +78,16 @@ interface IAppManager {
|
||||||
*/
|
*/
|
||||||
public function disableApp($appId);
|
public function disableApp($appId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the directory for the given app.
|
||||||
|
*
|
||||||
|
* @param string $appId
|
||||||
|
* @return string
|
||||||
|
* @since 11.0.0
|
||||||
|
* @throws AppPathNotFoundException
|
||||||
|
*/
|
||||||
|
public function getAppPath($appId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List all apps enabled for a user
|
* List all apps enabled for a user
|
||||||
*
|
*
|
||||||
|
|
|
@ -11,6 +11,7 @@ namespace Test\App;
|
||||||
|
|
||||||
use OC\Group\Group;
|
use OC\Group\Group;
|
||||||
use OC\User\User;
|
use OC\User\User;
|
||||||
|
use OCP\App\AppPathNotFoundException;
|
||||||
use Test\TestCase;
|
use Test\TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -260,6 +261,15 @@ class ManagerTest extends TestCase {
|
||||||
$this->assertFalse($this->manager->isEnabledForUser('test', $user));
|
$this->assertFalse($this->manager->isEnabledForUser('test', $user));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testGetAppPath() {
|
||||||
|
$this->assertEquals(\OC::$SERVERROOT . '/apps/files', $this->manager->getAppPath('files'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGetAppPathFail() {
|
||||||
|
$this->expectException(AppPathNotFoundException::class);
|
||||||
|
$this->manager->getAppPath('testnotexisting');
|
||||||
|
}
|
||||||
|
|
||||||
public function testIsEnabledForUserEnabledForGroup() {
|
public function testIsEnabledForUserEnabledForGroup() {
|
||||||
$user = $this->newUser('user1');
|
$user = $this->newUser('user1');
|
||||||
$this->groupManager->expects($this->once())
|
$this->groupManager->expects($this->once())
|
||||||
|
|
Загрузка…
Ссылка в новой задаче