From ef2fb51065aabb90e8e4234d84a78f4e047f7d1c Mon Sep 17 00:00:00 2001
From: Robin Appelman <robin@icewind.nl>
Date: Mon, 4 Nov 2019 19:25:00 +0100
Subject: [PATCH] remove missed manual Application instance constructions

Signed-off-by: Robin Appelman <robin@icewind.nl>
---
 apps/accessibility/appinfo/app.php           |  6 +++--
 apps/cloud_federation_api/appinfo/app.php    |  4 ++-
 apps/federatedfilesharing/appinfo/app.php    |  3 ++-
 apps/files_sharing/appinfo/app.php           |  3 ++-
 apps/lookup_server_connector/appinfo/app.php |  4 ++-
 apps/sharebymail/appinfo/app.php             |  4 ++-
 apps/systemtags/appinfo/app.php              |  5 ++--
 apps/theming/appinfo/app.php                 |  4 ++-
 apps/theming/lib/AppInfo/Application.php     | 28 ++++++++++++++++++++
 apps/twofactor_backupcodes/appinfo/app.php   |  4 ++-
 apps/updatenotification/appinfo/app.php      |  5 +++-
 apps/workflowengine/appinfo/app.php          |  5 +++-
 12 files changed, 61 insertions(+), 14 deletions(-)
 create mode 100644 apps/theming/lib/AppInfo/Application.php

diff --git a/apps/accessibility/appinfo/app.php b/apps/accessibility/appinfo/app.php
index 96621a16829..4421c732bd8 100644
--- a/apps/accessibility/appinfo/app.php
+++ b/apps/accessibility/appinfo/app.php
@@ -22,10 +22,12 @@ declare (strict_types = 1);
  *
  */
 
-$app = new \OCA\Accessibility\AppInfo\Application();
+use OCA\Accessibility\AppInfo\Application;
+
+$app = \OC::$server->query(Application::class);
 
 // Separate from the constructor since the route are not initialized before that
 // 1. create the app
 // 2. generate css route and inject
 $app->injectCss();
-$app->injectJavascript();
\ No newline at end of file
+$app->injectJavascript();
diff --git a/apps/cloud_federation_api/appinfo/app.php b/apps/cloud_federation_api/appinfo/app.php
index 9b79832d817..eaba54bb2db 100644
--- a/apps/cloud_federation_api/appinfo/app.php
+++ b/apps/cloud_federation_api/appinfo/app.php
@@ -19,4 +19,6 @@
  *
  */
 
-$app = new \OCA\CloudFederationAPI\AppInfo\Application();
+use OCA\CloudFederationAPI\AppInfo\Application;
+
+\OC::$server->query(Application::class);
diff --git a/apps/federatedfilesharing/appinfo/app.php b/apps/federatedfilesharing/appinfo/app.php
index 6b273faca80..025bc86b776 100644
--- a/apps/federatedfilesharing/appinfo/app.php
+++ b/apps/federatedfilesharing/appinfo/app.php
@@ -24,8 +24,9 @@
  */
 
 use OCA\FederatedFileSharing\Notifier;
+use OCA\FederatedFileSharing\AppInfo\Application;
 
-$app = new \OCA\FederatedFileSharing\AppInfo\Application();
+$app = \OC::$server->query(Application::class);
 $eventDispatcher = \OC::$server->getEventDispatcher();
 
 $manager = \OC::$server->getNotificationManager();
diff --git a/apps/files_sharing/appinfo/app.php b/apps/files_sharing/appinfo/app.php
index 32159f7b973..c4f44095dcd 100644
--- a/apps/files_sharing/appinfo/app.php
+++ b/apps/files_sharing/appinfo/app.php
@@ -29,13 +29,14 @@
 
 use OCA\Files_Sharing\ShareBackend\File;
 use OCA\Files_Sharing\ShareBackend\Folder;
+use OCA\Files_Sharing\AppInfo\Application;
 
 \OCA\Files_Sharing\Helper::registerHooks();
 
 \OC\Share\Share::registerBackend('file', File::class);
 \OC\Share\Share::registerBackend('folder', Folder::class, 'file');
 
-$application = new \OCA\Files_Sharing\AppInfo\Application();
+$application = \OC::$server->query(Application::class);
 $application->registerMountProviders();
 
 $eventDispatcher = \OC::$server->getEventDispatcher();
diff --git a/apps/lookup_server_connector/appinfo/app.php b/apps/lookup_server_connector/appinfo/app.php
index e1064b144a4..4fae295e96a 100644
--- a/apps/lookup_server_connector/appinfo/app.php
+++ b/apps/lookup_server_connector/appinfo/app.php
@@ -19,5 +19,7 @@
  *
  */
 
-$app = new \OCA\LookupServerConnector\AppInfo\Application();
+use OCA\LookupServerConnector\AppInfo\Application;
+
+$app = \OC::$server->query(Application::class);
 $app->register();
diff --git a/apps/sharebymail/appinfo/app.php b/apps/sharebymail/appinfo/app.php
index c1fd39d2a2f..e1bc280821d 100644
--- a/apps/sharebymail/appinfo/app.php
+++ b/apps/sharebymail/appinfo/app.php
@@ -19,4 +19,6 @@
  *
  */
 
-$app = new \OCA\ShareByMail\AppInfo\Application();
+use OCA\ShareByMail\AppInfo\Application;
+
+$app = \OC::$server->query(Application::class);
diff --git a/apps/systemtags/appinfo/app.php b/apps/systemtags/appinfo/app.php
index 82eb2a29f4b..8c0341b5894 100644
--- a/apps/systemtags/appinfo/app.php
+++ b/apps/systemtags/appinfo/app.php
@@ -39,9 +39,8 @@ $eventDispatcher->addListener(
 );
 
 $managerListener = function(ManagerEvent $event) {
-	$application = new \OCP\AppFramework\App('systemtags');
 	/** @var \OCA\SystemTags\Activity\Listener $listener */
-	$listener = $application->getContainer()->query(Listener::class);
+	$listener = \OC::$server->query(Listener::class);
 	$listener->event($event);
 };
 
@@ -52,7 +51,7 @@ $eventDispatcher->addListener(ManagerEvent::EVENT_UPDATE, $managerListener);
 $mapperListener = function(MapperEvent $event) {
 	$application = new \OCP\AppFramework\App('systemtags');
 	/** @var \OCA\SystemTags\Activity\Listener $listener */
-	$listener = $application->getContainer()->query(Listener::class);
+	$listener = \OC::$server->query(Listener::class);
 	$listener->mapperEvent($event);
 };
 
diff --git a/apps/theming/appinfo/app.php b/apps/theming/appinfo/app.php
index dc8e00f4ed5..ba60d44870b 100644
--- a/apps/theming/appinfo/app.php
+++ b/apps/theming/appinfo/app.php
@@ -25,7 +25,9 @@
  *
  */
 
-$app = new \OCP\AppFramework\App('theming');
+use OCA\Theming\AppInfo\Application;
+
+$app = \OC::$server->query(Application::class);
 $app->getContainer()->registerCapability(\OCA\Theming\Capabilities::class);
 
 $linkToCSS = \OC::$server->getURLGenerator()->linkToRoute(
diff --git a/apps/theming/lib/AppInfo/Application.php b/apps/theming/lib/AppInfo/Application.php
new file mode 100644
index 00000000000..519e49077f8
--- /dev/null
+++ b/apps/theming/lib/AppInfo/Application.php
@@ -0,0 +1,28 @@
+<?php
+/**
+ * @copyright Copyright (c) 2019 Robin Appelman <robin@icewind.nl>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * 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
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCA\Theming\AppInfo;
+
+class Application extends \OCP\AppFramework\App {
+	public function __construct() {
+		parent::__construct('theming', []);
+	}
+}
\ No newline at end of file
diff --git a/apps/twofactor_backupcodes/appinfo/app.php b/apps/twofactor_backupcodes/appinfo/app.php
index 34b4866af2d..f67e89d23b7 100644
--- a/apps/twofactor_backupcodes/appinfo/app.php
+++ b/apps/twofactor_backupcodes/appinfo/app.php
@@ -21,5 +21,7 @@
  *
  */
 
-$app = new \OCA\TwoFactorBackupCodes\AppInfo\Application();
+use OCA\TwoFactorBackupCodes\AppInfo\Application;
+
+$app = \OC::$server->query(Application::class);
 $app->register();
diff --git a/apps/updatenotification/appinfo/app.php b/apps/updatenotification/appinfo/app.php
index 5002fd7c837..6a34aa79d9b 100644
--- a/apps/updatenotification/appinfo/app.php
+++ b/apps/updatenotification/appinfo/app.php
@@ -21,5 +21,8 @@
  *
  */
 
-$app = new \OCA\UpdateNotification\AppInfo\Application();
+use \OCA\UpdateNotification\AppInfo\Application;
+
+/** @var Application $app */
+$app = \OC::$server->query(Application::class);
 $app->register();
diff --git a/apps/workflowengine/appinfo/app.php b/apps/workflowengine/appinfo/app.php
index d99c5892231..552d8432600 100644
--- a/apps/workflowengine/appinfo/app.php
+++ b/apps/workflowengine/appinfo/app.php
@@ -19,6 +19,9 @@
  *
  */
 
-$application = new \OCA\WorkflowEngine\AppInfo\Application();
+use \OCA\WorkflowEngine\AppInfo\Application;
+
+/** @var Application $application */
+$application = \OC::$server->query(Application::class);
 $application->registerHooksAndListeners();
 $application->registerRuleListeners();
-- 
GitLab