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