<?php
namespace gnomephp\doctrine;
/**
*
* Doctrine specific class, use this to interact with Doctrine.
* Uses database.yml in config folder.
* @author peec
*
*/
class Doctrine extends DoctrineConnection{
/**
* Doctrine entity manager.
* Publically available.
* @var Doctrine\ORM\EntityManager
*/
static public $em = null;
/**
* Do not load entity manager several times on single page.
*
* @var boolean
*/
static private $loaded=false;
static protected function getConfigSet(){
if (\gnomephp\Configuration::get('application', 'debug_mode') == true){
$gnomeConfigSet = \gnomephp\Configuration::get('database', 'development');
}else{
$gnomeConfigSet = \gnomephp\Configuration::get('database', 'production');
}
return $gnomeConfigSet;
}
static public function load(){
parent::load();
if (!self::$loaded){
self::$em = self::getNewEntityManager(self::getConfigSet());
self::$loaded = true;
}
}
/**
* @return Doctrine\ORM\EntityManager The entity manager of Doctrine.
*/
static public function getEM(){
return self::$em;
}
}