Ejemplo n.º 1
0
 /**
  * Creates an OrmController
  * @return OrmController	an OrmController instance
  */
 public static function create()
 {
     //check, if an instance of OrmController already exists
     if (OrmController::$ormController == null) {
         OrmController::$ormController = new OrmController();
     }
     //return instance
     return OrmController::$ormController;
 }
Ejemplo n.º 2
0
 /**
  * private constructor
  */
 private function __construct()
 {
     $ormController = OrmController::create();
     $this->entityManager = $ormController->getEntityManager();
 }
Ejemplo n.º 3
0
<?php

use Doctrine\ORM\Tools\Console\ConsoleRunner;
use yourCMDB\orm\OrmController;
$scriptBaseDir = dirname(__FILE__);
$coreBaseDir = realpath("{$scriptBaseDir}/../../../../../");
require_once "{$coreBaseDir}/bootstrap.php";
$ormController = OrmController::create();
$entityManager = $ormController->getEntityManager();
return ConsoleRunner::createHelperSet($entityManager);
Ejemplo n.º 4
0
 /**
  * tries to repair the schema in the configured datastore
  */
 public function repairSchema()
 {
     //get instances
     $ormController = OrmController::create();
     $entityManager = $ormController->getEntityManager();
     $schemaTool = new SchemaTool($entityManager);
     $classes = $entityManager->getMetadataFactory()->getAllMetadata();
     //create schema
     $schemaTool->updateSchema($classes);
     //set version for doctrine migrations
     $migrationConfig = $this->getMigrationsConfiguration();
     $migrationVersions = $migrationConfig->getAvailableVersions();
     foreach ($migrationVersions as $migrationVersionString) {
         $migrationVersion = $migrationConfig->getVersion($migrationVersionString);
         $migrationVersion->markMigrated();
     }
 }