예제 #1
0
 public function __construct()
 {
     $this->settings = Registry::get('settings');
     $this->siteTitle = $this->settings->site->title;
 }
예제 #2
0
 /**
  * Setup the application to work with doctrine
  * 
  * @return void
  */
 public static function setupDoctrine($settings)
 {
     // Doctrine specific settings
     if (isset($settings->doctrine) && $settings->doctrine->enabled == 1) {
         // Setup all variables here, with checks to see whether there
         // are overrides set in the settings file
         $devMode = $settings->environment == "development" || $settings->environment == "dev" ? true : false;
         $paths = $settings->doctrine->entityPaths;
         $proxyDir = isset($settings->doctrine->proxyDir) ? $settings->doctrine->proxyDir : 'data';
         // Now to the actual DB parameters for the connection
         $dbParams = array('driver' => $settings->doctrine->driver, 'host' => $settings->doctrine->host, 'user' => $settings->doctrine->user, 'password' => $settings->doctrine->password, 'dbname' => $settings->doctrine->dbname);
         // Now setup Doctrine
         $doctrine = \Doctrine\ORM\Tools\Setup::createAnnotationMetadataConfiguration($paths, $devMode);
         $doctrine->setProxyDir($proxyDir);
         if ($devMode) {
             // Development should use a simple Array cache
             $doctrine->setQueryCacheImpl(new \Doctrine\Common\Cache\ArrayCache());
         } else {
             // Production should use APC Cache
             //$doctrine->setQueryCacheImpl(new \Doctrine\Common\Cache\ApcCache());
         }
         $entityManager = \Doctrine\ORM\EntityManager::create($dbParams, $doctrine);
         Registry::set('em', $entityManager);
     }
 }