<?php
namespace Sintra\ApiBundle;
use Composer\InstalledVersions;
use Exception;
use LogBundle\LogBundle;
use Nelmio\ApiDocBundle\NelmioApiDocBundle;
use Pimcore\Extension\Bundle\AbstractPimcoreBundle;
use Pimcore\HttpKernel\Bundle\DependentBundleInterface;
use Pimcore\HttpKernel\BundleCollection\BundleCollection;
use Symfony\Bundle\SecurityBundle\SecurityBundle;
class SintraApiBundle extends AbstractPimcoreBundle implements DependentBundleInterface
{
public static function registerDependentBundles(BundleCollection $collection)
{
$collection->addBundle(new LogBundle(), 5000);
$collection->addBundle(new NelmioApiDocBundle(), 2000);
$collection->addBundle(new SecurityBundle(), 2000);
return $collection;
}
public function getJsPaths()
{
return [
'/bundles/sintraapi/js/pimcore/startup.js'
];
}
public function getVersion(): ?string
{
try {
$versionFile = "/var/www/html/sohproj.json";
if (file_exists($versionFile)) {
return json_decode(file_get_contents($versionFile))->version;
} else {
$packageName = json_decode(file_get_contents(__DIR__ . '/composer.json'))->name;
return InstalledVersions::getPrettyVersion($packageName);
}
} catch (Exception $ex) {
return "2.0.0";
}
}
}