Exemplo n.º 1
0
 /**
  * a partir de la base de datos, nos genera las entidades
  */
 public function importarEntidadesDeBD()
 {
     //obtenemos las instancias de los metadatos
     $this->em->getConfiguration()->setMetadataDriverImpl(new \Doctrine\ORM\Mapping\Driver\DatabaseDriver($this->em->getConnection()->getSchemaManager()));
     $cmf = new Doctrine\ORM\Tools\DisconnectedClassMetadataFactory();
     $cmf->setEntityManager($this->em);
     $metadata = $cmf->getAllMetadata();
     //exporta a un formato dado como xml,yml o php, entity (no entidades) a la carpeta destino
     $cme = new \Doctrine\ORM\Tools\Export\ClassMetadataExporter();
     $exporter = $cme->getExporter('xml', APPPATH . 'models/php');
     $exporter->setMetadata($metadata);
     $exporter->export();
 }
Exemplo n.º 2
0
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * This software consists of voluntary contributions made by many individuals
 * and is licensed under the LGPL. For more information, see
 * <http://www.doctrine-project.org>.
 */
require_once '../config.php';
//$tool = new \Doctrine\ORM\Tools\SchemaTool($em);
//$classes = array(
//  $em->getClassMetadata('Entities\Pessoa'),
//  $em->getClassMetadata('Entities\Departamento')
//);
//$tool->updateSchema($classes);
$em->getConfiguration()->setMetadataDriverImpl(new \Doctrine\ORM\Mapping\Driver\DatabaseDriver($em->getConnection()->getSchemaManager()));
$cmf = new Doctrine\ORM\Tools\DisconnectedClassMetadataFactory();
$cmf->setEntityManager($em);
$metadata = $cmf->getAllMetadata();
$eg = new \Doctrine\ORM\Tools\EntityGenerator();
$eg->setGenerateStubMethods(true);
$cme = new \Doctrine\ORM\Tools\Export\ClassMetadataExporter();
$exporter = $cme->getExporter('annotation', '../Entities');
$exporter->setMetadata($metadata);
$exporter->setEntityGenerator($eg);
$exporter->export();
Exemplo n.º 3
0
     //$generator = new \Doctrine\ORM\Tools\EntityGenerator();
     //$generator->generate($classes, 'E:\Ely\projects\sites\ddd\expressive\src\FNBr\Domain\Model\\');//OutputDir
     $metadata = getEntitiesMetaData($em);
     generateEntities('E:\\Ely\\projects\\sites\\ddd\\expressive\\src\\', $metadata);
 } else {
     if ($operation == "import") {
         //Generate Map from database
         $config = $container->get('config');
         $classesToImport = $models = $config['models'];
         $namespace = $config['namespace'] . "\\Domain\\Model\\";
         $em->getConfiguration()->setMetadataDriverImpl(new \Doctrine\ORM\Mapping\Driver\DatabaseDriver($em->getConnection()->getSchemaManager()));
         $cmf = new \Doctrine\ORM\Tools\DisconnectedClassMetadataFactory();
         $cmf->setEntityManager($em);
         $metadata = $cmf->getAllMetadata();
         $metadata = processMetadata($metadata, $models, $namespace, $config['namespace']);
         $cme = new \Doctrine\ORM\Tools\Export\ClassMetadataExporter();
         $exporter = $cme->getExporter('yml', 'E:\\temp\\ORM');
         //Extension & OutputDir
         $exporter->setMetadata($metadata);
         $exporter->export();
         $prefix = $config['namespace'] . ".Domain.Model.";
         foreach ($classesToImport as $modelName) {
             $fileTemp = 'E:\\temp\\ORM' . '\\' . $prefix . $modelName . "." . $modelName . ".dcm.yml";
             if (is_file($fileTemp)) {
                 $dirORM = 'E:\\Ely\\projects\\sites\\ddd\\expressive\\src\\FNBr\\Infrastructure\\Persistence\\Doctrine\\ORM\\' . $modelName;
                 mkdir($dirORM);
                 $fileORM = $dirORM . "\\" . $modelName . ".orm.yml";
                 copy($fileTemp, $fileORM);
             }
         }
     } else {