Merge branch 'php-censor-version'

This commit is contained in:
Dmitry Khomutov 2018-01-27 17:16:27 +07:00
commit 40356dccdc
No known key found for this signature in database
GPG key ID: EC19426474B37AAC
3 changed files with 56 additions and 17 deletions

View file

@ -119,6 +119,7 @@ class Application extends b8\Application
$controller->layout = new View('layout');
$controller->layout->title = 'PHP Censor';
$controller->layout->breadcrumb = [];
$controller->layout->version = trim(file_get_contents(ROOT_DIR . 'VERSION.md'));
return $controller;
}

View file

@ -29,11 +29,21 @@ use Phinx\Config\Config as PhinxConfig;
/**
* Class Application
*
*
* @package PHPCensor\Console
*/
class Application extends BaseApplication
{
const LOGO = <<<'LOGO'
____ __ ______ ______
/ __ \/ / / / __ \ / ____/__ ____ _________ _____
/ /_/ / /_/ / /_/ / / / / _ \/ __ \/ ___/ __ \/ ___/
/ ____/ __ / ____/ / /___/ __/ / / (__ ) /_/ / /
/_/ /_/ /_/_/ \____/\___/_/ /_/____/\____/_/
LOGO;
/**
* @param Config $applicationConfig
*
@ -53,18 +63,20 @@ class Application extends BaseApplication
$logger = new Logger('php-censor', $loggerHandlers);
Handler::register($logger);
return $logger;
}
/**
* Constructor.
*
* @param string $name The name of the application
* @param string $version The version of the application
*/
public function __construct($name = 'PHP Censor - Continuous Integration for PHP', $version = '')
public function __construct($name = 'PHP Censor', $version = 'UNKNOWN')
{
$version = trim(file_get_contents(ROOT_DIR . 'VERSION.md'));
parent::__construct($name, $version);
$applicationConfig = Config::getInstance();
@ -89,7 +101,7 @@ class Application extends BaseApplication
],
];
}
if (!empty($databaseSettings['port'])) {
$phinxSettings['environments']['php-censor']['port'] = (integer)$databaseSettings['port'];
}
@ -116,18 +128,18 @@ class Application extends BaseApplication
->setConfig($phinxConfig)
->setName('php-censor-migrations:status')
);
/** @var UserStore $userStore */
$userStore = Factory::getStore('User');
/** @var ProjectStore $projectStore */
$projectStore = Factory::getStore('Project');
/** @var BuildStore $buildStore */
$buildStore = Factory::getStore('Build');
$logger = $this->initLogger($applicationConfig);
$this->add(new RunCommand($logger));
$this->add(new RebuildCommand($logger));
$this->add(new InstallCommand());
@ -137,4 +149,27 @@ class Application extends BaseApplication
$this->add(new RebuildQueueCommand($logger));
$this->add(new ScheduleBuildCommand($projectStore, $buildStore, new BuildService($buildStore)));
}
public function getHelp()
{
return self::LOGO . parent::getHelp();
}
/**
* Returns the long version of the application.
*
* @return string The long application version
*/
public function getLongVersion()
{
if ('UNKNOWN' !== $this->getName()) {
if ('UNKNOWN' !== $this->getVersion()) {
return sprintf('<info>%s</info> v%s', $this->getName(), $this->getVersion());
}
return sprintf('<info>%s</info>', $this->getName());
}
return '<info>Console Tool</info>';
}
}

View file

@ -58,7 +58,7 @@
</a>
<div class="navbar-custom-menu">
<ul class="nav navbar-nav">
<li class="dropdown messages-menu app-pending">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<i class="fa fa-clock-o"></i>
@ -72,7 +72,7 @@
</li>
</ul>
</li>
<li class="dropdown messages-menu app-running">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<i class="fa fa-cogs"></i>
@ -86,7 +86,7 @@
</li>
</ul>
</li>
<?php if (!$this->LoginIsDisabled()->check()): ?>
<!-- User Account: style can be found in dropdown.less -->
<li class="dropdown user user-menu">
@ -102,7 +102,7 @@
<?php print $this->User()->getName(); ?>
</p>
</li>
<!-- Menu Footer-->
<li class="user-footer">
<div class="pull-left">
@ -249,9 +249,12 @@
}
?>
<?php print $content; ?>
</section><!-- /.content -->
</aside><!-- /.content-wrapper -->
</div><!-- ./wrapper -->
<?= $content; ?>
</section>
</aside>
<footer class="main-footer">
PHP Censor v<?= $version; ?>
</footer>
</div>
</body>
</html>