src/Graviton/CoreBundle/Compiler/VersionCompilerPass.php
public function process(ContainerBuilder $container)
    {
        $rootDir = $container->getParameter('kernel.root_dir');

        if (strpos($rootDir, 'vendor') !== false) {
            $configurationFile = $rootDir.'/../../../../app';
        } else {
            $configurationFile = $rootDir;
        }

        $configurationFile .= '/config/version_service.yml';

        if (!file_exists($configurationFile)) {
            throw new \LogicException(
                'Could not read version configuration file "'.$configurationFile.'"'
            );
        }

        $config = Yaml::parseFile($configurationFile);
        $versionInformation = [
            'self' => 'unknown'
        ];

        if (isset($config['selfName'])) {
            $versionInformation['self'] = $this->getPackageVersion($config['selfName']);
        }

        if (isset($config['desiredVersions']) && is_array($config['desiredVersions'])) {
            foreach ($config['desiredVersions'] as $name) {
                $versionInformation[$name] = $this->getPackageVersion($name);
            }
        }

        // for version header
        $versionHeader = '';
        foreach ($versionInformation as $name => $version) {
            $versionHeader .= $name . ': ' . $version . '; ';
        }

        $container->setParameter(
            'graviton.core.version.data',
            $versionInformation
        );
        $container->setParameter(
            'graviton.core.version.header',
            trim($versionHeader)
        );
    }
public function process(ContainerBuilder $container)
    {
        $rootDir = $container->getParameter('kernel.root_dir');

        if (strpos($rootDir, 'vendor') !== false) {
            $configurationFile = $rootDir.'/../../../../app';
        } else {
            $configurationFile = $rootDir;
        }

        $configurationFile .= '/config/version_service.yml';

        if (!file_exists($configurationFile)) {
            throw new \LogicException(
                'Could not read version configuration file "'.$configurationFile.'"'
            );
        }

        $config = Yaml::parseFile($configurationFile);
        $versionInformation = [
            'self' => 'unknown'
        ];

        if (isset($config['selfName'])) {
            $versionInformation['self'] = $this->getPackageVersion($config['selfName']);
        }

        if (isset($config['desiredVersions']) && is_array($config['desiredVersions'])) {
            foreach ($config['desiredVersions'] as $name) {
                $versionInformation[$name] = $this->getPackageVersion($name);
            }
        }

        // for version header
        $versionHeader = '';
        foreach ($versionInformation as $name => $version) {
            $versionHeader .= $name . ': ' . $version . '; ';
        }

        $container->setParameter(
            'graviton.core.version.data',
            $versionInformation
        );
        $container->setParameter(
            'graviton.core.version.header',
            trim($versionHeader)
        );
    }
public function process ( ContainerBuilder $ container ) { $ rootDir = $ container -> getParameter ( 'kernel.root_dir' ) ; if ( strpos ( $ rootDir , 'vendor' ) !== false ) { $ configurationFile = $ rootDir . '/../../../../app' ; } else { $ configurationFile = $ rootDir ; } $ configurationFile .= '/config/version_service.yml' ; if ( ! file_exists ( $ configurationFile ) ) { throw new \ LogicException ( 'Could not read version configuration file "' . $ configurationFile . '"' ) ; } $ config = Yaml :: parseFile ( $ configurationFile ) ; $ versionInformation = [ 'self' => 'unknown' ] ; if ( isset ( $ config [ 'selfName' ] ) ) { $ versionInformation [ 'self' ] = $ this -> getPackageVersion ( $ config [ 'selfName' ] ) ; } if ( isset ( $ config [ 'desiredVersions' ] ) && is_array ( $ config [ 'desiredVersions' ] ) ) { foreach ( $ config [ 'desiredVersions' ] as $ name ) { $ versionInformation [ $ name ] = $ this -> getPackageVersion ( $ name ) ; } } // for version header $ versionHeader = '' ; foreach ( $ versionInformation as $ name => $ version ) { $ versionHeader .= $ name . ': ' . $ version . '; ' ; } $ container -> setParameter ( 'graviton.core.version.data' , $ versionInformation ) ; $ container -> setParameter ( 'graviton.core.version.header' , trim ( $ versionHeader ) ) ; }
add version information of packages to the container

@param ContainerBuilder $container Container

@return void
add version information of packages to the container