Esempio n. 1
0
 /**
  * Check if proxy classes are already generated
  *
  * @return boolean
  */
 protected function areProxiesExist()
 {
     return \Includes\Utils\FileManager::isDirReadable(\Includes\Decorator\ADecorator::getCacheModelProxiesDir());
 }
Esempio n. 2
0
 /**
  * Register the autoload function for the Doctrine library
  *
  * @return void
  */
 protected static function registerDoctrineAutoloader()
 {
     static::registerCustom('Doctrine');
     static::registerCustom('Symfony');
     static::registerCustom('Rah');
     // Proxy classes autoloader
     \Doctrine\ORM\Proxy\Autoloader::register(rtrim(\Includes\Decorator\ADecorator::getCacheModelProxiesDir(), LC_DS), LC_MODEL_PROXY_NS);
 }
Esempio n. 3
0
 /**
  * Return the Doctrine config object
  *
  * @return \Doctrine\ORM\Configuration
  */
 protected static function getConfig()
 {
     $config = new \Doctrine\ORM\Configuration();
     $config->setAutoGenerateProxyClasses(false);
     static::setMetadataDriver($config);
     // Set proxy settings
     $config->setProxyDir(rtrim(\Includes\Decorator\ADecorator::getCacheModelProxiesDir(), LC_DS));
     $config->setProxyNamespace(LC_MODEL_PROXY_NS);
     $cache = new \Doctrine\Common\Cache\ArrayCache();
     $config->setMetadataCacheImpl($cache);
     $config->setQueryCacheImpl($cache);
     return $config;
 }
Esempio n. 4
0
 /**
  * Connect and set-up Doctrine
  *
  * @return void
  */
 public function connect()
 {
     $this->configuration = new \Doctrine\ORM\Configuration();
     // Setup cache
     $this->setDoctrineCache();
     // Set metadata driver
     $chain = new \Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain();
     $chain->addDriver($this->createAnnotationDriver(\Includes\Decorator\ADecorator::getCacheModelsDir()), 'XLite\\Model');
     $iterator = new \RecursiveDirectoryIterator(\Includes\Decorator\ADecorator::getCacheClassesDir() . 'XLite' . LC_DS . 'Module', \FilesystemIterator::SKIP_DOTS);
     foreach ($iterator as $dir) {
         if (\Includes\Utils\FileManager::isDir($dir->getPathName())) {
             $iterator2 = new \RecursiveDirectoryIterator($dir->getPathName(), \FilesystemIterator::SKIP_DOTS);
             foreach ($iterator2 as $dir2) {
                 if (\Includes\Utils\FileManager::isDir($dir2->getPathName()) && \Includes\Utils\FileManager::isDir($dir2->getPathName() . LC_DS . 'Model')) {
                     $chain->addDriver($this->createAnnotationDriver($dir2->getPathName() . LC_DS . 'Model'), 'XLite\\Module\\' . $dir->getBaseName() . '\\' . $dir2->getBaseName() . '\\Model');
                 }
             }
         }
     }
     $this->configuration->setMetadataDriverImpl($chain);
     // Set proxy settings
     $this->configuration->setProxyDir(rtrim(\Includes\Decorator\ADecorator::getCacheModelProxiesDir(), LC_DS));
     $this->configuration->setProxyNamespace(LC_MODEL_PROXY_NS);
     $this->configuration->setAutoGenerateProxyClasses(false);
     // Register custom functions
     $this->configuration->addCustomStringFunction('if', '\\XLite\\Core\\Doctrine\\IfFunction');
     $this->configuration->addCustomStringFunction('IFNULL', '\\XLite\\Core\\Doctrine\\IfnullFunction');
     $this->configuration->addCustomStringFunction('relevance', '\\XLite\\Core\\Doctrine\\RelevanceFunction');
     $this->configuration->addCustomNumericFunction('intval', '\\XLite\\Core\\Doctrine\\IntvalFunction');
     $this->configuration->addCustomStringFunction('findInSet', '\\XLite\\Core\\Doctrine\\FindInSetFunction');
     $this->configuration->addCustomStringFunction('castChar', '\\XLite\\Core\\Doctrine\\CastCharFunction');
     $this->configuration->addCustomStringFunction('collate', '\\XLite\\Core\\Doctrine\\CollateFunction');
     $this->tablePrefix = trim(\XLite::getInstance()->getOptions(array('database_details', 'table_prefix')));
     // Initialize DB connection and entity manager
     $this->startEntityManager();
 }