public function testTest()
 {
     if (!class_exists('Symfony\\Component\\Yaml\\Yaml', true)) {
         $this->markTestSkipped('Please install Symfony YAML Component into the include path of your PHP installation.');
     }
     $cme = new ClassMetadataExporter();
     $converter = new ConvertDoctrine1Schema(__DIR__ . '/doctrine1schema');
     $exporter = $cme->getExporter('yml', __DIR__ . '/convert');
     $exporter->setOverwriteExistingFiles(true);
     $exporter->setMetadata($converter->getMetadata());
     $exporter->export();
     $this->assertTrue(file_exists(__DIR__ . '/convert/User.dcm.yml'));
     $this->assertTrue(file_exists(__DIR__ . '/convert/Profile.dcm.yml'));
     $metadataDriver = new \Doctrine\ORM\Mapping\Driver\YamlDriver(__DIR__ . '/convert');
     $em = $this->_createEntityManager($metadataDriver);
     $cmf = new DisconnectedClassMetadataFactory();
     $cmf->setEntityManager($em);
     $metadata = $cmf->getAllMetadata();
     $profileClass = $cmf->getMetadataFor('Profile');
     $userClass = $cmf->getMetadataFor('User');
     $this->assertEquals(2, count($metadata));
     $this->assertEquals('Profile', $profileClass->name);
     $this->assertEquals('User', $userClass->name);
     $this->assertEquals(4, count($profileClass->fieldMappings));
     $this->assertEquals(5, count($userClass->fieldMappings));
     $this->assertEquals('text', $userClass->fieldMappings['clob']['type']);
     $this->assertEquals('test_alias', $userClass->fieldMappings['theAlias']['columnName']);
     $this->assertEquals('theAlias', $userClass->fieldMappings['theAlias']['fieldName']);
     $this->assertEquals('Profile', $profileClass->associationMappings['User']['sourceEntity']);
     $this->assertEquals('User', $profileClass->associationMappings['User']['targetEntity']);
     $this->assertEquals('username', $userClass->table['uniqueConstraints']['username']['columns'][0]);
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $bundleClass = null;
     $bundleDirs = $this->container->get('kernel')->getBundleDirs();
     foreach ($this->container->get('kernel')->getBundles() as $bundle) {
         if (strpos(get_class($bundle), $input->getArgument('bundle')) !== false) {
             $tmp = dirname(str_replace('\\', '/', get_class($bundle)));
             $namespace = str_replace('/', '\\', dirname($tmp));
             $class = basename($tmp);
             if (isset($bundleDirs[$namespace])) {
                 $destPath = realpath($bundleDirs[$namespace]) . '/' . $class;
                 $bundleClass = $class;
                 break;
             }
         }
     }
     $type = $input->getArgument('mapping-type') ? $input->getArgument('mapping-type') : 'xml';
     if ('annotation' === $type) {
         $destPath .= '/Entity';
     } else {
         $destPath .= '/Resources/config/doctrine/metadata/orm';
     }
     if ('yaml' === $type) {
         $type = 'yml';
     }
     $cme = new ClassMetadataExporter();
     $exporter = $cme->getExporter($type);
     if ('annotation' === $type) {
         $entityGenerator = $this->getEntityGenerator();
         $exporter->setEntityGenerator($entityGenerator);
     }
     $emName = $input->getOption('em') ? $input->getOption('em') : 'default';
     $emServiceName = sprintf('doctrine.orm.%s_entity_manager', $emName);
     $em = $this->container->get($emServiceName);
     $databaseDriver = new DatabaseDriver($em->getConnection()->getSchemaManager());
     $em->getConfiguration()->setMetadataDriverImpl($databaseDriver);
     $cmf = new DisconnectedClassMetadataFactory();
     $cmf->setEntityManager($em);
     $metadata = $cmf->getAllMetadata();
     if ($metadata) {
         $output->writeln(sprintf('Importing mapping information from "<info>%s</info>" entity manager', $emName));
         foreach ($metadata as $class) {
             $className = $class->name;
             $class->name = $namespace . '\\' . $bundleClass . '\\Entity\\' . $className;
             if ('annotation' === $type) {
                 $path = $destPath . '/' . $className . '.php';
             } else {
                 $path = $destPath . '/' . str_replace('\\', '.', $class->name) . '.dcm.' . $type;
             }
             $output->writeln(sprintf('  > writing <comment>%s</comment>', $path));
             $code = $exporter->exportClassMetadata($class);
             if (!is_dir($dir = dirname($path))) {
                 mkdir($dir, 0777, true);
             }
             file_put_contents($path, $code);
         }
     } else {
         $output->writeln('Database does not have any mapping information.' . PHP_EOL, 'ERROR');
     }
 }
 function testCreateSchema()
 {
     /* @var $em \Doctrine\ORM\EntityManager */
     $em = $this->app["orm.em"];
     $tool = new SchemaTool($em);
     //@note @doctrine générer les fichiers de classe à partir de métadonnées
     /* generate entity classes */
     $dmf = new DisconnectedClassMetadataFactory();
     $dmf->setEntityManager($em);
     $metadatas = $dmf->getAllMetadata();
     //print_r($metadatas);
     $generator = new EntityGenerator();
     $generator->setGenerateAnnotations(TRUE);
     $generator->setGenerateStubMethods(TRUE);
     $generator->setRegenerateEntityIfExists(TRUE);
     $generator->setUpdateEntityIfExists(TRUE);
     $generator->generate($metadatas, ROOT_TEST_DIR);
     $generator->setNumSpaces(4);
     $this->assertFileExists(ROOT_TEST_DIR . "/Entity/Post.php");
     /* @note @doctrine générer la base de donnée à partir des métadonnées */
     /* @see Doctrine\ORM\Tools\Console\Command\SchemaTool\CreateCommand */
     /* generate database */
     $tool->dropSchema($metadatas);
     $tool->createSchema($metadatas);
     $post = new \Entity\Post();
     $post->setTitle("the title");
     $em->persist($post);
     $em->flush();
     $this->assertInternalType("int", $post->getId());
 }
 public function __construct()
 {
     try {
         $conn = array("driver" => "pdo_mysql", "host" => "localhost", "port" => "3306", "user" => "root", "password" => "", "dbname" => "controle_gastos");
         /*
         var_dump(__DIR__);
         var_dump(PP);
         exit;
         */
         $loader = new \Doctrine\Common\ClassLoader("Entities", __DIR__);
         $loader->register();
         $config = Setup::createAnnotationMetadataConfiguration(array("../../" . __DIR__ . "/app/models"), false);
         $em = EntityManager::create($conn, $config);
         $cmf = new DisconnectedClassMetadataFactory();
         $cmf->setEntityManager($em);
         $em->getConnection()->getDatabasePlatform()->registerDoctrineTypeMapping('set', 'string');
         $em->getConnection()->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');
         $driver = new DatabaseDriver($em->getConnection()->getSchemaManager());
         $em->getConfiguration()->setMetadataDriverImpl($driver);
         $metadata = $cmf->getAllMetadata();
         $generator = new EntityGenerator();
         $generator->setGenerateAnnotations(true);
         $generator->setGenerateStubMethods(true);
         $generator->setRegenerateEntityIfExists(true);
         $generator->setUpdateEntityIfExists(true);
         $generator->generate($metadata, "../../" . __DIR__ . "/app/models");
     } catch (\Exception $e) {
         throw $e;
     }
 }
示例#5
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $dbName = $input->getArgument('dbname');
     $path = $input->getOption('path');
     $extensionKey = $input->getOption('extension-key');
     $connectionParams = array('dbname' => $dbName, 'user' => $input->getOption('user'), 'password' => $input->getOption('password'), 'host' => $input->getOption('host'), 'driver' => $input->getOption('driver'), 'port' => $input->getOption('port'));
     $config = Setup::createAnnotationMetadataConfiguration(array('.'), false);
     $em = EntityManager::create($connectionParams, $config);
     $em->getConfiguration()->setMetadataDriverImpl(new \Doctrine\ORM\Mapping\Driver\DatabaseDriver($em->getConnection()->getSchemaManager()));
     $cmf = new DisconnectedClassMetadataFactory();
     $cmf->setEntityManager($em);
     if (is_null($extensionKey)) {
         $extensionKey = $dbName;
         if (self::DEFAULT_PATH != $path) {
             $extensionKey = array_pop(explode(DIRECTORY_SEPARATOR, $path));
         }
     }
     $exporter = new ExtbaseExporter($cmf);
     $exporter->setExtensionKey($extensionKey);
     $exporter->setPath($input->getOption('path'));
     self::mapDefaultInputOptions($exporter, $input);
     $output->writeln(sprintf('Exporting database schema "<info>%s</info>".', $dbName));
     $result = $exporter->exportJson();
     foreach ($exporter->getLogs() as $log) {
         $output->writeln($log);
     }
     return $result ? 0 : 1;
 }
 /**
  * Read declared business entities and BusinessEntityPatternPages to generate their urls
  * @param InputInterface  $input
  * @param OutputInterface $output
  *
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $progress = $this->getHelperSet()->get('progress');
     $progress->setProgressCharacter('V');
     $progress->setEmptyBarCharacter('-');
     $entityManager = $this->getContainer()->get('doctrine.orm.entity_manager');
     $cmf = new DisconnectedClassMetadataFactory();
     $cmf->setEntityManager($entityManager);
     $metadatas = $cmf->getAllMetadata();
     $classes = [];
     $output->writeln('<info>Parse every classes to know which ones are related to Link</info>');
     $progress->start($output, count($metadatas));
     foreach ($metadatas as $key => $metadata) {
         $progress->advance();
         if ($metadata->hasAssociation('link')) {
             $association = $metadata->getAssociationMapping('link');
             if ('Victoire\\Bundle\\CoreBundle\\Entity\\Link' === $association['targetEntity']) {
                 $classes[] = $metadata;
             }
         }
     }
     $progress->finish();
     $counter = 0;
     if (count($classes)) {
         $output->writeln('<info>Let\'s migrate</info>');
         $progress->start($output, count($classes));
         foreach ($classes as $class) {
             $progress->advance();
             //get the full universe of entities thanks to the entity repository
             $objects = $entityManager->getRepository($class->name)->findAll();
             foreach ($objects as $object) {
                 if (!$object->hasLink()) {
                     //Create a Link according to the legacy link trait properties
                     $link = new Link();
                     $object->setLink($link);
                     //fill the values
                     $link->setUrl($object->url);
                     $link->setTarget($object->target);
                     $link->setRoute($object->route);
                     $link->setRouteParameters($object->routeParameters);
                     $link->setPage($object->page);
                     $link->setLinkType($object->linkType);
                     $link->setAttachedWidget($object->attachedWidget);
                     $link->setAnalyticsTrackCode($object->analyticsTrackCode);
                     //persist the new link and the relation
                     $entityManager->persist($object);
                     $entityManager->persist($link);
                     $entityManager->flush();
                     $counter++;
                 }
             }
         }
         $progress->finish();
         $output->writeln(sprintf('<comment>Ok, %s records migrated !</comment>', $counter));
     }
     if (0 == $counter) {
         $output->writeln('<comment>Nothing to do...</comment>');
     }
 }
 /**
  *
  */
 public function __construct(App $app, EntityManager $em, DisconnectedClassMetadataFactory $cmf)
 {
     $cmf->setEntityManager($em);
     $this->app = $app;
     $this->metaData = $cmf->getAllMetaData();
     $this->entityManager = $em;
     parent::__construct('orm:generate:classes');
 }
示例#8
0
 /**
  * @see Console\Command\Command
  */
 protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
 {
     $em = $this->getHelper('em')->getEntityManager();
     if (\Zend_Registry::isRegistered(\LoSo_Zend_Application_Bootstrap_SymfonyContainerBootstrap::getRegistryIndex()) && ($container = \Zend_Registry::get(\LoSo_Zend_Application_Bootstrap_SymfonyContainerBootstrap::getRegistryIndex())) instanceof \Symfony\Component\DependencyInjection\ContainerInterface) {
         $mappingPaths = $container->getParameter('doctrine.orm.mapping_paths');
         $entitiesPaths = $container->getParameter('doctrine.orm.entities_paths');
     } else {
         $doctrineConfig = \Zend_Registry::get('doctrine.config');
         $mappingPaths = $doctrineConfig['doctrine.orm.mapping_paths'];
         $entitiesPaths = $doctrineConfig['doctrine.orm.entities_paths'];
     }
     $cmf = new DisconnectedClassMetadataFactory($em);
     $metadatas = $cmf->getAllMetadata();
     foreach ($mappingPaths as $namespace => $mappingPath) {
         // Process destination directory
         $destPath = realpath($entitiesPaths[$namespace]);
         if (!file_exists($destPath)) {
             throw new \InvalidArgumentException(sprintf("Entities destination directory '<info>%s</info>' does not exist.", $destPath));
         } else {
             if (!is_writable($destPath)) {
                 throw new \InvalidArgumentException(sprintf("Entities destination directory '<info>%s</info>' does not have write permissions.", $destPath));
             }
         }
         $moduleMetadatas = MetadataFilter::filter($metadatas, $namespace);
         if (count($moduleMetadatas)) {
             // Create EntityGenerator
             $entityGenerator = new EntityGenerator();
             $entityGenerator->setGenerateAnnotations($input->getOption('generate-annotations'));
             $entityGenerator->setGenerateStubMethods($input->getOption('generate-methods'));
             $entityGenerator->setRegenerateEntityIfExists($input->getOption('regenerate-entities'));
             $entityGenerator->setUpdateEntityIfExists($input->getOption('update-entities'));
             $entityGenerator->setNumSpaces($input->getOption('num-spaces'));
             if (($extend = $input->getOption('extend')) !== null) {
                 $entityGenerator->setClassToExtend($extend);
             }
             foreach ($moduleMetadatas as $metadata) {
                 $output->write(sprintf('Processing entity "<info>%s</info>"', $metadata->name) . PHP_EOL);
             }
             // Generating Entities
             $entityGenerator->generate($moduleMetadatas, $destPath);
             $this->_processNamespaces($destPath, $namespace);
             // Outputting information message
             $output->write(sprintf('Entity classes generated to "<info>%s</INFO>"', $destPath) . PHP_EOL);
         } else {
             $output->write('No Metadata Classes to process.' . PHP_EOL);
         }
     }
     /*$output->write(PHP_EOL . 'Reset database.' . PHP_EOL);
     
             $metadatas = $em->getMetadataFactory()->getAllMetadata();
             $schemaTool = new \Doctrine\ORM\Tools\SchemaTool($em);
             $output->write('Dropping database schema...' . PHP_EOL);
             $schemaTool->dropSchema($metadatas);
             $output->write('Database schema dropped successfully!' . PHP_EOL);
             $output->write('Creating database schema...' . PHP_EOL);
             $schemaTool->createSchema($metadatas);
             $output->write('Database schema created successfully!' . PHP_EOL);*/
 }
示例#9
0
 protected function getAllMetadata(array $entity)
 {
     $metadata = array();
     $cmf = new DisconnectedClassMetadataFactory();
     $cmf->setEntityManager($this->_em);
     foreach ($entity as $e) {
         $metadata[] = $cmf->getMetadataFor($e);
     }
     return $metadata;
 }
 protected function _createClassMetadataFactory($em, $type)
 {
     if ($type === 'annotation') {
         $factory = new ClassMetadataFactory();
     } else {
         $factory = new DisconnectedClassMetadataFactory();
     }
     $factory->setEntityManager($em);
     return $factory;
 }
示例#11
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $bundle = $this->getApplication()->getKernel()->getBundle($input->getArgument('bundle'));
     $destPath = $bundle->getPath();
     /*  $type = $input->getArgument('mapping-type') ? $input->getArgument('mapping-type') : 'xml';
         if ('annotation' === $type) {
             $destPath .= '/Entity/Base';
         } else {
             $destPath .= '/Resources/config/doctrine';
         }
         if ('yaml' === $type) {
             $type = 'yml';
         }*/
     $cme = new ClassMetadataExporter();
     $exporter = $cme->getExporter($type);
     $exporter->setOverwriteExistingFiles($input->getOption('force'));
     if ('annotation' === $type) {
         $entityGenerator = $this->getEntityGenerator();
         $exporter->setEntityGenerator($entityGenerator);
     }
     $em = $this->getEntityManager($input->getOption('em'));
     $databaseDriver = new DatabaseDriver($em->getConnection()->getSchemaManager());
     $em->getConfiguration()->setMetadataDriverImpl($databaseDriver);
     $emName = $input->getOption('em');
     $emName = $emName ? $emName : 'default';
     $cmf = new DisconnectedClassMetadataFactory();
     $cmf->setEntityManager($em);
     $metadata = $cmf->getAllMetadata();
     $metadata = MetadataFilter::filter($metadata, $input->getOption('filter'));
     if ($metadata) {
         $output->writeln(sprintf('Importing mapping information from "<info>%s</info>" entity manager', $emName));
         foreach ($metadata as $class) {
             $className = $class->name;
             $class->name = $bundle->getNamespace() . '\\Entity\\Base\\' . $className;
             if ('annotation' === $type) {
                 $path = $destPath . '/' . $className . '.php';
             } else {
                 $path = $destPath . '/' . $className . '.orm.' . $type;
             }
             $output->writeln(sprintf('  > writing <comment>%s</comment>', $path));
             $code = $exporter->exportClassMetadata($class);
             if (!is_dir($dir = dirname($path))) {
                 mkdir($dir, 0777, true);
             }
             $code = str_replace('private $', 'protected $', $code);
             file_put_contents($path, $code);
             $mainFilePath = $destPath . '/../' . $className . '.php';
             $output->writeln(sprintf('  > writing <comment>%s</comment>', $mainFilePath));
             file_put_contents($mainFilePath, '<?php' . "\n\n" . 'namespace ' . $bundle->getNamespace() . '\\Entity;' . "\n\n" . 'use ' . $bundle->getNamespace() . '\\Entity\\Base\\' . $className . ' as Base' . $className . ';' . "\n\n" . 'class ' . $className . ' extends Base' . $className . "\n" . '{' . "\n" . '}');
         }
     } else {
         $output->writeln('Database does not have any mapping information.', 'ERROR');
         $output->writeln('', 'ERROR');
     }
 }
示例#12
0
 /**
  * generate entity objects automatically from mysql db tables
  * @return none
  */
 function generate_classes()
 {
     $this->em->getConfiguration()->setMetadataDriverImpl(new DatabaseDriver($this->em->getConnection()->getSchemaManager()));
     $cmf = new DisconnectedClassMetadataFactory();
     $cmf->setEntityManager($this->em);
     $metadata = $cmf->getAllMetadata();
     $generator = new EntityGenerator();
     $generator->setUpdateEntityIfExists(true);
     $generator->setGenerateStubMethods(true);
     $generator->setGenerateAnnotations(true);
     $generator->generate($metadata, APPPATH . "models/Entities");
 }
示例#13
0
 protected function findAllMetadatas()
 {
     $metadatas = array();
     foreach ($this->container->get('doctrine')->getEntityManagerNames() as $id) {
         $cmf = new DisconnectedClassMetadataFactory();
         $cmf->setEntityManager($this->container->get($id));
         foreach ($cmf->getAllMetadata() as $metadata) {
             $metadatas[$metadata->name] = $metadata;
         }
     }
     return $metadatas;
 }
 /**
  * @see Console\Command\Command
  */
 protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
 {
     $em = $this->getHelper('em')->getEntityManager();
     if ($input->getOption('from-database') === true) {
         $databaseDriver = new \Doctrine\ORM\Mapping\Driver\DatabaseDriver($em->getConnection()->getSchemaManager());
         $em->getConfiguration()->setMetadataDriverImpl($databaseDriver);
         if (($namespace = $input->getOption('namespace')) !== null) {
             $databaseDriver->setNamespace($namespace);
         }
     }
     $cmf = new DisconnectedClassMetadataFactory();
     $cmf->setEntityManager($em);
     $metadata = $cmf->getAllMetadata();
     $metadata = MetadataFilter::filter($metadata, $input->getOption('filter'));
     // Process destination directory
     if (!is_dir($destPath = $input->getArgument('dest-path'))) {
         mkdir($destPath, 0777, true);
     }
     $destPath = realpath($destPath);
     if (!file_exists($destPath)) {
         throw new \InvalidArgumentException(sprintf("Mapping destination directory '<info>%s</info>' does not exist.", $destPath));
     } else {
         if (!is_writable($destPath)) {
             throw new \InvalidArgumentException(sprintf("Mapping destination directory '<info>%s</info>' does not have write permissions.", $destPath));
         }
     }
     $toType = strtolower($input->getArgument('to-type'));
     $exporter = $this->getExporter($toType, $destPath);
     $exporter->setOverwriteExistingFiles($input->getOption('force') !== false);
     if ($toType == 'annotation') {
         $entityGenerator = new \Internshala\Doctrine_Extension\Entity_Generator();
         //$entityGenerator = new EntityGenerator();
         $exporter->setEntityGenerator($entityGenerator);
         $entityGenerator->setNumSpaces($input->getOption('num-spaces'));
         if (($extend = $input->getOption('extend')) !== null) {
             $entityGenerator->setClassToExtend($extend);
         }
     }
     if (count($metadata)) {
         foreach ($metadata as $class) {
             $output->write(sprintf('Processing entity "<info>%s</info>"', $class->name) . PHP_EOL);
         }
         $exporter->setMetadata($metadata);
         $exporter->export();
         $output->write(PHP_EOL . sprintf('Exporting "<info>%s</info>" mapping information to "<info>%s</info>"' . PHP_EOL, $toType, $destPath));
     } else {
         $output->write('No Metadata Classes to process.' . PHP_EOL);
     }
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $bundle = $this->application->getKernel()->getBundle($input->getArgument('bundle'));
     $destPath = $bundle->getPath();
     $type = $input->getArgument('mapping-type') ? $input->getArgument('mapping-type') : 'xml';
     if ('annotation' === $type) {
         $destPath .= '/Entity';
     } else {
         $destPath .= '/Resources/config/doctrine/metadata/orm';
     }
     if ('yaml' === $type) {
         $type = 'yml';
     }
     $cme = new ClassMetadataExporter();
     $exporter = $cme->getExporter($type);
     if ('annotation' === $type) {
         $entityGenerator = $this->getEntityGenerator();
         $exporter->setEntityGenerator($entityGenerator);
     }
     $em = $this->getEntityManager($this->container, $input->getOption('em'));
     $databaseDriver = new DatabaseDriver($em->getConnection()->getSchemaManager());
     $em->getConfiguration()->setMetadataDriverImpl($databaseDriver);
     $cmf = new DisconnectedClassMetadataFactory();
     $cmf->setEntityManager($em);
     $metadata = $cmf->getAllMetadata();
     if ($metadata) {
         $output->writeln(sprintf('Importing mapping information from "<info>%s</info>" entity manager', $emName));
         foreach ($metadata as $class) {
             $className = $class->name;
             $class->name = $bundle->getNamespace() . '\\Entity\\' . $className;
             if ('annotation' === $type) {
                 $path = $destPath . '/' . $className . '.php';
             } else {
                 $path = $destPath . '/' . str_replace('\\', '.', $class->name) . '.dcm.' . $type;
             }
             $output->writeln(sprintf('  > writing <comment>%s</comment>', $path));
             $code = $exporter->exportClassMetadata($class);
             if (!is_dir($dir = dirname($path))) {
                 mkdir($dir, 0777, true);
             }
             file_put_contents($path, $code);
         }
     } else {
         $output->writeln('Database does not have any mapping information.' . PHP_EOL, 'ERROR');
     }
 }
示例#16
0
 public function fire()
 {
     $this->info('Starting entities generation....');
     // flush all generated and cached entities, etc
     \D2Cache::flushAll();
     $cmf = new DisconnectedClassMetadataFactory();
     $cmf->setEntityManager($this->d2em);
     $metadata = $cmf->getAllMetadata();
     if (empty($metadata)) {
         $this->error('No metadata found to generate entities.');
         return -1;
     }
     $directory = Config::get('d2doctrine.paths.entities');
     if (!$directory) {
         $this->error('The entity directory has not been set.');
         return -1;
     }
     $entityGenerator = new EntityGenerator();
     $entityGenerator->setGenerateAnnotations($this->option('generate-annotations'));
     $entityGenerator->setGenerateStubMethods($this->option('generate-methods'));
     $entityGenerator->setRegenerateEntityIfExists($this->option('regenerate-entities'));
     $entityGenerator->setUpdateEntityIfExists($this->option('update-entities'));
     $entityGenerator->setNumSpaces($this->option('num-spaces'));
     $entityGenerator->setBackupExisting(!$this->option('no-backup'));
     $this->info('Processing entities:');
     foreach ($metadata as $item) {
         $this->line($item->name);
     }
     try {
         $entityGenerator->generate($metadata, $directory);
         $this->info('Entities have been created.');
     } catch (\ErrorException $e) {
         if ($this->option('verbose') == 3) {
             throw $e;
         }
         $this->error("Caught ErrorException: " . $e->getMessage());
         $this->info("Re-optimizing:");
         $this->call('optimize');
         $this->comment("*** You must now rerun this artisan command ***");
         exit(-1);
     }
 }
 /**
  * @see Console\Command\Command
  */
 protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
 {
     $em = $this->getHelper('em')->getEntityManager();
     $cmf = new DisconnectedClassMetadataFactory();
     $cmf->setEntityManager($em);
     $metadatas = $cmf->getAllMetadata();
     $metadatas = MetadataFilter::filter($metadatas, $input->getOption('filter'));
     // Process destination directory
     $destPath = realpath($input->getArgument('dest-path'));
     if (!file_exists($destPath)) {
         throw new \InvalidArgumentException(sprintf("Entities destination directory '<info>%s</info>' does not exist.", $destPath));
     } else {
         if (!is_writable($destPath)) {
             throw new \InvalidArgumentException(sprintf("Entities destination directory '<info>%s</info>' does not have write permissions.", $destPath));
         }
     }
     if (count($metadatas)) {
         // Create EntityGenerator
         $entityGenerator = new EntityGenerator();
         $entityGenerator->setGenerateAnnotations($input->getOption('generate-annotations'));
         $entityGenerator->setGenerateStubMethods($input->getOption('generate-methods'));
         $entityGenerator->setRegenerateEntityIfExists($input->getOption('regenerate-entities'));
         $entityGenerator->setUpdateEntityIfExists($input->getOption('update-entities'));
         $entityGenerator->setNumSpaces($input->getOption('num-spaces'));
         if (($attributeVisibility = $input->getOption('attribute-visibility')) !== null) {
             $entityGenerator->setAttributeVisibility($attributeVisibility);
         }
         if (($extend = $input->getOption('extend')) !== null) {
             $entityGenerator->setClassToExtend($extend);
         }
         foreach ($metadatas as $metadata) {
             $output->write(sprintf('Processing entity "<info>%s</info>"', $metadata->name) . PHP_EOL);
         }
         // Generating Entities
         $entityGenerator->generate($metadatas, $destPath);
         // Outputting information message
         $output->write(PHP_EOL . sprintf('Entity classes generated to "<info>%s</INFO>"', $destPath) . PHP_EOL);
     } else {
         $output->write('No Metadata Classes to process.' . PHP_EOL);
     }
 }
示例#18
0
 protected function prepare()
 {
     $this->metadata = $this->cmf->getAllMetadata();
     $this->metadata = MetadataFilter::filter($this->metadata, $this->filter);
     $this->filename = $this->path . '/' . self::PROJECT_FILE;
     if (!is_dir($dir = dirname($this->filename))) {
         mkdir($dir, 0777, true);
     }
     $configFile = $this->path . '/' . self::CONFIG_FILE;
     if (is_readable($configFile)) {
         $this->configuration = Yaml::parse(file_get_contents($configFile));
     }
 }
 /**
  * {@inheritDoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $em = $this->getContainer()->get('doctrine')->getManager($input->getOption('em'));
     $path = $input->getOption('path') ? $input->getOption('path') : $this->getContainer()->getParameter('kernel.cache_dir');
     if ($input->getOption('from-database')) {
         $em->getConfiguration()->setMetadataDriverImpl(new \Doctrine\ORM\Mapping\Driver\DatabaseDriver($em->getConnection()->getSchemaManager()));
     }
     $emName = $input->getOption('em');
     $emName = $emName ? $emName : 'default';
     $cmf = new DisconnectedClassMetadataFactory();
     $cmf->setEntityManager($em);
     $exporter = new ExtbaseExporter($cmf);
     $exporter->setExtensionKey($input->getArgument('extension-key'));
     $exporter->setPath($path);
     \EdRush\Extbaser\Command\ExportExtbaseCommand::mapDefaultInputOptions($exporter, $input);
     $output->writeln(sprintf('Importing mapping information from "<info>%s</info>" entity manager', $emName));
     $result = $exporter->exportJson();
     foreach ($exporter->getLogs() as $log) {
         $output->writeln($log);
     }
     return $result ? 0 : 1;
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     global $container;
     /** @var string $cacheDir */
     $cacheDir = $container['doctrine.orm.repositoriesCacheDir'];
     $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($cacheDir, \FilesystemIterator::SKIP_DOTS), \RecursiveIteratorIterator::CHILD_FIRST);
     /** @var \SplFileInfo $file */
     foreach ($iterator as $file) {
         if ($file->isDir()) {
             rmdir($file);
         } else {
             unlink($file);
         }
     }
     /** @var EntityManager $entityManager */
     $entityManager = $container['doctrine.orm.entityManager'];
     $classMetadataFactory = new DisconnectedClassMetadataFactory();
     $classMetadataFactory->setEntityManager($entityManager);
     $metadatas = $classMetadataFactory->getAllMetadata();
     if (count($metadatas)) {
         $numRepositories = 0;
         $generator = new EntityRepositoryGenerator();
         foreach ($metadatas as $metadata) {
             if ($metadata->customRepositoryClassName) {
                 $output->write(sprintf('Processing repository "<info>%s</info>"', $metadata->customRepositoryClassName) . PHP_EOL);
                 $generator->writeEntityRepositoryClass($metadata->customRepositoryClassName, $cacheDir);
                 $numRepositories++;
             }
         }
         if ($numRepositories) {
             // Outputting information message
             $output->write(PHP_EOL . sprintf('Repository classes generated to "<info>%s</INFO>"', $cacheDir) . PHP_EOL);
         } else {
             $output->write('No Repository classes were found to be processed.' . PHP_EOL);
         }
     } else {
         $output->write('No Metadata Classes to process.' . PHP_EOL);
     }
 }
示例#21
0
 /**
  *
  */
 public function __construct(EntityManager $em, DisconnectedClassMetadataFactory $cmf)
 {
     $cmf->setEntityManager($em);
     $this->metaDataFactory = $cmf;
     $this->entityManager = $em;
 }
 /**
  * @return array
  */
 private function getAllMetadata()
 {
     $metadata = array();
     foreach ($this->registry->getManagers() as $em) {
         $cmf = new DisconnectedClassMetadataFactory();
         $cmf->setEntityManager($em);
         foreach ($cmf->getAllMetadata() as $m) {
             $metadata[] = $m;
         }
     }
     return $metadata;
 }
示例#23
0
 /**
  * Creates a disconnected meta data factory with a database mapping driver
  * to get the meta data for the extension tables directly from the database.
  *
  * @return Doctrine\ORM\Tools\DisconnectedClassMetadataFactory
  */
 private function getFactoryWithDatabaseDriver() {
     $driver = $this->getDatabaseDriver();
     Shopware()->Models()->getConfiguration()->setMetadataDriverImpl($driver);
     $factory = new DisconnectedClassMetadataFactory();
     $factory->setEntityManager(Shopware()->Models());
     return $factory;
 }
示例#24
0
 protected function getBundleMetadatas(Bundle $bundle)
 {
     $namespace = $bundle->getNamespace();
     $bundleMetadatas = array();
     $entityManagers = $this->getDoctrineEntityManagers();
     foreach ($entityManagers as $key => $em) {
         $cmf = new DisconnectedClassMetadataFactory();
         $cmf->setEntityManager($em);
         $metadatas = $cmf->getAllMetadata();
         foreach ($metadatas as $metadata) {
             if (strpos($metadata->name, $namespace) === 0) {
                 $bundleMetadatas[$metadata->name] = $metadata;
             }
         }
     }
     return $bundleMetadatas;
 }
 /**
  * {@inheritDoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $app = $this->getHelper("app")->getApplication();
     $registry = $app['orm.manager_registry'];
     /* @var $registry ManagerRegistry */
     $emName = $input->getOption("em") ? $input->getOption("em") : "default";
     $em = $registry->getManager($emName);
     //$bundle = $this->getApplication()->getKernel()->getBundle($input->getArgument('bundle'));
     //        $destPath = $bundle->getPath();
     $destPath = $input->getArgument("path");
     $type = $input->getArgument('mapping-type') ? $input->getArgument('mapping-type') : 'xml';
     if ('annotation' === $type) {
         $destPath .= "/" . preg_replace("#\\\\#", "/", $input->getOption("namespace"));
     } else {
         $destPath .= '/Resources/doctrine';
     }
     if ('yaml' === $type) {
         $type = 'yml';
     }
     $cme = new ClassMetadataExporter();
     $exporter = $cme->getExporter($type);
     $exporter->setOverwriteExistingFiles($input->getOption('force'));
     if ('annotation' === $type) {
         $entityGenerator = $this->getEntityGenerator();
         $exporter->setEntityGenerator($entityGenerator);
     }
     //$em = $this->getEntityManager($input->getOption('em'));
     $databaseDriver = new DatabaseDriver($em->getConnection()->getSchemaManager());
     $em->getConfiguration()->setMetadataDriverImpl($databaseDriver);
     //$emName = $input->getOption('em');
     //        $emName = $emName ? $emName : 'default';
     $cmf = new DisconnectedClassMetadataFactory();
     $cmf->setEntityManager($em);
     $metadata = $cmf->getAllMetadata();
     $metadata = MetadataFilter::filter($metadata, $input->getOption('filter'));
     if ($metadata) {
         $output->writeln(sprintf('Importing mapping information from "<info>%s</info>" entity manager', $emName));
         foreach ($metadata as $class) {
             $className = $class->name;
             $class->name = $input->getOption("namespace") . "\\" . $className;
             //$classPath = $class-> /* todo fix it */
             if ('annotation' === $type) {
                 $path = $destPath . '/' . $className . '.php';
             } else {
                 $path = $destPath . '/' . preg_replace('#\\\\#', ".", $class->name) . '.dcm.' . $type;
             }
             $output->writeln(sprintf('  > writing <comment>%s</comment>', $path));
             $code = $exporter->exportClassMetadata($class);
             if (!is_dir($dir = dirname($path))) {
                 mkdir($dir, 0777, true);
             }
             file_put_contents($path, $code);
         }
     } else {
         $output->writeln('Database does not have any mapping information.', 'ERROR');
         $output->writeln('', 'ERROR');
     }
 }
 /**
  * @return array
  */
 protected function getMetadata()
 {
     if (!isset($this->metadata)) {
         $em = $this->getServiceLocator()->get($this->entitymanager);
         $databaseDriver = new DatabaseDriver($em->getConnection()->getSchemaManager());
         $em->getConfiguration()->setMetadataDriverImpl($databaseDriver);
         // Setting the Database for annotation-prefix
         $this->setDatabase($em->getConnection()->getDatabase());
         // Doctrine dosn't support mysql-enums, so we declare them here as a string
         $conn = $em->getConnection();
         $conn->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');
         //@todo more typemappings??
         //$conn->getDatabasePlatform()->registerDoctrineTypeMapping('datetime', 'string');
         //\Doctrine\DBAL\Types\Type::addType('blob', 'Doctrine\DBAL\Types\Blob');
         //$em->getConnection()->getDatabasePlatform()->registerDoctrineTypeMapping('blob', 'string');
         $cmf = new DisconnectedClassMetadataFactory();
         $cmf->setEntityManager($em);
         $this->metadata = $cmf->getAllMetadata();
     }
     return $this->metadata;
 }
示例#27
0
<?php

define('DIR_BASE', realpath(dirname(__FILE__) . '/..'));
define('DIR_CORE', DIR_BASE . '/core');
define('DIR_CACHE', DIR_BASE . '/cache');
define('DIR_PACKAGES', DIR_BASE . '/packages');
define('DIR_URI', '');
require '../core/autoload.php';
require '../vendor/autoload.php';
use Doctrine\ORM\Tools\Setup;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Mapping\Driver\DatabaseDriver;
use Doctrine\ORM\Tools\DisconnectedClassMetadataFactory;
use Doctrine\ORM\Tools\Export\ClassMetadataExporter;
new AutoLoad();
$dbConfig = Config::getInstance()->getValues('db');
$db = array('driver' => 'pdo_mysql', 'host' => $dbConfig->DB_HOST . ':' . $dbConfig->DB_PORT, 'user' => $dbConfig->DB_USER, 'password' => $dbConfig->DB_PASS, 'dbname' => $dbConfig->DB_NAME);
$doctrineConfig = Setup::createAnnotationMetadataConfiguration(array(DIR_CACHE . '/doctrine'), $dbConfig->DB_DEV);
$entityManager = EntityManager::create($db, $doctrineConfig);
$entityManager->getConnection()->connect();
$databaseDriver = new DatabaseDriver($entityManager->getConnection()->getSchemaManager());
$databaseDriver->setNamespace('Models\\');
$entityManager->getConfiguration()->setMetadataDriverImpl($databaseDriver);
$metadataFactory = new DisconnectedClassMetadataFactory();
$metadataFactory->setEntityManager($entityManager);
$metadata = $metadataFactory->getAllMetadata();
$metadataExporter = new ClassMetadataExporter();
$exporter = $metadataExporter->getExporter('xml', DIR_CACHE . '/doctrine');
$exporter->setMetadata($metadata);
$exporter->export();
echo 'Doctrine models successfully generated!';
 public static function generate(OutputInterface $output = null, &$reload = false)
 {
     global $container;
     /** @var string $entitiesCacheDir */
     $entitiesCacheDir = $container['doctrine.orm.entitiesCacheDir'];
     /** @var string $proxiesCacheDir */
     $proxiesCacheDir = $container['doctrine.orm.proxiesCacheDir'];
     /** @var string $repositoriesCacheDir */
     $repositoriesCacheDir = $container['doctrine.orm.repositoriesCacheDir'];
     /** @var LoggerInterface $logger */
     $logger = $container['doctrine.orm.logger'];
     $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($entitiesCacheDir, \FilesystemIterator::SKIP_DOTS), \RecursiveIteratorIterator::CHILD_FIRST);
     /** @var \SplFileInfo $file */
     foreach ($iterator as $file) {
         if ($file->isDir()) {
             rmdir($file);
         } else {
             unlink($file);
         }
     }
     /** @var EntityManager $entityManager */
     $entityManager = $container['doctrine.orm.entityManager'];
     // load "disconnected" metadata (without reflection class) information
     $classMetadataFactory = new DisconnectedClassMetadataFactory();
     $classMetadataFactory->setEntityManager($entityManager);
     $metadatas = $classMetadataFactory->getAllMetadata();
     if (count($metadatas)) {
         $generated = array();
         // Create EntityGenerator
         /** @var EntityGenerator $entityGenerator */
         $entityGenerator = $container['doctrine.orm.entityGeneratorFactory'](true);
         foreach ($metadatas as $metadata) {
             static::generateEntity($metadata, $entitiesCacheDir, $entityGenerator, $output);
             $generated[] = $metadata->name;
         }
         if ($output) {
             $output->write(PHP_EOL . sprintf('Entity classes generated to "<info>%s</info>"', $entitiesCacheDir) . PHP_EOL);
         }
         $logger->info(sprintf('Entity classes generated to "%s"', $entitiesCacheDir));
         // (re)load "connected" metadata information
         $classMetadataFactory = $entityManager->getMetadataFactory();
         try {
             $metadatas = $classMetadataFactory->getAllMetadata();
             $entityManager->getProxyFactory()->generateProxyClasses($metadatas, $proxiesCacheDir);
             if ($output) {
                 $output->write(PHP_EOL . sprintf('Entity proxies generated to "<info>%s</info>"', $proxiesCacheDir) . PHP_EOL);
             }
             $logger->info(sprintf('Entity proxies generated to "%s"', $proxiesCacheDir));
             $repositoryGenerator = new EntityRepositoryGenerator();
             foreach ($metadatas as $metadata) {
                 if ($metadata->customRepositoryClassName) {
                     if ($output) {
                         $output->write(sprintf('Processing repository "<info>%s</info>"', $metadata->customRepositoryClassName) . PHP_EOL);
                     }
                     $repositoryGenerator->writeEntityRepositoryClass($metadata->customRepositoryClassName, $repositoriesCacheDir);
                 }
             }
         } catch (\ReflectionException $e) {
             // silently ignore and reload
             $reload = true;
         }
         if ($output) {
             $output->write(PHP_EOL . sprintf('Entity repositories generated to "<info>%s</info>"', $repositoriesCacheDir) . PHP_EOL);
         }
         $logger->info(sprintf('Entity repositories generated to "%s"', $repositoriesCacheDir));
         return $generated;
     } else {
         return false;
     }
 }
示例#29
0
 public function exportJson()
 {
     $metadata = $this->cmf->getAllMetadata();
     $metadata = MetadataFilter::filter($metadata, $this->filter);
     if ($metadata) {
         $filename = $this->path . '/' . $this->extensionKey . '/' . self::PROJECT_FILE_NAME;
         if (!is_dir($dir = dirname($filename))) {
             mkdir($dir, 0777, true);
         }
         $configuration = new ExtensionBuilderConfiguration();
         if (is_readable($filename)) {
             if ($this->overwriteExistingFiles && $this->roundTripExistingFiles) {
                 $this->logs[] = sprintf('File "<info>%s</info>" already exists, you selected both override (force) and round-trip - please choose one.', $filename);
                 return 1;
             }
             if (!$this->overwriteExistingFiles && !$this->roundTripExistingFiles) {
                 $this->logs[] = sprintf('File "<info>%s</info>" already exists, use --force to override or --round-trip it.', $filename);
                 return 1;
             }
             if ($this->roundTripExistingFiles) {
                 $roundtripContents = json_decode(file_get_contents($filename), true);
                 $configuration->setProperties($this->mapArrayToClass($roundtripContents['properties'], new Properties()));
                 $configuration->setLog($this->mapArrayToClass($roundtripContents['log'], new Log()));
             }
         }
         $configuration->getProperties()->setExtensionKey($this->extensionKey);
         $configuration->getLog()->setLastModified(date('Y-m-d H:i'));
         //in this array we store the target entites for all relations to create wires later on
         $relationTargetsByModuleByRelation = array();
         $moduleIndex = 0;
         $posX = 50;
         $posY = 50;
         foreach ($metadata as $metadata) {
             if ($moduleIndex) {
                 if (0 == $moduleIndex % 5) {
                     $posX = 50;
                     $posY += 200;
                 } else {
                     $posX += 300;
                 }
             }
             $className = $metadata->name;
             //remove namespaces, e.g. when importing entities
             if (class_exists($className)) {
                 $reflection = new \ReflectionClass($className);
                 $className = $reflection->getShortName();
             }
             $this->logs[] = sprintf('Processing table "<info>%s</info>"', $className);
             $module = new Module();
             $module->getValue()->setName($className);
             $module->getConfig()->setPosition(array($posX, $posY));
             $module->getValue()->getObjectsettings()->setUid($this->getRandomUid());
             $module->getValue()->getObjectsettings()->setType(ObjectSettings::OBJECT_TYPE_ENTITY);
             //export properties
             foreach ($metadata->fieldMappings as $fieldMapping) {
                 $property = new Property();
                 $property->setPropertyName($fieldMapping['fieldName']);
                 $property->setPropertyType($this->getPropertyType($fieldMapping['type']));
                 $property->setUid($this->getRandomUid());
                 $module->getValue()->getPropertyGroup()->addProperty($property);
             }
             //export relations
             $relationIndex = 0;
             foreach ($metadata->associationMappings as $associationMapping) {
                 $relationNameSingular = $associationMapping['fieldName'];
                 $relationNamePlural = Inflector::pluralize(Inflector::singularize($associationMapping['fieldName']));
                 $relation = new Relation();
                 $relationType = null;
                 $relationName = '';
                 switch ($associationMapping['type']) {
                     case ClassMetadataInfo::ONE_TO_MANY:
                         $relationType = Relation::ONE_TO_MANY;
                         $relationName = $relationNamePlural;
                         break;
                     case ClassMetadataInfo::MANY_TO_ONE:
                         $relationType = Relation::MANY_TO_ONE;
                         $relationName = $relationNameSingular;
                         break;
                     case ClassMetadataInfo::ONE_TO_ONE:
                         $relationType = Relation::ONE_TO_ONE;
                         $relationName = $relationNameSingular;
                         break;
                     case ClassMetadataInfo::MANY_TO_MANY:
                         $relationType = Relation::MANY_TO_MANY;
                         $relationName = $relationNamePlural;
                         break;
                 }
                 $relation->setRelationName($relationName);
                 $relation->setRelationType($relationType);
                 $relationName = $relationNameSingular;
                 $module->getValue()->getRelationGroup()->addRelation($relation);
                 $targetClassName = $associationMapping['targetEntity'];
                 //remove namespaces, e.g. when importing entities
                 if (class_exists($targetClassName)) {
                     $reflection = new \ReflectionClass($targetClassName);
                     $targetClassName = $reflection->getShortName();
                 }
                 $relationTargetsByModuleByRelation[$moduleIndex][$relationIndex] = $targetClassName;
                 $relationIndex++;
                 $this->logs[] = sprintf('Added relation "<comment>%s</comment>": "<info>%s</info>" -> "<info>%s</info>"', $relationName, $className, $targetClassName);
             }
             $configuration->addModule($module);
             $moduleIndex++;
         }
         // now we have all the modules, we can create wires
         $moduleIndex = 0;
         foreach ($configuration->getModules() as $key => $module) {
             $relationIndex = 0;
             if (!empty($module->getValue()->getRelationGroup()->getRelations())) {
                 foreach ($module->getValue()->getRelationGroup()->getRelations() as $relation) {
                     /* @var $relation Relation */
                     // now add the corresponding wire for the relation
                     $wire = new Wire();
                     $targetEntity = $relationTargetsByModuleByRelation[$moduleIndex][$relationIndex];
                     $targetModule = $configuration->getModuleByName($targetEntity);
                     if ($targetModule) {
                         $targetModuleId = array_search($targetModule, $configuration->getModules());
                         $src = new Node();
                         $src->setModuleId($key);
                         $src->setTerminal(Node::TERMINAL_SRC . $relationIndex);
                         $src->setUid($relation->getUid());
                         $tgt = new Node();
                         $tgt->setModuleId($targetModuleId);
                         $tgt->setTerminal(Node::TERMINAL_TGT);
                         $tgt->setUid($targetModule->getValue()->getObjectsettings()->getUid());
                         $wire->setSrc($src);
                         $wire->setTgt($tgt);
                         $configuration->addWire($wire);
                         $this->logs[] = sprintf('Added wire "<comment>%s</comment>": "<info>%s</info>" -> "<info>%s</info>"', $relation->getRelationName(), $module->getValue()->getName(), $targetEntity);
                     }
                     $relationIndex++;
                 }
             }
             $moduleIndex++;
         }
         file_put_contents($filename, json_encode($configuration, JSON_PRETTY_PRINT));
         $this->logs[] = 'Exported database schema to ' . $filename;
         return true;
     } else {
         $this->logs[] = 'Database does not have any mapping information.';
         return false;
     }
 }
示例#30
0
 /**
  * Entidades::entityManager()
  * 
  * Prepara el proceso de la creacion de las entidades
  * @param object $configuracion
  * @return object
  */
 private function entityManager($configuracion = false)
 {
     $entidad = EntityManager::create($this->confg, $configuracion);
     $entidad->getConnection()->getDatabasePlatform()->registerDoctrineTypeMapping('set', 'string');
     $entidad->getConnection()->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');
     // fetch metadata
     $driver = new DatabaseDriver($entidad->getConnection()->getSchemaManager());
     $driver->setNamespace('Entidades\\' . $this->conexion . '\\');
     //Agrega el namespace Entidad\Nombre de la tabla
     $entidad->getConfiguration()->setMetadataDriverImpl($driver);
     $cmf = new DisconnectedClassMetadataFactory();
     $cmf->setEntityManager($entidad);
     // we must set the EntityManager
     $classes = $driver->getAllClassNames();
     $metadata = array();
     foreach ($classes as $class) {
         //any unsupported table/schema could be handled here to exclude some classes
         if (true) {
             $metadata[] = $cmf->getMetadataFor($class);
         }
     }
     $this->generador($metadata);
 }