Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 68 lines (53 sloc) 2.237 kb
0b85aba William Durand [Command] Added a new command named: propel:form:generate
willdurand authored
1 <?php
2
3 /**
4 * This file is part of the PropelBundle package.
5 * For the full copyright and license information, please view the LICENSE
6 * file that was distributed with this source code.
7 *
8 * @license MIT License
9 */
10
11 namespace Propel\PropelBundle\Command;
12
13 use Symfony\Component\Console\Input\InputInterface;
14 use Symfony\Component\Console\Output\OutputInterface;
15
16 /**
17 * @author William Durand <william.durand1@gmail.com>
18 */
29ca595 William Durand Removed 'Propel' class prefixes
willdurand authored
19 abstract class GeneratorAwareCommand extends AbstractCommand
0b85aba William Durand [Command] Added a new command named: propel:form:generate
willdurand authored
20 {
21 /**
22 * {@inheritdoc}
23 */
24 protected function initialize(InputInterface $input, OutputInterface $output)
25 {
26 parent::initialize($input, $output);
27
28 $this->loadPropelGenerator();
29 }
30
31 protected function loadPropelGenerator()
32 {
33 $propelPath = $this->getContainer()->getParameter('propel.path');
34
35 require_once sprintf('%s/generator/lib/builder/util/XmlToAppData.php', $propelPath);
36 require_once sprintf('%s/generator/lib/config/GeneratorConfig.php', $propelPath);
37 require_once sprintf('%s/generator/lib/config/QuickGeneratorConfig.php', $propelPath);
38
39 set_include_path(sprintf('%s/generator/lib', $propelPath) . PATH_SEPARATOR . get_include_path());
40 }
41
42 protected function getDatabasesFromSchema(\SplFileInfo $file)
43 {
44 $transformer = new \XmlToAppData(null, null, 'UTF-8');
f68972f William Durand Fixed PropelGeneratorAwareCommand to use the propel.ini file
willdurand authored
45 $config = new \QuickGeneratorConfig();
46
47 if (file_exists($propelIni = $this->getContainer()->getParameter('kernel.root_dir') . '/config/propel.ini')) {
48 foreach ($this->getProperties($propelIni) as $key => $value) {
49 if (0 === strpos($key, 'propel.')) {
50 $newKey = substr($key, strlen('propel.'));
51
52 $j = strpos($newKey, '.');
53 while (false !== $j) {
54 $newKey = substr($newKey, 0, $j) . ucfirst(substr($newKey, $j + 1));
55 $j = strpos($newKey, '.');
56 }
57
58 $config->setBuildProperty($newKey, $value);
59 }
60 }
61 }
62
63 $transformer->setGeneratorConfig($config);
0b85aba William Durand [Command] Added a new command named: propel:form:generate
willdurand authored
64
65 return $transformer->parseFile($file->getPathName())->getDatabases();
66 }
67 }
Something went wrong with that request. Please try again.