Skip to content

Commit

Permalink
combine schema files into one AppData
Browse files Browse the repository at this point in the history
This fixes #173.

In case the schema.xml files are referenced across multiple bundles, the \AppData needs to be extended by each bundle, before reading data from the respective \Database.
  • Loading branch information
havvg committed Jan 23, 2016
1 parent 4db28b7 commit da1f027
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 4 additions & 1 deletion Command/FormGenerateCommand.php
Expand Up @@ -52,8 +52,11 @@ protected function configure()
protected function execute(InputInterface $input, OutputInterface $output)
{
if ($schemas = $this->getSchemasFromBundle($this->bundle)) {
$schemas = $this->getFinalSchemas($this->getContainer()->get('kernel'));

$transformer = new \XmlToAppData(null, null, 'UTF-8');
foreach ($schemas as $fileName => $array) {
foreach ($this->getDatabasesFromSchema($array[1]) as $database) {
foreach ($this->getDatabasesFromSchema($array[1], $transformer) as $database) {
$this->createFormTypeFromDatabase($this->bundle, $database, $input->getArgument('models'), $output, $input->getOption('force'));
}
}
Expand Down
7 changes: 5 additions & 2 deletions Command/GeneratorAwareCommand.php
Expand Up @@ -38,9 +38,12 @@ protected function loadPropelGenerator()
set_include_path(sprintf('%s/generator/lib', $propelPath) . PATH_SEPARATOR . get_include_path());
}

protected function getDatabasesFromSchema(\SplFileInfo $file)
protected function getDatabasesFromSchema(\SplFileInfo $file, \XmlToAppData $transformer = null)
{
$transformer = new \XmlToAppData(null, null, 'UTF-8');
if (null === $transformer) {
$transformer = new \XmlToAppData(null, null, 'UTF-8');
}

$config = new \QuickGeneratorConfig();

if (file_exists($propelIni = $this->getContainer()->getParameter('kernel.root_dir') . '/config/propel.ini')) {
Expand Down

0 comments on commit da1f027

Please sign in to comment.