src/Graviton/GeneratorBundle/DependencyInjection/Compiler/GeneratorHashCompilerPass.php
public function process(ContainerBuilder $container)
    {
        // first type of hash: the genhash'es of all GravitonDyn bundles
        $dir = $container->getParameter('graviton.generator.dynamicbundle.dir');

        $dynHash = '';
        if (is_dir($dir)) {
            $finder = (new Finder())
                ->in($dir)
                ->files()
                ->sortByName()
                ->name('genhash');

            foreach ($finder as $file) {
                $dynHash .= DIRECTORY_SEPARATOR . $file->getContents();
            }
        }

        // 2nd hash: configuration of our own graviton things (static stuff)
        $staticHash = '';
        if (is_dir(__DIR__.'/../../../')) {
            $finder = (new Finder())
                ->in(__DIR__ . '/../../../')
                ->path('/serializer/')
                ->path('/doctrine/')
                ->path('/schema/')
                ->notPath('/Tests/')
                ->files()
                ->sortByName()
                ->name('*.xml')
                ->name('*.json');

            foreach ($finder as $file) {
                $staticHash .= DIRECTORY_SEPARATOR . sha1_file($file->getPathname());
            }
        }

        $dynHash = sha1($dynHash);
        $staticHash = sha1($staticHash);
        $allHash = sha1($dynHash . DIRECTORY_SEPARATOR . $staticHash);

        $container->setParameter('graviton.generator.hash.dyn', $dynHash);
        $container->setParameter('graviton.generator.hash.static', $staticHash);
        $container->setParameter('graviton.generator.hash.all', $allHash);
    }
public function process(ContainerBuilder $container)
    {
        // first type of hash: the genhash'es of all GravitonDyn bundles
        $dir = $container->getParameter('graviton.generator.dynamicbundle.dir');

        $dynHash = '';
        if (is_dir($dir)) {
            $finder = (new Finder())
                ->in($dir)
                ->files()
                ->sortByName()
                ->name('genhash');

            foreach ($finder as $file) {
                $dynHash .= DIRECTORY_SEPARATOR . $file->getContents();
            }
        }

        // 2nd hash: configuration of our own graviton things (static stuff)
        $staticHash = '';
        if (is_dir(__DIR__.'/../../../')) {
            $finder = (new Finder())
                ->in(__DIR__ . '/../../../')
                ->path('/serializer/')
                ->path('/doctrine/')
                ->path('/schema/')
                ->notPath('/Tests/')
                ->files()
                ->sortByName()
                ->name('*.xml')
                ->name('*.json');

            foreach ($finder as $file) {
                $staticHash .= DIRECTORY_SEPARATOR . sha1_file($file->getPathname());
            }
        }

        $dynHash = sha1($dynHash);
        $staticHash = sha1($staticHash);
        $allHash = sha1($dynHash . DIRECTORY_SEPARATOR . $staticHash);

        $container->setParameter('graviton.generator.hash.dyn', $dynHash);
        $container->setParameter('graviton.generator.hash.static', $staticHash);
        $container->setParameter('graviton.generator.hash.all', $allHash);
    }
public function process ( ContainerBuilder $ container ) { // first type of hash: the genhash'es of all GravitonDyn bundles $ dir = $ container -> getParameter ( 'graviton.generator.dynamicbundle.dir' ) ; $ dynHash = '' ; if ( is_dir ( $ dir ) ) { $ finder = ( new Finder ( ) ) -> in ( $ dir ) -> files ( ) -> sortByName ( ) -> name ( 'genhash' ) ; foreach ( $ finder as $ file ) { $ dynHash .= DIRECTORY_SEPARATOR . $ file -> getContents ( ) ; } } // 2nd hash: configuration of our own graviton things (static stuff) $ staticHash = '' ; if ( is_dir ( __DIR__ . '/../../../' ) ) { $ finder = ( new Finder ( ) ) -> in ( __DIR__ . '/../../../' ) -> path ( '/serializer/' ) -> path ( '/doctrine/' ) -> path ( '/schema/' ) -> notPath ( '/Tests/' ) -> files ( ) -> sortByName ( ) -> name ( '*.xml' ) -> name ( '*.json' ) ; foreach ( $ finder as $ file ) { $ staticHash .= DIRECTORY_SEPARATOR . sha1_file ( $ file -> getPathname ( ) ) ; } } $ dynHash = sha1 ( $ dynHash ) ; $ staticHash = sha1 ( $ staticHash ) ; $ allHash = sha1 ( $ dynHash . DIRECTORY_SEPARATOR . $ staticHash ) ; $ container -> setParameter ( 'graviton.generator.hash.dyn' , $ dynHash ) ; $ container -> setParameter ( 'graviton.generator.hash.static' , $ staticHash ) ; $ container -> setParameter ( 'graviton.generator.hash.all' , $ allHash ) ; }
generate the hashes

@param ContainerBuilder $container container builder

@return void
generate the hashes