Command/GenerateDocumentClassCommand.php
changeset 23 b435f8055cb4
parent 18 6f16b9fd6a17
--- a/Command/GenerateDocumentClassCommand.php	Fri Oct 28 14:57:11 2011 +0200
+++ b/Command/GenerateDocumentClassCommand.php	Fri Nov 04 11:56:59 2011 +0100
@@ -16,10 +16,6 @@
 use Symfony\Component\Console\Input\InputInterface;
 use Symfony\Component\Console\Input\InputOption;
 use Symfony\Component\Console\Output\OutputInterface;
-use Mandango\Mondator\Definition\Definition;
-use Mandango\Mondator\Definition\Property;
-use Mandango\Mondator\Definition\Method;
-use Mandango\Mondator\Dumper;
 
 class GenerateDocumentClassCommand extends ContainerAwareCommand
 {
@@ -42,32 +38,9 @@
             $path = realpath($this->getContainer()->get('kernel')->getRootDir()."/../src");
         }
         
-        $definition = new Definition('IRI\Bundle\WikiTagBundle\Entity\Document');
-        
-        $definition->setParentClass('\IRI\Bundle\WikiTagBundle\Model\Document');
+        $schema_utils = $this->getContainer()->get("wikitag.shema_utils");
         
-        $fields = $this->getContainer()->getParameter('wiki_tag.fields');
-        foreach ( $fields as $name => $field_def)
-        {
-            $property = new Property("private", $name, NULL);
-            $definition->addProperty($property);
-            
-            $get_method = new Method("public", "get".ucfirst($name), NULL, <<<EOF
-                return \$this->$name;
-EOF
-            );
-            $definition->addMethod($get_method);
-            
-            $set_method = new Method("public", "set".ucfirst($name), "\$$name", <<<EOF
-                \$this->$name = \$$name;
-EOF
-            );
-            $definition->addMethod($set_method);
-            
-        }
-                
-        $dumper = new Dumper($definition);
-        $classCode = $dumper->dump();
+        $classCode = $schema_utils->generateDocumentClass();
         
         if($input->getOption('simulate'))
         {