Skip to content

Commit

Permalink
DI ITimestampFormatter into upgrade command
Browse files Browse the repository at this point in the history
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
  • Loading branch information
rullzer committed Dec 22, 2017
1 parent 09ed6a8 commit 624460f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
13 changes: 9 additions & 4 deletions core/Command/Upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
use OC\Console\TimestampFormatter;
use OC\Installer;
use OC\Updater;
use OCP\Console\ITimestampFormatter;
use OCP\IConfig;
use OCP\ILogger;
use Symfony\Component\Console\Command\Command;
Expand All @@ -61,16 +62,21 @@ class Upgrade extends Command {
/** @var ILogger */
private $logger;

/** @var ITimestampFormatter */
private $timestampFormatter;

/**
* @param IConfig $config
* @param ILogger $logger
* @param Installer $installer
* @param ITimestampFormatter $timestampFormatter
*/
public function __construct(IConfig $config, ILogger $logger, Installer $installer) {
public function __construct(IConfig $config, ILogger $logger, Installer $installer, ITimestampFormatter $timestampFormatter) {
parent::__construct();
$this->config = $config;
$this->logger = $logger;
$this->installer = $installer;
$this->timestampFormatter = $timestampFormatter;
}

protected function configure() {
Expand All @@ -96,9 +102,8 @@ protected function execute(InputInterface $input, OutputInterface $output) {
if(\OC::checkUpgrade(false)) {
if (OutputInterface::VERBOSITY_NORMAL < $output->getVerbosity()) {
// Prepend each line with a little timestamp
$timestampFormatter = new TimestampFormatter($this->config);
$timestampFormatter->setFormatter($output->getFormatter());
$output->setFormatter($timestampFormatter);
$this->timestampFormatter->setFormatter($output->getFormatter());
$output->setFormatter($this->stimestampFormatter);
}

$self = $this;
Expand Down
7 changes: 6 additions & 1 deletion core/register_command.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,12 @@
$application->add(new OC\Core\Command\Maintenance\UpdateHtaccess());
$application->add(new OC\Core\Command\Maintenance\UpdateTheme(\OC::$server->getMimeTypeDetector(), \OC::$server->getMemCacheFactory()));

$application->add(new OC\Core\Command\Upgrade(\OC::$server->getConfig(), \OC::$server->getLogger(), \OC::$server->query(\OC\Installer::class)));
$application->add(new OC\Core\Command\Upgrade(
\OC::$server->getConfig(),
\OC::$server->getLogger(),
\OC::$server->query(\OC\Installer::class),
\OC::$server->query(\OCP\Console\ITimestampFormatter::class)
));
$application->add(new OC\Core\Command\Maintenance\Repair(
new \OC\Repair(\OC\Repair::getRepairSteps(), \OC::$server->getEventDispatcher()), \OC::$server->getConfig(),
\OC::$server->getEventDispatcher(), \OC::$server->getAppManager()));
Expand Down
3 changes: 2 additions & 1 deletion lib/private/Console/TimestampFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@
namespace OC\Console;


use OCP\Console\ITimestampFormatter;
use OCP\IConfig;
use Symfony\Component\Console\Formatter\OutputFormatter;
use Symfony\Component\Console\Formatter\OutputFormatterInterface;
use Symfony\Component\Console\Formatter\OutputFormatterStyleInterface;

class TimestampFormatter implements OutputFormatterInterface {
class TimestampFormatter implements ITimestampFormatter {
/** @var IConfig */
protected $config;

Expand Down
3 changes: 3 additions & 0 deletions lib/private/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
use OC\Collaboration\Collaborators\RemotePlugin;
use OC\Collaboration\Collaborators\UserPlugin;
use OC\Command\CronBus;
use OC\Console\TimestampFormatter;
use OC\Contacts\ContactsMenu\ActionFactory;
use OC\Contacts\ContactsMenu\ContactsStore;
use OC\Diagnostics\EventLogger;
Expand Down Expand Up @@ -1147,6 +1148,8 @@ public function __construct($webRoot, \OC\Config $config) {
});
$this->registerAlias(IContactsStore::class, ContactsStore::class);

$this->registerAlias(ITimestampFormatter::class, TimestampFormatter::class);

$this->connectDispatcher();
}

Expand Down

0 comments on commit 624460f

Please sign in to comment.