src/Phn/Dal/Engine.php
private function loadLayerAndCheck($path, array $stack)
    {
        if (in_array($path, $stack)) {
            throw new LogicException(sprintf(
                'Circular reference detected:'.PHP_EOL.'  - file: %s'.PHP_EOL.'  - load: %s then crash',
                implode(PHP_EOL.'  - load: ', $stack),
                $path
            ));
        }

        $metadata = unserialize(file_get_contents($this->getMetaFilename($path)));

        $pgVersion = $this->connection->getVersion();
        $cmpVersion = $metadata->getSupport();

        if (version_compare($pgVersion, $cmpVersion, '<')) {
            throw new LogicException(sprintf(
                'The current version of PostgreSQL is "%s" and the DAL "%s" requires a minimum version of "%s"',
                $pgVersion,
                $path,
                $cmpVersion
            ));
        }

        $stack[] = $path;

        $this->graphNodes[$path] = $graphNode = new GraphNode();

        $mapper = new HierarchicalMapper($graphNode);
        $mapper->setType('#', new FragmentConverter());

        $blueprint = new HierarchicalBlueprint($graphNode, $this->connection, $mapper, $this->executionStrategies, $this->environment);

        foreach ($metadata->getImports() as $import => $map) {
            $this->doLoad($import, $stack);

            $graphNode->import($this->graphNodes[$import], $map);
        }

        return $this->loadLayer($this->getFilename($path), $mapper, $blueprint);
    }
private function loadLayerAndCheck($path, array $stack)
    {
        if (in_array($path, $stack)) {
            throw new LogicException(sprintf(
                'Circular reference detected:'.PHP_EOL.'  - file: %s'.PHP_EOL.'  - load: %s then crash',
                implode(PHP_EOL.'  - load: ', $stack),
                $path
            ));
        }

        $metadata = unserialize(file_get_contents($this->getMetaFilename($path)));

        $pgVersion = $this->connection->getVersion();
        $cmpVersion = $metadata->getSupport();

        if (version_compare($pgVersion, $cmpVersion, '<')) {
            throw new LogicException(sprintf(
                'The current version of PostgreSQL is "%s" and the DAL "%s" requires a minimum version of "%s"',
                $pgVersion,
                $path,
                $cmpVersion
            ));
        }

        $stack[] = $path;

        $this->graphNodes[$path] = $graphNode = new GraphNode();

        $mapper = new HierarchicalMapper($graphNode);
        $mapper->setType('#', new FragmentConverter());

        $blueprint = new HierarchicalBlueprint($graphNode, $this->connection, $mapper, $this->executionStrategies, $this->environment);

        foreach ($metadata->getImports() as $import => $map) {
            $this->doLoad($import, $stack);

            $graphNode->import($this->graphNodes[$import], $map);
        }

        return $this->loadLayer($this->getFilename($path), $mapper, $blueprint);
    }
private function loadLayerAndCheck ( $ path , array $ stack ) { if ( in_array ( $ path , $ stack ) ) { throw new LogicException ( sprintf ( 'Circular reference detected:' . PHP_EOL . '  - file: %s' . PHP_EOL . '  - load: %s then crash' , implode ( PHP_EOL . '  - load: ' , $ stack ) , $ path ) ) ; } $ metadata = unserialize ( file_get_contents ( $ this -> getMetaFilename ( $ path ) ) ) ; $ pgVersion = $ this -> connection -> getVersion ( ) ; $ cmpVersion = $ metadata -> getSupport ( ) ; if ( version_compare ( $ pgVersion , $ cmpVersion , '<' ) ) { throw new LogicException ( sprintf ( 'The current version of PostgreSQL is "%s" and the DAL "%s" requires a minimum version of "%s"' , $ pgVersion , $ path , $ cmpVersion ) ) ; } $ stack [ ] = $ path ; $ this -> graphNodes [ $ path ] = $ graphNode = new GraphNode ( ) ; $ mapper = new HierarchicalMapper ( $ graphNode ) ; $ mapper -> setType ( '#' , new FragmentConverter ( ) ) ; $ blueprint = new HierarchicalBlueprint ( $ graphNode , $ this -> connection , $ mapper , $ this -> executionStrategies , $ this -> environment ) ; foreach ( $ metadata -> getImports ( ) as $ import => $ map ) { $ this -> doLoad ( $ import , $ stack ) ; $ graphNode -> import ( $ this -> graphNodes [ $ import ] , $ map ) ; } return $ this -> loadLayer ( $ this -> getFilename ( $ path ) , $ mapper , $ blueprint ) ; }
Loads the DAL for the given path and do some check about the supported version of the loaded files and that
there is no circular references between them.

This method will check that:

- The PostgreSQL version matches the supported version of the DAL.
- The loaded DAL does not induces circular reference.

@param string   $path  The path of the DAL to load.
@param string[] $stack The stack of paths that have been loaded since the current call.

@throws LogicException When a circular reference is detected.
@throws LogicException When the version of PostgreSQL doesn't match the minimum version required.

@return AbstractDal
Loads the DAL for the given path and do some check about the supported version of the loaded files and that there is no circular references between them .