Added an AsgardCms class containing the current cms version

parent 95aa9e1d
<?php
namespace Modules\Core;
class AsgardCms
{
/**
* The AsgardCms version.
* @var string
*/
const VERSION = '2.5.2';
}
......@@ -2,63 +2,16 @@
namespace Modules\Core\Composers;
use Illuminate\Contracts\Cache\Repository;
use Illuminate\Contracts\Filesystem\Filesystem;
use Illuminate\Contracts\View\View;
use Illuminate\Http\Request;
use Modules\Core\AsgardCms;
class ApplicationVersionViewComposer
{
/**
* @var Filesystem
*/
private $filesystem;
/**
* @var Repository
*/
private $cache;
/**
* @var Request
*/
private $request;
public function __construct(Filesystem $filesystem, Repository $cache, Request $request)
{
$this->filesystem = $filesystem;
$this->cache = $cache;
$this->request = $request;
}
public function compose(View $view)
{
if (app('asgard.onBackend') === false) {
return;
}
$view->with('version', $this->getAppVersion());
}
/**
* @return string
*/
private function getAppVersion()
{
$composerFile = $this->getComposerFile();
return isset($composerFile->version) ? $composerFile->version : '1.0';
}
/**
* Get the decoded contents from the main composer.json file
* @return object
*/
private function getComposerFile()
{
$appName = str_slug(config('app.name'));
$composerFile = $this->cache->remember("app.version.$appName", 1440, function () {
return $this->filesystem->get('composer.json');
});
return json_decode($composerFile);
$view->with('version', AsgardCms::VERSION);
}
}
url: https://github.com/AsgardCms/Platform
versions:
"2.x.x@unreleased":
added:
- Added an <code>AsgardCms</code> class containing the current cms version
"2.5.2":
changed:
- Fixing CLI issue not having the translation repository bound
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment