Completed
Push — master ( f0b7b2...9247c4 )
by Morris
11:48 queued 10:35
created
lib/private/Console/Application.php 2 patches
Indentation   +138 added lines, -138 removed lines patch added patch discarded remove patch
@@ -43,149 +43,149 @@
 block discarded – undo
43 43
 use Symfony\Component\EventDispatcher\EventDispatcherInterface;
44 44
 
45 45
 class Application {
46
-	/** @var IConfig */
47
-	private $config;
48
-	/** @var EventDispatcherInterface */
49
-	private $dispatcher;
50
-	/** @var IRequest */
51
-	private $request;
52
-	/** @var ILogger  */
53
-	private $logger;
46
+    /** @var IConfig */
47
+    private $config;
48
+    /** @var EventDispatcherInterface */
49
+    private $dispatcher;
50
+    /** @var IRequest */
51
+    private $request;
52
+    /** @var ILogger  */
53
+    private $logger;
54 54
 
55
-	/**
56
-	 * @param IConfig $config
57
-	 * @param EventDispatcherInterface $dispatcher
58
-	 * @param IRequest $request
59
-	 * @param ILogger $logger
60
-	 */
61
-	public function __construct(IConfig $config, EventDispatcherInterface $dispatcher, IRequest $request, ILogger $logger) {
62
-		$defaults = \OC::$server->getThemingDefaults();
63
-		$this->config = $config;
64
-		$this->application = new SymfonyApplication($defaults->getName(), \OC_Util::getVersionString());
65
-		$this->dispatcher = $dispatcher;
66
-		$this->request = $request;
67
-		$this->logger = $logger;
68
-	}
55
+    /**
56
+     * @param IConfig $config
57
+     * @param EventDispatcherInterface $dispatcher
58
+     * @param IRequest $request
59
+     * @param ILogger $logger
60
+     */
61
+    public function __construct(IConfig $config, EventDispatcherInterface $dispatcher, IRequest $request, ILogger $logger) {
62
+        $defaults = \OC::$server->getThemingDefaults();
63
+        $this->config = $config;
64
+        $this->application = new SymfonyApplication($defaults->getName(), \OC_Util::getVersionString());
65
+        $this->dispatcher = $dispatcher;
66
+        $this->request = $request;
67
+        $this->logger = $logger;
68
+    }
69 69
 
70
-	/**
71
-	 * @param InputInterface $input
72
-	 * @param OutputInterface $output
73
-	 * @throws \Exception
74
-	 */
75
-	public function loadCommands(InputInterface $input, OutputInterface $output) {
76
-		// $application is required to be defined in the register_command scripts
77
-		$application = $this->application;
78
-		$inputDefinition = $application->getDefinition();
79
-		$inputDefinition->addOption(
80
-			new InputOption(
81
-				'no-warnings', 
82
-				null, 
83
-				InputOption::VALUE_NONE, 
84
-				'Skip global warnings, show command output only', 
85
-				null
86
-			)
87
-		);
88
-		try {
89
-			$input->bind($inputDefinition);
90
-		} catch (\RuntimeException $e) {
91
-			//expected if there are extra options
92
-		}
93
-		if ($input->getOption('no-warnings')) {
94
-			$output->setVerbosity(OutputInterface::VERBOSITY_QUIET);
95
-		}
96
-		try {
97
-			require_once __DIR__ . '/../../../core/register_command.php';
98
-			if ($this->config->getSystemValue('installed', false)) {
99
-				if (\OCP\Util::needUpgrade()) {
100
-					throw new NeedsUpdateException();
101
-				} elseif ($this->config->getSystemValue('maintenance', false)) {
102
-					if ($input->getArgument('command') !== '_completion') {
103
-						$errOutput = $output->getErrorOutput();
104
-						$errOutput->writeln('<comment>Nextcloud is in maintenance mode - no apps have been loaded</comment>' . PHP_EOL);
105
-					}
106
-				} else {
107
-					OC_App::loadApps();
108
-					foreach (\OC::$server->getAppManager()->getInstalledApps() as $app) {
109
-						$appPath = \OC_App::getAppPath($app);
110
-						if ($appPath === false) {
111
-							continue;
112
-						}
113
-						// load commands using info.xml
114
-						$info = \OC_App::getAppInfo($app);
115
-						if (isset($info['commands'])) {
116
-							$this->loadCommandsFromInfoXml($info['commands']);
117
-						}
118
-						// load from register_command.php
119
-						\OC_App::registerAutoloading($app, $appPath);
120
-						$file = $appPath . '/appinfo/register_command.php';
121
-						if (file_exists($file)) {
122
-							try {
123
-								require $file;
124
-							} catch (\Exception $e) {
125
-								$this->logger->logException($e);
126
-							}
127
-						}
128
-					}
129
-				}
130
-			} else if ($input->getArgument('command') !== '_completion' && $input->getArgument('command') !== 'maintenance:install') {
131
-				$output->writeln("Nextcloud is not installed - only a limited number of commands are available");
132
-			}
133
-		} catch(NeedsUpdateException $e) {
134
-			if ($input->getArgument('command') !== '_completion') {
135
-				$output->writeln("Nextcloud or one of the apps require upgrade - only a limited number of commands are available");
136
-				$output->writeln("You may use your browser or the occ upgrade command to do the upgrade");
137
-			}
138
-		}
70
+    /**
71
+     * @param InputInterface $input
72
+     * @param OutputInterface $output
73
+     * @throws \Exception
74
+     */
75
+    public function loadCommands(InputInterface $input, OutputInterface $output) {
76
+        // $application is required to be defined in the register_command scripts
77
+        $application = $this->application;
78
+        $inputDefinition = $application->getDefinition();
79
+        $inputDefinition->addOption(
80
+            new InputOption(
81
+                'no-warnings', 
82
+                null, 
83
+                InputOption::VALUE_NONE, 
84
+                'Skip global warnings, show command output only', 
85
+                null
86
+            )
87
+        );
88
+        try {
89
+            $input->bind($inputDefinition);
90
+        } catch (\RuntimeException $e) {
91
+            //expected if there are extra options
92
+        }
93
+        if ($input->getOption('no-warnings')) {
94
+            $output->setVerbosity(OutputInterface::VERBOSITY_QUIET);
95
+        }
96
+        try {
97
+            require_once __DIR__ . '/../../../core/register_command.php';
98
+            if ($this->config->getSystemValue('installed', false)) {
99
+                if (\OCP\Util::needUpgrade()) {
100
+                    throw new NeedsUpdateException();
101
+                } elseif ($this->config->getSystemValue('maintenance', false)) {
102
+                    if ($input->getArgument('command') !== '_completion') {
103
+                        $errOutput = $output->getErrorOutput();
104
+                        $errOutput->writeln('<comment>Nextcloud is in maintenance mode - no apps have been loaded</comment>' . PHP_EOL);
105
+                    }
106
+                } else {
107
+                    OC_App::loadApps();
108
+                    foreach (\OC::$server->getAppManager()->getInstalledApps() as $app) {
109
+                        $appPath = \OC_App::getAppPath($app);
110
+                        if ($appPath === false) {
111
+                            continue;
112
+                        }
113
+                        // load commands using info.xml
114
+                        $info = \OC_App::getAppInfo($app);
115
+                        if (isset($info['commands'])) {
116
+                            $this->loadCommandsFromInfoXml($info['commands']);
117
+                        }
118
+                        // load from register_command.php
119
+                        \OC_App::registerAutoloading($app, $appPath);
120
+                        $file = $appPath . '/appinfo/register_command.php';
121
+                        if (file_exists($file)) {
122
+                            try {
123
+                                require $file;
124
+                            } catch (\Exception $e) {
125
+                                $this->logger->logException($e);
126
+                            }
127
+                        }
128
+                    }
129
+                }
130
+            } else if ($input->getArgument('command') !== '_completion' && $input->getArgument('command') !== 'maintenance:install') {
131
+                $output->writeln("Nextcloud is not installed - only a limited number of commands are available");
132
+            }
133
+        } catch(NeedsUpdateException $e) {
134
+            if ($input->getArgument('command') !== '_completion') {
135
+                $output->writeln("Nextcloud or one of the apps require upgrade - only a limited number of commands are available");
136
+                $output->writeln("You may use your browser or the occ upgrade command to do the upgrade");
137
+            }
138
+        }
139 139
 
140
-		if ($input->getFirstArgument() !== 'check') {
141
-			$errors = \OC_Util::checkServer(\OC::$server->getSystemConfig());
142
-			if (!empty($errors)) {
143
-				foreach ($errors as $error) {
144
-					$output->writeln((string)$error['error']);
145
-					$output->writeln((string)$error['hint']);
146
-					$output->writeln('');
147
-				}
148
-				throw new \Exception("Environment not properly prepared.");
149
-			}
150
-		}
151
-	}
140
+        if ($input->getFirstArgument() !== 'check') {
141
+            $errors = \OC_Util::checkServer(\OC::$server->getSystemConfig());
142
+            if (!empty($errors)) {
143
+                foreach ($errors as $error) {
144
+                    $output->writeln((string)$error['error']);
145
+                    $output->writeln((string)$error['hint']);
146
+                    $output->writeln('');
147
+                }
148
+                throw new \Exception("Environment not properly prepared.");
149
+            }
150
+        }
151
+    }
152 152
 
153
-	/**
154
-	 * Sets whether to automatically exit after a command execution or not.
155
-	 *
156
-	 * @param bool $boolean Whether to automatically exit after a command execution or not
157
-	 */
158
-	public function setAutoExit($boolean) {
159
-		$this->application->setAutoExit($boolean);
160
-	}
153
+    /**
154
+     * Sets whether to automatically exit after a command execution or not.
155
+     *
156
+     * @param bool $boolean Whether to automatically exit after a command execution or not
157
+     */
158
+    public function setAutoExit($boolean) {
159
+        $this->application->setAutoExit($boolean);
160
+    }
161 161
 
162
-	/**
163
-	 * @param InputInterface $input
164
-	 * @param OutputInterface $output
165
-	 * @return int
166
-	 * @throws \Exception
167
-	 */
168
-	public function run(InputInterface $input = null, OutputInterface $output = null) {
169
-		$this->dispatcher->dispatch(ConsoleEvent::EVENT_RUN, new ConsoleEvent(
170
-			ConsoleEvent::EVENT_RUN,
171
-			$this->request->server['argv']
172
-		));
173
-		return $this->application->run($input, $output);
174
-	}
162
+    /**
163
+     * @param InputInterface $input
164
+     * @param OutputInterface $output
165
+     * @return int
166
+     * @throws \Exception
167
+     */
168
+    public function run(InputInterface $input = null, OutputInterface $output = null) {
169
+        $this->dispatcher->dispatch(ConsoleEvent::EVENT_RUN, new ConsoleEvent(
170
+            ConsoleEvent::EVENT_RUN,
171
+            $this->request->server['argv']
172
+        ));
173
+        return $this->application->run($input, $output);
174
+    }
175 175
 
176
-	private function loadCommandsFromInfoXml($commands) {
177
-		foreach ($commands as $command) {
178
-			try {
179
-				$c = \OC::$server->query($command);
180
-			} catch (QueryException $e) {
181
-				if (class_exists($command)) {
182
-					$c = new $command();
183
-				} else {
184
-					throw new \Exception("Console command '$command' is unknown and could not be loaded");
185
-				}
186
-			}
176
+    private function loadCommandsFromInfoXml($commands) {
177
+        foreach ($commands as $command) {
178
+            try {
179
+                $c = \OC::$server->query($command);
180
+            } catch (QueryException $e) {
181
+                if (class_exists($command)) {
182
+                    $c = new $command();
183
+                } else {
184
+                    throw new \Exception("Console command '$command' is unknown and could not be loaded");
185
+                }
186
+            }
187 187
 
188
-			$this->application->add($c);
189
-		}
190
-	}
188
+            $this->application->add($c);
189
+        }
190
+    }
191 191
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -94,14 +94,14 @@  discard block
 block discarded – undo
94 94
 			$output->setVerbosity(OutputInterface::VERBOSITY_QUIET);
95 95
 		}
96 96
 		try {
97
-			require_once __DIR__ . '/../../../core/register_command.php';
97
+			require_once __DIR__.'/../../../core/register_command.php';
98 98
 			if ($this->config->getSystemValue('installed', false)) {
99 99
 				if (\OCP\Util::needUpgrade()) {
100 100
 					throw new NeedsUpdateException();
101 101
 				} elseif ($this->config->getSystemValue('maintenance', false)) {
102 102
 					if ($input->getArgument('command') !== '_completion') {
103 103
 						$errOutput = $output->getErrorOutput();
104
-						$errOutput->writeln('<comment>Nextcloud is in maintenance mode - no apps have been loaded</comment>' . PHP_EOL);
104
+						$errOutput->writeln('<comment>Nextcloud is in maintenance mode - no apps have been loaded</comment>'.PHP_EOL);
105 105
 					}
106 106
 				} else {
107 107
 					OC_App::loadApps();
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 						}
118 118
 						// load from register_command.php
119 119
 						\OC_App::registerAutoloading($app, $appPath);
120
-						$file = $appPath . '/appinfo/register_command.php';
120
+						$file = $appPath.'/appinfo/register_command.php';
121 121
 						if (file_exists($file)) {
122 122
 							try {
123 123
 								require $file;
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 			} else if ($input->getArgument('command') !== '_completion' && $input->getArgument('command') !== 'maintenance:install') {
131 131
 				$output->writeln("Nextcloud is not installed - only a limited number of commands are available");
132 132
 			}
133
-		} catch(NeedsUpdateException $e) {
133
+		} catch (NeedsUpdateException $e) {
134 134
 			if ($input->getArgument('command') !== '_completion') {
135 135
 				$output->writeln("Nextcloud or one of the apps require upgrade - only a limited number of commands are available");
136 136
 				$output->writeln("You may use your browser or the occ upgrade command to do the upgrade");
@@ -141,8 +141,8 @@  discard block
 block discarded – undo
141 141
 			$errors = \OC_Util::checkServer(\OC::$server->getSystemConfig());
142 142
 			if (!empty($errors)) {
143 143
 				foreach ($errors as $error) {
144
-					$output->writeln((string)$error['error']);
145
-					$output->writeln((string)$error['hint']);
144
+					$output->writeln((string) $error['error']);
145
+					$output->writeln((string) $error['hint']);
146 146
 					$output->writeln('');
147 147
 				}
148 148
 				throw new \Exception("Environment not properly prepared.");
Please login to merge, or discard this patch.