From 2c988ecbf498bebd8ac904e0c457521350cf469f Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 15 Jul 2016 08:46:31 +0200 Subject: [PATCH] Use the themed Defaults everywhere --- apps/dav/lib/Connector/PublicAuth.php | 2 +- apps/dav/lib/Connector/Sabre/Auth.php | 2 +- apps/federation/lib/DAV/FedAuth.php | 2 +- core/Application.php | 6 +++--- core/Command/Maintenance/Install.php | 2 +- core/Controller/LostController.php | 8 +++----- lib/base.php | 2 +- lib/private/Console/Application.php | 4 ++-- lib/private/Server.php | 2 +- lib/private/Setup.php | 2 +- lib/private/URLGenerator.php | 4 ++-- lib/private/legacy/util.php | 2 +- lib/public/Defaults.php | 2 +- settings/Application.php | 2 +- settings/Controller/MailSettingsController.php | 1 - settings/personal.php | 2 +- 16 files changed, 21 insertions(+), 24 deletions(-) diff --git a/apps/dav/lib/Connector/PublicAuth.php b/apps/dav/lib/Connector/PublicAuth.php index 4e63ca1d29e..9b386c7609d 100644 --- a/apps/dav/lib/Connector/PublicAuth.php +++ b/apps/dav/lib/Connector/PublicAuth.php @@ -65,7 +65,7 @@ class PublicAuth extends AbstractBasic { $this->session = $session; // setup realm - $defaults = new \OC_Defaults(); + $defaults = new \OCP\Defaults(); $this->realm = $defaults->getName(); } diff --git a/apps/dav/lib/Connector/Sabre/Auth.php b/apps/dav/lib/Connector/Sabre/Auth.php index 82c2711b560..28e4ae2bcde 100644 --- a/apps/dav/lib/Connector/Sabre/Auth.php +++ b/apps/dav/lib/Connector/Sabre/Auth.php @@ -78,7 +78,7 @@ class Auth extends AbstractBasic { $this->principalPrefix = $principalPrefix; // setup realm - $defaults = new \OC_Defaults(); + $defaults = new \OCP\Defaults(); $this->realm = $defaults->getName(); } diff --git a/apps/federation/lib/DAV/FedAuth.php b/apps/federation/lib/DAV/FedAuth.php index 21c0d61487c..ff83932283c 100644 --- a/apps/federation/lib/DAV/FedAuth.php +++ b/apps/federation/lib/DAV/FedAuth.php @@ -38,7 +38,7 @@ class FedAuth extends AbstractBasic { $this->principalPrefix = 'principals/system/'; // setup realm - $defaults = new \OC_Defaults(); + $defaults = new \OCP\Defaults(); $this->realm = $defaults->getName(); } diff --git a/core/Application.php b/core/Application.php index a87917b626a..1485f7a7516 100644 --- a/core/Application.php +++ b/core/Application.php @@ -35,7 +35,7 @@ use OC\Core\Controller\LostController; use OC\Core\Controller\TokenController; use OC\Core\Controller\TwoFactorChallengeController; use OC\Core\Controller\UserController; -use OC_Defaults; +use OCP\Defaults; use OCP\AppFramework\App; use OCP\Util; @@ -165,8 +165,8 @@ class Application extends App { $container->registerService('UserFolder', function(SimpleContainer $c) { return $c->query('ServerContainer')->getUserFolder(); }); - $container->registerService('Defaults', function() { - return new OC_Defaults; + $container->registerService('Defaults', function(SimpleContainer $c) { + return $c->query('ServerContainer')->getThemingDefaults(); }); $container->registerService('Mailer', function(SimpleContainer $c) { return $c->query('ServerContainer')->getMailer(); diff --git a/core/Command/Maintenance/Install.php b/core/Command/Maintenance/Install.php index cee0c60b488..3e9e043b036 100644 --- a/core/Command/Maintenance/Install.php +++ b/core/Command/Maintenance/Install.php @@ -64,7 +64,7 @@ class Install extends Command { // validate the environment $server = \OC::$server; $setupHelper = new Setup($this->config, $server->getIniWrapper(), - $server->getL10N('lib'), new \OC_Defaults(), $server->getLogger(), + $server->getL10N('lib'), $server->getThemingDefaults(), $server->getLogger(), $server->getSecureRandom()); $sysInfo = $setupHelper->getSystemInfo(true); $errors = $sysInfo['errors']; diff --git a/core/Controller/LostController.php b/core/Controller/LostController.php index b509d4bf632..774404af0a5 100644 --- a/core/Controller/LostController.php +++ b/core/Controller/LostController.php @@ -38,7 +38,6 @@ use \OCP\IConfig; use OCP\IUserManager; use OCP\Mail\IMailer; use OCP\Security\ISecureRandom; -use \OC_Defaults; use OCP\Security\StringUtils; /** @@ -54,8 +53,7 @@ class LostController extends Controller { protected $urlGenerator; /** @var IUserManager */ protected $userManager; - // FIXME: Inject a non-static factory of OC_Defaults for better unit-testing - /** @var OC_Defaults */ + /** @var \OC_Defaults */ protected $defaults; /** @var IL10N */ protected $l10n; @@ -77,7 +75,7 @@ class LostController extends Controller { * @param IRequest $request * @param IURLGenerator $urlGenerator * @param IUserManager $userManager - * @param OC_Defaults $defaults + * @param \OC_Defaults $defaults * @param IL10N $l10n * @param IConfig $config * @param ISecureRandom $secureRandom @@ -90,7 +88,7 @@ class LostController extends Controller { IRequest $request, IURLGenerator $urlGenerator, IUserManager $userManager, - OC_Defaults $defaults, + \OC_Defaults $defaults, IL10N $l10n, IConfig $config, ISecureRandom $secureRandom, diff --git a/lib/base.php b/lib/base.php index 70fac6d707b..62ace1bc0ef 100644 --- a/lib/base.php +++ b/lib/base.php @@ -812,7 +812,7 @@ class OC { if (!$systemConfig->getValue('installed', false)) { \OC::$server->getSession()->clear(); $setupHelper = new OC\Setup(\OC::$server->getConfig(), \OC::$server->getIniWrapper(), - \OC::$server->getL10N('lib'), new \OC_Defaults(), \OC::$server->getLogger(), + \OC::$server->getL10N('lib'), \OC::$server->getThemingDefaults(), \OC::$server->getLogger(), \OC::$server->getSecureRandom()); $controller = new OC\Core\Controller\SetupController($setupHelper); $controller->run($_POST); diff --git a/lib/private/Console/Application.php b/lib/private/Console/Application.php index ec91064278e..be561342178 100644 --- a/lib/private/Console/Application.php +++ b/lib/private/Console/Application.php @@ -26,8 +26,8 @@ namespace OC\Console; use OC_App; -use OC_Defaults; use OCP\Console\ConsoleEvent; +use OCP\Defaults; use OCP\IConfig; use OCP\IRequest; use Symfony\Component\Console\Application as SymfonyApplication; @@ -51,7 +51,7 @@ class Application { * @param IRequest $request */ public function __construct(IConfig $config, EventDispatcherInterface $dispatcher, IRequest $request) { - $defaults = new OC_Defaults; + $defaults = \OC::$server->getThemingDefaults(); $this->config = $config; $this->application = new SymfonyApplication($defaults->getName(), \OC_Util::getVersionString()); $this->dispatcher = $dispatcher; diff --git a/lib/private/Server.php b/lib/private/Server.php index c663bc44261..d69e384ad75 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -562,7 +562,7 @@ class Server extends ServerContainer implements IServerContainer { return new Mailer( $c->getConfig(), $c->getLogger(), - new \OC_Defaults() + $c->getThemingDefaults() ); }); $this->registerService('OcsClient', function (Server $c) { diff --git a/lib/private/Setup.php b/lib/private/Setup.php index f1454805a08..7b2c4392360 100644 --- a/lib/private/Setup.php +++ b/lib/private/Setup.php @@ -426,7 +426,7 @@ class Setup { } $setupHelper = new \OC\Setup($config, \OC::$server->getIniWrapper(), - \OC::$server->getL10N('lib'), new \OC_Defaults(), \OC::$server->getLogger(), + \OC::$server->getL10N('lib'), \OC::$server->getThemingDefaults(), \OC::$server->getLogger(), \OC::$server->getSecureRandom()); $htaccessContent = file_get_contents($setupHelper->pathToHtaccess()); diff --git a/lib/private/URLGenerator.php b/lib/private/URLGenerator.php index 9ae99d67bc6..c7b2b222faf 100644 --- a/lib/private/URLGenerator.php +++ b/lib/private/URLGenerator.php @@ -29,7 +29,7 @@ */ namespace OC; -use OC_Defaults; +use OCP\Defaults; use OCP\ICacheFactory; use OCP\IConfig; use OCP\IURLGenerator; @@ -222,7 +222,7 @@ class URLGenerator implements IURLGenerator { * @return string url to the online documentation */ public function linkToDocs($key) { - $theme = new OC_Defaults(); + $theme = \OC::$server->getThemingDefaults(); return $theme->buildDocLinkToKey($key); } } diff --git a/lib/private/legacy/util.php b/lib/private/legacy/util.php index 2a876eda4d0..63da546ec82 100644 --- a/lib/private/legacy/util.php +++ b/lib/private/legacy/util.php @@ -631,7 +631,7 @@ class OC_Util { $webServerRestart = false; $setup = new \OC\Setup($config, \OC::$server->getIniWrapper(), \OC::$server->getL10N('lib'), - new \OC_Defaults(), \OC::$server->getLogger(), \OC::$server->getSecureRandom()); + \OC::$server->getThemingDefaults(), \OC::$server->getLogger(), \OC::$server->getSecureRandom()); $urlGenerator = \OC::$server->getURLGenerator(); diff --git a/lib/public/Defaults.php b/lib/public/Defaults.php index 791ed5827de..5194484fea2 100644 --- a/lib/public/Defaults.php +++ b/lib/public/Defaults.php @@ -51,7 +51,7 @@ class Defaults { * @since 6.0.0 */ function __construct() { - $this->defaults = new \OC_Defaults(); + $this->defaults = \OC::$server->getThemingDefaults(); } /** diff --git a/settings/Application.php b/settings/Application.php index aedf1e00b2d..1549b273c51 100644 --- a/settings/Application.php +++ b/settings/Application.php @@ -227,7 +227,7 @@ class Application extends App { return $c->query('ServerContainer')->getMailer(); }); $container->registerService('Defaults', function(IContainer $c) { - return new \OC_Defaults; + return $c->query('ServerContainer')->getThemingDefaults(); }); $container->registerService('DefaultMailAddress', function(IContainer $c) { return Util::getDefaultEmailAddress('no-reply'); diff --git a/settings/Controller/MailSettingsController.php b/settings/Controller/MailSettingsController.php index 11f72e7e8ee..cd3c6e2224a 100644 --- a/settings/Controller/MailSettingsController.php +++ b/settings/Controller/MailSettingsController.php @@ -29,7 +29,6 @@ use OCP\IRequest; use OCP\IL10N; use OCP\IConfig; use OCP\Mail\IMailer; -use OCP\Mail\IMessage; /** * @package OC\Settings\Controller diff --git a/settings/personal.php b/settings/personal.php index e7a928f88bf..0519e68beaa 100644 --- a/settings/personal.php +++ b/settings/personal.php @@ -37,7 +37,7 @@ OC_Util::checkLoggedIn(); -$defaults = new OC_Defaults(); // initialize themable default strings and urls +$defaults = \OC::$server->getThemingDefaults(); $certificateManager = \OC::$server->getCertificateManager(); $config = \OC::$server->getConfig(); $urlGenerator = \OC::$server->getURLGenerator(); -- 2.39.5