Use IAppManager instead of private API
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
parent
699c64c750
commit
8391ca8792
3 changed files with 25 additions and 9 deletions
|
@ -23,6 +23,8 @@
|
|||
namespace OCA\Theming;
|
||||
|
||||
|
||||
use OCP\App\AppPathNotFoundException;
|
||||
use OCP\App\IAppManager;
|
||||
use OCP\Files\IAppData;
|
||||
use OCP\ICacheFactory;
|
||||
use OCP\IConfig;
|
||||
|
@ -41,6 +43,10 @@ class ThemingDefaults extends \OC_Defaults {
|
|||
private $appData;
|
||||
/** @var ICacheFactory */
|
||||
private $cacheFactory;
|
||||
/** @var Util */
|
||||
private $util;
|
||||
/** @var IAppManager */
|
||||
private $appManager;
|
||||
/** @var string */
|
||||
private $name;
|
||||
/** @var string */
|
||||
|
@ -49,8 +55,7 @@ class ThemingDefaults extends \OC_Defaults {
|
|||
private $slogan;
|
||||
/** @var string */
|
||||
private $color;
|
||||
/** @var Util */
|
||||
private $util;
|
||||
|
||||
/** @var string */
|
||||
private $iTunesAppId;
|
||||
/** @var string */
|
||||
|
@ -68,13 +73,15 @@ class ThemingDefaults extends \OC_Defaults {
|
|||
* @param IAppData $appData
|
||||
* @param ICacheFactory $cacheFactory
|
||||
* @param Util $util
|
||||
* @param IAppManager $appManager
|
||||
*/
|
||||
public function __construct(IConfig $config,
|
||||
IL10N $l,
|
||||
IURLGenerator $urlGenerator,
|
||||
IAppData $appData,
|
||||
ICacheFactory $cacheFactory,
|
||||
Util $util
|
||||
Util $util,
|
||||
IAppManager $appManager
|
||||
) {
|
||||
parent::__construct();
|
||||
$this->config = $config;
|
||||
|
@ -83,6 +90,7 @@ class ThemingDefaults extends \OC_Defaults {
|
|||
$this->appData = $appData;
|
||||
$this->cacheFactory = $cacheFactory;
|
||||
$this->util = $util;
|
||||
$this->appManager = $appManager;
|
||||
|
||||
$this->name = parent::getName();
|
||||
$this->url = parent::getBaseUrl();
|
||||
|
@ -269,10 +277,12 @@ class ThemingDefaults extends \OC_Defaults {
|
|||
return $this->urlGenerator->linkToRoute('theming.Icon.getTouchIcon', ['app' => $app]) . '?v=' . $cacheBusterValue;
|
||||
}
|
||||
if ($image === 'manifest.json') {
|
||||
$appPath = \OC_App::getAppPath($app);
|
||||
if ($appPath && file_exists($appPath . '/img/manifest.json')) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
$appPath = $this->appManager->getAppPath($app);
|
||||
if (file_exists($appPath . '/img/manifest.json')) {
|
||||
return false;
|
||||
}
|
||||
} catch (AppPathNotFoundException $e) {}
|
||||
return $this->urlGenerator->linkToRoute('theming.Theming.getManifest') . '?v=' . $cacheBusterValue;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
namespace OCA\Theming\Tests;
|
||||
|
||||
use OCA\Theming\ThemingDefaults;
|
||||
use OCP\App\IAppManager;
|
||||
use OCP\Files\IAppData;
|
||||
use OCA\Theming\Util;
|
||||
use OCP\Files\NotFoundException;
|
||||
|
@ -55,6 +56,8 @@ class ThemingDefaultsTest extends TestCase {
|
|||
private $util;
|
||||
/** @var ICache|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $cache;
|
||||
/** @var IAppManager|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $appManager;
|
||||
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
|
@ -65,6 +68,7 @@ class ThemingDefaultsTest extends TestCase {
|
|||
$this->cacheFactory = $this->createMock(ICacheFactory::class);
|
||||
$this->cache = $this->createMock(ICache::class);
|
||||
$this->util = $this->createMock(Util::class);
|
||||
$this->appManager = $this->createMock(IAppManager::class);
|
||||
$this->defaults = new \OC_Defaults();
|
||||
$this->cacheFactory
|
||||
->expects($this->any())
|
||||
|
@ -77,7 +81,8 @@ class ThemingDefaultsTest extends TestCase {
|
|||
$this->urlGenerator,
|
||||
$this->appData,
|
||||
$this->cacheFactory,
|
||||
$this->util
|
||||
$this->util,
|
||||
$this->appManager
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -892,7 +892,8 @@ class Server extends ServerContainer implements IServerContainer {
|
|||
$c->getURLGenerator(),
|
||||
$c->getAppDataDir('theming'),
|
||||
$c->getMemCacheFactory(),
|
||||
new Util($c->getConfig(), $this->getAppManager(), $this->getAppDataDir('theming'))
|
||||
new Util($c->getConfig(), $this->getAppManager(), $this->getAppDataDir('theming')),
|
||||
$this->getAppManager()
|
||||
);
|
||||
}
|
||||
return new \OC_Defaults();
|
||||
|
|
Loading…
Reference in a new issue