protected function getDatabasesFromSchema(\SplFileInfo $file) { $transformer = new \XmlToAppData(null, null, 'UTF-8'); $config = new \QuickGeneratorConfig(); if (file_exists($propelIni = $this->getContainer()->getParameter('kernel.root_dir') . '/config/propel.ini')) { foreach ($this->getProperties($propelIni) as $key => $value) { if (0 === strpos($key, 'propel.')) { $newKey = substr($key, strlen('propel.')); $j = strpos($newKey, '.'); while (false !== $j) { $newKey = substr($newKey, 0, $j) . ucfirst(substr($newKey, $j + 1)); $j = strpos($newKey, '.'); } $config->setBuildProperty($newKey, $value); } } } $transformer->setGeneratorConfig($config); return $transformer->parseFile($file->getPathName())->getDatabases(); }
/** * test if issue 425 is resolved */ public function testLoadBehavior() { $schema = <<<SCHEMA <database xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://xsd.propelorm.org/1.6/database.xsd" name="default" defaultIdMethod="native"> <table name="dummyTable"> <behavior name="foobar"/> <column name="dummyField1" type="char" size="36" required="true" primaryKey="true" /> <column name="dummyField2" type="integer" required="true" /> </table> </database> SCHEMA; $generatorConfig = new \QuickGeneratorConfig(); $generatorConfig->setBuildProperty('behaviorFoobarClass', 'Foobar\\Behavior\\Foobar'); $builder = new \PropelQuickBuilder(); $builder->setConfig($generatorConfig); $builder->setSchema($schema); $builder->build(); $this->assertTrue(class_exists('DummyTable'), 'dummy table class is correctly generated'); }