Skip to content
This repository was archived by the owner on Jul 17, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions Command/GenerateMappingCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,22 @@ protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new SymfonyStyle($input, $output);

$flexModel = $this->getContainer()->get('flexmodel');
$container = $this->getContainer();

$flexModel = $container->get('flexmodel');
$domDocument = $flexModel->getDOMDocument();

$bundleName = $container->getParameter('flex_model.bundle_name');
$bundle = $this->getApplication()->getKernel()->getBundle($bundleName);

$xslDocument = new DOMDocument('1.0', 'UTF-8');
$xslDocument->load(__DIR__.'/../Resources/xsl/doctrine-mapping.xsl');

$processor = new XSLTProcessor();
$processor->setParameter('', 'objectNamespace', 'AppBundle\\Entity\\'); // @todo Make configurable
$processor->setParameter('', 'objectNamespace', sprintf('%s\\Entity\\', $bundle->getNamespace()));
$processor->importStyleSheet($xslDocument);

$bundle = $this->getApplication()->getKernel()->getBundle('AppBundle'); // @todo Make configurable

$ormMappingDirectory = $bundle->getPath().'/Resources/config/doctrine'; // @todo Make configurable
$ormMappingDirectory = $bundle->getPath().'/Resources/config/doctrine';
if (is_dir(dirname($ormMappingDirectory)) === false) {
mkdir($ormMappingDirectory, 0755, true);
}
Expand All @@ -63,6 +66,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
$io->success('Generated Doctrine mapping from FlexModel configuration.');

$command = $this->getApplication()->find('generate:doctrine:entities');
$command->run(new ArrayInput(array('name' => 'AppBundle')), $output);
$command->run(new ArrayInput(array('name' => $bundleName)), $output);
}
}
1 change: 1 addition & 0 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public function getConfigTreeBuilder()
$rootNode
->children()
->scalarNode('resource')->isRequired()->end()
->scalarNode('bundle_name')->defaultValue('AppBundle')->end()
->scalarNode('file_upload_path')->end()
->end();

Expand Down
1 change: 1 addition & 0 deletions DependencyInjection/FlexModelExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public function load(array $configs, ContainerBuilder $container)
$config = $this->processConfiguration($configuration, $configs);

$container->setParameter('flex_model.resource', $config['resource']);
$container->setParameter('flex_model.bundle_name', $config['bundle_name']);

$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.xml');
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Add the following configuration to your `config.yml` file:
# app/config/config.yml

flex_model:
bundle_name: AppBundle # optional, defaults to 'AppBundle'
resource: "%kernel.root_dir%/../src/AppBundle/Resources/config/flexmodel.xml"
```

Expand Down