Jarves\Propel\PropelHelper::collectSchemas PHP Method

collectSchemas() public method

public collectSchemas ( ) : boolean
return boolean
    public function collectSchemas()
    {
        $cacheDir = $this->getJarves()->getCacheDir() . '/propel/';
        if (!is_dir($cacheDir)) {
            mkdir($cacheDir);
        }
        $finder = Finder::create()->in($cacheDir)->files()->depth(0)->name('*.schema.xml');
        foreach ($finder as $file) {
            unlink($file->getPathname());
        }
        $prefix = $this->getJarves()->getSystemConfig()->getDatabase()->getPrefix();
        $schemeData = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n  <database name=\"default\" tablePrefix=\"{$prefix}\" defaultIdMethod=\"native\"\n";
        $jarvesBehavior = '<behavior name="\\Jarves\\Propel\\JarvesBehavior" />';
        $bundles = $this->getJarves()->getBundles();
        foreach ($bundles as $bundleName => $bundle) {
            if (file_exists($schema = $bundle->getPath() . '/Resources/config/jarves.propel.schema.built.xml')) {
                $extension = $bundle->getNamespace();
                $tables = simplexml_load_file($schema);
                $newSchema = $schemeData . ' namespace="' . ucfirst($extension) . '\\Model">';
                foreach ($tables->table as $table) {
                    $newSchema .= $table->asXML() . "\n    ";
                }
                $newSchema .= "{$jarvesBehavior}</database>";
                $file = $bundleName . '.schema.xml';
                file_put_contents($cacheDir . $file, $newSchema);
            }
        }
        return true;
    }