diff --git a/apps/theming/lib/Template.php b/apps/theming/lib/Template.php index 85e5481ae40b0..4847d2f82521b 100644 --- a/apps/theming/lib/Template.php +++ b/apps/theming/lib/Template.php @@ -29,6 +29,7 @@ use OCP\IConfig; use OCP\IL10N; use OCP\IURLGenerator; +use OCP\Files\IRootFolder; /** * Class Template @@ -52,6 +53,8 @@ class Template extends \OC_Defaults { private $slogan; /** @var string */ private $color; + /** @var IRootFolder */ + private $rootFolder; /** * Template constructor. @@ -60,16 +63,19 @@ class Template extends \OC_Defaults { * @param IL10N $l * @param IURLGenerator $urlGenerator * @param \OC_Defaults $defaults + * @param IRootFolder $rootFolder */ public function __construct(IConfig $config, IL10N $l, IURLGenerator $urlGenerator, - \OC_Defaults $defaults + \OC_Defaults $defaults, + IRootFolder $rootFolder ) { parent::__construct(); $this->config = $config; $this->l = $l; $this->urlGenerator = $urlGenerator; + $this->rootFolder = $rootFolder; $this->name = $defaults->getName(); $this->url = $defaults->getBaseUrl(); @@ -126,8 +132,7 @@ public function getMailHeaderColor() { */ public function getLogo() { $logo = $this->config->getAppValue('theming', 'logoMime'); - $pathToLogo = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data/') . '/themedinstancelogo'; - if(!$logo || !file_exists($pathToLogo)) { + if(!$logo || !$this->rootFolder->nodeExists('themedinstancelogo')) { return $this->urlGenerator->imagePath('core','logo.svg'); } else { return $this->urlGenerator->linkToRoute('theming.Theming.getLogo'); @@ -140,8 +145,7 @@ public function getLogo() { */ public function getBackground() { $backgroundLogo = $this->config->getAppValue('theming', 'backgroundMime'); - $pathToLogo = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data/') . '/themedbackgroundlogo'; - if(!$backgroundLogo || !file_exists($pathToLogo)) { + if(!$backgroundLogo || !$this->rootFolder->nodeExists('themedbackgroundlogo')) { return $this->urlGenerator->imagePath('core','background.jpg'); } else { return $this->urlGenerator->linkToRoute('theming.Theming.getLoginBackground'); diff --git a/apps/theming/tests/TemplateTest.php b/apps/theming/tests/TemplateTest.php index 0a257aeef4ed3..be61a028c31dc 100644 --- a/apps/theming/tests/TemplateTest.php +++ b/apps/theming/tests/TemplateTest.php @@ -27,6 +27,7 @@ use OCP\IConfig; use OCP\IL10N; use OCP\IURLGenerator; +use OCP\Files\IRootFolder; use Test\TestCase; class TemplateTest extends TestCase { @@ -40,11 +41,14 @@ class TemplateTest extends TestCase { private $defaults; /** @var Template */ private $template; + /** @var IRootFolder */ + private $rootFolder; public function setUp() { $this->config = $this->getMock('\\OCP\\IConfig'); $this->l10n = $this->getMock('\\OCP\\IL10N'); $this->urlGenerator = $this->getMock('\\OCP\\IURLGenerator'); + $this->rootFolder = $this->getMock('\\OCP\\Files\\IRootFolder'); $this->defaults = $this->getMockBuilder('\\OC_Defaults') ->disableOriginalConstructor() ->getMock(); @@ -68,7 +72,8 @@ public function setUp() { $this->config, $this->l10n, $this->urlGenerator, - $this->defaults + $this->defaults, + $this->rootFolder ); return parent::setUp(); diff --git a/lib/private/Server.php b/lib/private/Server.php index fd6ecdc297ef6..f05a44c610cf1 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -655,7 +655,8 @@ public function __construct($webRoot, \OC\Config $config) { $this->getConfig(), $this->getL10N('theming'), $this->getURLGenerator(), - new \OC_Defaults() + new \OC_Defaults(), + $this->getRootFolder() ); } return new \OC_Defaults();