示例#1
0
 protected function _initDoctrine()
 {
     require_once LIBRARY_PATH . '/Doctrine/Common/ClassLoader.php';
     $autoloader = \Zend_Loader_Autoloader::getInstance();
     $fmmAutoloader = new \Doctrine\Common\ClassLoader();
     $autoloader->pushAutoloader(array($fmmAutoloader, 'loadClass'));
     $options = $this->getOptions();
     $config = new Doctrine\ORM\Configuration();
     $config->addCustomDatetimeFunction('YEAR', 'Doctrine\\Extensions\\Query\\Mysql\\Year');
     $config->addCustomDatetimeFunction('MONTH', 'Doctrine\\Extensions\\Query\\Mysql\\Month');
     $config->addCustomDatetimeFunction('DAY', 'Doctrine\\Extensions\\Query\\Mysql\\Day');
     $config->addCustomStringFunction('DATEDIFF', 'Doctrine\\Extensions\\Query\\Mysql\\DateDiff');
     $config->addCustomStringFunction('DATE_FORMAT', 'Doctrine\\Extensions\\Query\\Mysql\\DateFormat');
     $config->addCustomStringFunction('IF', 'Doctrine\\Extensions\\Query\\Mysql\\IfElse');
     $config->addCustomStringFunction('GROUP_CONCAT', 'Doctrine\\Extensions\\Query\\Mysql\\GroupConcat');
     $config->addCustomStringFunction('IFNULL', 'Doctrine\\Extensions\\Query\\Mysql\\IfNull');
     $config->setProxyDir($options['doctrine']['metadata']['proxyDir']);
     $config->setProxyNamespace('Doctrine\\Proxy');
     $config->setAutoGenerateProxyClasses(true);
     $config->setAutoGenerateProxyClasses(APPLICATION_ENV == 'development');
     //$driverImpl = $config->newDefaultAnnotationDriver($options['metadata']['entityDir']);
     $driverImpl = new Doctrine\ORM\Mapping\Driver\YamlDriver($options['doctrine']['metadata']['entityDir']);
     $config->setMetadataDriverImpl($driverImpl);
     $cache = new Doctrine\Common\Cache\ArrayCache();
     $config->setMetadataCacheImpl($cache);
     $config->setQueryCacheImpl($cache);
     $evm = new Doctrine\Common\EventManager();
     $em = Doctrine\ORM\EntityManager::create($options['doctrine']['db'], $config, $evm);
     Zend_Registry::set('doctrine', $em);
     return $em;
 }
 public function setUp()
 {
     $config = new \Doctrine\ORM\Configuration();
     $config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache());
     $config->setQueryCacheImpl(new \Doctrine\Common\Cache\ArrayCache());
     $config->setProxyDir($GLOBALS['doctrine2-proxies-path']);
     $config->setProxyNamespace($GLOBALS['doctrine2-proxies-namespace']);
     $config->setAutoGenerateProxyClasses(true);
     $driver = $config->newDefaultAnnotationDriver($GLOBALS['doctrine2-entities-path']);
     $config->setMetadataDriverImpl($driver);
     $conn = array('driver' => 'pdo_sqlite', 'memory' => true);
     $config->addCustomNumericFunction('DATEDIFF', 'DoctrineExtensions\\Query\\Mysql\\DateDiff');
     $config->addCustomDatetimeFunction('DATE_ADD', 'DoctrineExtensions\\Query\\Mysql\\DateAdd');
     $config->addCustomStringFunction('STR_TO_DATE', 'DoctrineExtensions\\Query\\MySql\\StrToDate');
     $config->addCustomStringFunction('FIND_IN_SET', 'DoctrineExtensions\\Query\\MySql\\FindInSet');
     $this->entityManager = \Doctrine\ORM\EntityManager::create($conn, $config);
 }
示例#3
0
 protected static function getEntityManager($options)
 {
     $config = new \Doctrine\ORM\Configuration();
     // Handling for class names specified as platform types.
     if ($options['conn']['platform']) {
         $class_obj = new \ReflectionClass($options['conn']['platform']);
         $options['conn']['platform'] = $class_obj->newInstance();
     }
     // Special handling for the utf8mb4 type.
     if ($options['conn']['driver'] == 'pdo_mysql' && $options['conn']['charset'] == 'utf8mb4') {
         $options['conn']['platform'] = new \FA\Doctrine\Platform\MysqlUnicode();
     }
     $metadata_driver = $config->newDefaultAnnotationDriver($options['modelPath']);
     $config->setMetadataDriverImpl($metadata_driver);
     $cache = new \FA\Doctrine\Cache();
     // $cache->setNamespace('doctrine_');
     $config->setMetadataCacheImpl($cache);
     $config->setQueryCacheImpl($cache);
     $config->setResultCacheImpl($cache);
     $config->setProxyDir($options['proxyPath']);
     $config->setProxyNamespace($options['proxyNamespace']);
     if (isset($options['conn']['debug']) && $options['conn']['debug']) {
         $config->setSQLLogger(new \FA\Doctrine\Logger\EchoSQL());
     }
     $config->addFilter('softdelete', '\\FA\\Doctrine\\Filter\\SoftDelete');
     $config->addCustomNumericFunction('RAND', '\\FA\\Doctrine\\Functions\\Rand');
     $config->addCustomStringFunction('FIELD', 'DoctrineExtensions\\Query\\Mysql\\Field');
     $config->addCustomStringFunction('IF', 'DoctrineExtensions\\Query\\Mysql\\IfElse');
     $evm = new \Doctrine\Common\EventManager();
     $em = \Doctrine\ORM\EntityManager::create($options['conn'], $config, $evm);
     $em->getFilters()->enable("softdelete");
     // Workaround to allow ENUM types to exist as strings in Doctrine.
     $platform = $em->getconnection()->getDatabasePlatform();
     $platform->registerDoctrineTypeMapping('enum', 'string');
     // Try the connection before rendering the page.
     $em->getConnection()->connect();
     return $em;
 }
 /**
  * Initialize ORM Configuration.
  *
  * @param array $config ORM EntityManager configuration.
  *
  * @return Doctrine\ORM\Configuration
  */
 private function startORMConfiguration(array $config = array())
 {
     $configClass = $config['configurationClass'];
     $configuration = new $configClass();
     $configuration = new \Doctrine\ORM\Configuration();
     // Entity Namespaces configuration
     foreach ($config['entityNamespaces'] as $alias => $namespace) {
         $configuration->addEntityNamespace($alias, $namespace);
     }
     // Proxy configuration
     $configuration->setAutoGenerateProxyClasses(!in_array($config['proxy']['autoGenerateClasses'], array("0", "false", false)));
     $configuration->setProxyNamespace($config['proxy']['namespace']);
     $configuration->setProxyDir($config['proxy']['dir']);
     // Cache configuration
     $configuration->setMetadataCacheImpl($this->getCacheInstance($config['metadataCache']));
     $configuration->setResultCacheImpl($this->getCacheInstance($config['resultCache']));
     $configuration->setQueryCacheImpl($this->getCacheInstance($config['queryCache']));
     // Metadata configuration
     $configuration->setMetadataDriverImpl($this->startORMMetadata($config['metadataDrivers']));
     // DQL Functions configuration
     $dqlFunctions = $config['DQLFunctions'];
     foreach ($dqlFunctions['datetime'] as $name => $className) {
         $configuration->addCustomDatetimeFunction($name, $className);
     }
     foreach ($dqlFunctions['numeric'] as $name => $className) {
         $configuration->addCustomNumericFunction($name, $className);
     }
     foreach ($dqlFunctions['string'] as $name => $className) {
         $configuration->addCustomStringFunction($name, $className);
     }
     return $configuration;
 }
示例#5
0
文件: Database.php 项目: fraym/core
 /**
  * @return $this
  */
 public function connect()
 {
     // Prevent to connect twice
     if ($this->entityManager) {
         return $this;
     }
     $applicationDir = $this->core->getApplicationDir();
     $this->createModuleDirCache();
     $cache = $this->cache->getCacheProvider();
     $config = new \Doctrine\ORM\Configuration();
     $config->setMetadataCacheImpl($cache);
     $config->addCustomStringFunction('MD5', '\\DoctrineExtensions\\Query\\Mysql\\Md5');
     $config->addCustomStringFunction('ACOS', '\\DoctrineExtensions\\Query\\Mysql\\Acos');
     $config->addCustomStringFunction('ASIN', '\\DoctrineExtensions\\Query\\Mysql\\Asin');
     $config->addCustomStringFunction('ATAN', '\\DoctrineExtensions\\Query\\Mysql\\Atan');
     $config->addCustomStringFunction('ATAN2', '\\DoctrineExtensions\\Query\\Mysql\\Atan2');
     $config->addCustomStringFunction('BINARY', '\\DoctrineExtensions\\Query\\Mysql\\Binary');
     $config->addCustomStringFunction('CHARLENGTH', '\\DoctrineExtensions\\Query\\Mysql\\CharLength');
     $config->addCustomStringFunction('CONCATWS', '\\DoctrineExtensions\\Query\\Mysql\\ConcatWs');
     $config->addCustomStringFunction('COS', '\\DoctrineExtensions\\Query\\Mysql\\Cos');
     $config->addCustomStringFunction('COT', '\\DoctrineExtensions\\Query\\Mysql\\COT');
     $config->addCustomStringFunction('COUNTIF', '\\DoctrineExtensions\\Query\\Mysql\\CountIf');
     $config->addCustomStringFunction('CRC32', '\\DoctrineExtensions\\Query\\Mysql\\Crc32');
     $config->addCustomStringFunction('DATE', '\\DoctrineExtensions\\Query\\Mysql\\Date');
     $config->addCustomStringFunction('DATEADD', '\\DoctrineExtensions\\Query\\Mysql\\DateAdd');
     $config->addCustomStringFunction('DATEDIFF', '\\DoctrineExtensions\\Query\\Mysql\\DateFormat');
     $config->addCustomStringFunction('DAY', '\\DoctrineExtensions\\Query\\Mysql\\Day');
     $config->addCustomStringFunction('DEGREES', '\\DoctrineExtensions\\Query\\Mysql\\Degrees');
     $config->addCustomStringFunction('FIELD', '\\DoctrineExtensions\\Query\\Mysql\\Field');
     $config->addCustomStringFunction('FINDINSET', '\\DoctrineExtensions\\Query\\Mysql\\FindInSet');
     $config->addCustomStringFunction('GROUPCONCAT', '\\DoctrineExtensions\\Query\\Mysql\\GroupConcat');
     $config->addCustomStringFunction('HOUR', '\\DoctrineExtensions\\Query\\Mysql\\Hour');
     $config->addCustomStringFunction('IFELSE', '\\DoctrineExtensions\\Query\\Mysql\\IfElse');
     $config->addCustomStringFunction('IFNULL', '\\DoctrineExtensions\\Query\\Mysql\\IfNUll');
     $config->addCustomStringFunction('MATCHAGAINST', '\\DoctrineExtensions\\Query\\Mysql\\MatchAgainst');
     $config->addCustomStringFunction('MONTH', '\\DoctrineExtensions\\Query\\Mysql\\Month');
     $config->addCustomStringFunction('NULLIF', '\\DoctrineExtensions\\Query\\Mysql\\NullIf');
     $config->addCustomStringFunction('PI', '\\DoctrineExtensions\\Query\\Mysql\\Pi');
     $config->addCustomStringFunction('RADIANS', '\\DoctrineExtensions\\Query\\Mysql\\Radians');
     $config->addCustomStringFunction('RAND', '\\DoctrineExtensions\\Query\\Mysql\\Rand');
     $config->addCustomStringFunction('REGEXP', '\\DoctrineExtensions\\Query\\Mysql\\Regexp');
     $config->addCustomStringFunction('ROUND', '\\DoctrineExtensions\\Query\\Mysql\\Round');
     $config->addCustomStringFunction('SHA1', '\\DoctrineExtensions\\Query\\Mysql\\Sha1');
     $config->addCustomStringFunction('SHA2', '\\DoctrineExtensions\\Query\\Mysql\\Sha2');
     $config->addCustomStringFunction('SIN', '\\DoctrineExtensions\\Query\\Mysql\\Sin');
     $config->addCustomStringFunction('STRTODATE', '\\DoctrineExtensions\\Query\\Mysql\\StrToDate');
     $config->addCustomStringFunction('TAN', '\\DoctrineExtensions\\Query\\Mysql\\Tan');
     $config->addCustomStringFunction('TIMESTAMPDIFF', '\\DoctrineExtensions\\Query\\Mysql\\TimestampDiff');
     $config->addCustomStringFunction('WEEK', '\\DoctrineExtensions\\Query\\Mysql\\Week');
     $config->addCustomStringFunction('YEAR', '\\DoctrineExtensions\\Query\\Mysql\\Year');
     if (!defined('ENV') || ENV === \Fraym\Core::ENV_DEVELOPMENT) {
         $config->setAutoGenerateProxyClasses(true);
     }
     $modelDirs = $this->getModuleDirCache();
     \Doctrine\Common\Annotations\AnnotationRegistry::registerLoader(function ($class) {
         return class_exists($class, true);
     });
     $annotationReader = new \Doctrine\Common\Annotations\AnnotationReader();
     $this->cachedAnnotationReader = new \Doctrine\Common\Annotations\CachedReader($annotationReader, $cache);
     $this->annotationDriver = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($this->cachedAnnotationReader, $modelDirs);
     /**
      * Ignore PHP-DI Annotation
      */
     $annotationReader->addGlobalIgnoredName('Injectable');
     $annotationReader->addGlobalIgnoredName('Inject');
     $config->setMetadataDriverImpl($this->annotationDriver);
     $config->setQueryCacheImpl($cache);
     $config->setResultCacheImpl($cache);
     $config->setProxyDir($applicationDir . DIRECTORY_SEPARATOR . CACHE_DOCTRINE_PROXY_PATH);
     $config->setProxyNamespace('Proxies');
     $this->fetchMode = \PDO::FETCH_OBJ;
     $tablePrefix = new TablePrefix(DB_TABLE_PREFIX);
     $this->eventManager = new \Doctrine\Common\EventManager();
     $this->eventManager->addEventListener(\Doctrine\ORM\Events::loadClassMetadata, $tablePrefix);
     $this->entityManager = \Doctrine\ORM\EntityManager::create($this->connectionOptions, $config, $this->eventManager);
     $this->pdo = $this->entityManager->getConnection();
     $this->pdo->getDatabasePlatform()->registerDoctrineTypeMapping('set', 'string');
     $driverChain = new \Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain();
     \Gedmo\DoctrineExtensions::registerAbstractMappingIntoDriverChainORM($driverChain, $this->cachedAnnotationReader);
     $this->eventManager->addEventListener([\Doctrine\ORM\Events::preRemove, \Doctrine\ORM\Events::postRemove, \Doctrine\ORM\Events::prePersist, \Doctrine\ORM\Events::postPersist, \Doctrine\ORM\Events::preUpdate, \Doctrine\ORM\Events::postUpdate, \Doctrine\ORM\Events::postLoad, \Doctrine\ORM\Events::onFlush], $this->eventListener);
     return $this;
 }
示例#6
0
 /**
  * Gets the 'doctrine.orm.default_entity_manager' service.
  *
  * This service is shared.
  * This method always returns the same instance of the service.
  *
  * @param bool    $lazyLoad whether to try lazy-loading the service with a proxy
  *
  * @return \Doctrine\ORM\EntityManager A Doctrine\ORM\EntityManager instance
  */
 protected function getDoctrine_Orm_DefaultEntityManagerService($lazyLoad = true)
 {
     $a = $this->get('annotation_reader');
     $b = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($a, array(0 => $this->targetDirs[3] . '/vendor/gedmo/doctrine-extensions/lib/Gedmo/Translatable/Entity', 1 => $this->targetDirs[3] . '/vendor/gedmo/doctrine-extensions/lib/Gedmo/Translator/Entity', 2 => $this->targetDirs[3] . '/vendor/gedmo/doctrine-extensions/lib/Gedmo/Loggable/Entity', 3 => $this->targetDirs[3] . '/vendor/gedmo/doctrine-extensions/lib/Gedmo/Tree/Entity', 4 => $this->targetDirs[3] . '/vendor/7rin0/bigfoot-core-bundle/Bigfoot/Bundle/CoreBundle/Entity', 5 => $this->targetDirs[3] . '/vendor/7rin0/bigfoot-context-bundle/Bigfoot/Bundle/ContextBundle/Entity', 6 => $this->targetDirs[3] . '/vendor/7rin0/bigfoot-navigation-bundle/Bigfoot/Bundle/NavigationBundle/Entity', 7 => $this->targetDirs[3] . '/vendor/7rin0/bigfoot-user-bundle/Bigfoot/Bundle/UserBundle/Entity', 8 => $this->targetDirs[3] . '/vendor/7rin0/bigfoot-content-bundle/Bigfoot/Bundle/ContentBundle/Entity', 9 => $this->targetDirs[3] . '/vendor/7rin0/bigfoot-media-bundle/Bigfoot/Bundle/MediaBundle/Entity'));
     $c = new \Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain();
     $c->addDriver($b, 'Gedmo\\Translatable\\Entity');
     $c->addDriver($b, 'Gedmo\\Translator\\Entity');
     $c->addDriver($b, 'Gedmo\\Loggable\\Entity');
     $c->addDriver($b, 'Gedmo\\Tree\\Entity');
     $c->addDriver($b, 'Bigfoot\\Bundle\\CoreBundle\\Entity');
     $c->addDriver($b, 'Bigfoot\\Bundle\\ContextBundle\\Entity');
     $c->addDriver($b, 'Bigfoot\\Bundle\\NavigationBundle\\Entity');
     $c->addDriver($b, 'Bigfoot\\Bundle\\UserBundle\\Entity');
     $c->addDriver($b, 'Bigfoot\\Bundle\\ContentBundle\\Entity');
     $c->addDriver($b, 'Bigfoot\\Bundle\\MediaBundle\\Entity');
     $d = new \Doctrine\ORM\Configuration();
     $d->setEntityNamespaces(array('GedmoTranslatable' => 'Gedmo\\Translatable\\Entity', 'GedmoTranslator' => 'Gedmo\\Translator\\Entity', 'GedmoLoggable' => 'Gedmo\\Loggable\\Entity', 'GedmoTree' => 'Gedmo\\Tree\\Entity', 'BigfootCoreBundle' => 'Bigfoot\\Bundle\\CoreBundle\\Entity', 'BigfootContextBundle' => 'Bigfoot\\Bundle\\ContextBundle\\Entity', 'BigfootNavigationBundle' => 'Bigfoot\\Bundle\\NavigationBundle\\Entity', 'BigfootUserBundle' => 'Bigfoot\\Bundle\\UserBundle\\Entity', 'BigfootContentBundle' => 'Bigfoot\\Bundle\\ContentBundle\\Entity', 'BigfootMediaBundle' => 'Bigfoot\\Bundle\\MediaBundle\\Entity'));
     $d->setMetadataCacheImpl($this->get('doctrine_cache.providers.doctrine.orm.default_metadata_cache'));
     $d->setQueryCacheImpl($this->get('doctrine_cache.providers.doctrine.orm.default_query_cache'));
     $d->setResultCacheImpl($this->get('doctrine_cache.providers.doctrine.orm.default_result_cache'));
     $d->setMetadataDriverImpl($c);
     $d->setProxyDir(__DIR__ . '/doctrine/orm/Proxies');
     $d->setProxyNamespace('Proxies');
     $d->setAutoGenerateProxyClasses(true);
     $d->setClassMetadataFactoryName('Doctrine\\ORM\\Mapping\\ClassMetadataFactory');
     $d->setDefaultRepositoryClassName('Doctrine\\ORM\\EntityRepository');
     $d->setNamingStrategy(new \Doctrine\ORM\Mapping\UnderscoreNamingStrategy());
     $d->setQuoteStrategy(new \Doctrine\ORM\Mapping\DefaultQuoteStrategy());
     $d->setEntityListenerResolver($this->get('doctrine.orm.default_entity_listener_resolver'));
     $d->addCustomStringFunction('regexp', 'Bigfoot\\Bundle\\CoreBundle\\ORM\\Doctrine\\Query\\MySQL\\Regexp');
     $d->addCustomStringFunction('substring_index', 'Bigfoot\\Bundle\\CoreBundle\\ORM\\Doctrine\\Query\\MySQL\\SubstringIndex');
     $d->addCustomStringFunction('greatest', 'Bigfoot\\Bundle\\CoreBundle\\ORM\\Doctrine\\Query\\MySQL\\Greatest');
     $d->addCustomNumericFunction('acos', 'Bigfoot\\Bundle\\CoreBundle\\ORM\\Acos');
     $d->addCustomNumericFunction('cos', 'Bigfoot\\Bundle\\CoreBundle\\ORM\\Cos');
     $d->addCustomNumericFunction('sin', 'Bigfoot\\Bundle\\CoreBundle\\ORM\\Sin');
     $d->addCustomNumericFunction('radians', 'Bigfoot\\Bundle\\CoreBundle\\ORM\\Radians');
     $d->addCustomNumericFunction('GEO_DISTANCE', 'Craue\\GeoBundle\\Doctrine\\Query\\Mysql\\GeoDistance');
     $d->addCustomNumericFunction('GEO_DISTANCE_BY_POSTAL_CODE', 'Craue\\GeoBundle\\Doctrine\\Query\\Mysql\\GeoDistanceByPostalCode');
     $d->addFilter('softdeleteable', 'Gedmo\\SoftDeleteable\\Filter\\SoftDeleteableFilter');
     $this->services['doctrine.orm.default_entity_manager'] = $instance = \Doctrine\ORM\EntityManager::create($this->get('doctrine.dbal.default_connection'), $d);
     $this->get('doctrine.orm.default_manager_configurator')->configure($instance);
     return $instance;
 }
 /**
  * Gets the 'doctrine.orm.default_entity_manager' service.
  *
  * This service is shared.
  * This method always returns the same instance of the service.
  *
  * @return \Doctrine\ORM\EntityManager A Doctrine\ORM\EntityManager instance.
  */
 protected function getDoctrine_Orm_DefaultEntityManagerService()
 {
     $a = $this->get('annotation_reader');
     $b = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($a, array(0 => $this->targetDirs[3] . '\\src\\BackOffice\\RO\\UtilisateurBundle\\Entity', 1 => $this->targetDirs[3] . '\\src\\BackOffice\\RO\\AgenceBundle\\Entity', 2 => $this->targetDirs[3] . '\\src\\BackOffice\\RO\\VehiculeBundle\\Entity', 3 => $this->targetDirs[3] . '\\src\\BackOffice\\RO\\EquipementBundle\\Entity', 4 => $this->targetDirs[3] . '\\src\\BackOffice\\RO\\ModeleBundle\\Entity', 5 => $this->targetDirs[3] . '\\src\\BackOffice\\RO\\MarqueBundle\\Entity', 6 => $this->targetDirs[3] . '\\src\\BackOffice\\RO\\CategorieBundle\\Entity', 7 => $this->targetDirs[3] . '\\src\\BackOffice\\RO\\EntrepriseBundle\\Entity', 8 => $this->targetDirs[3] . '\\src\\BackOffice\\RO\\ClientBundle\\Entity', 9 => $this->targetDirs[3] . '\\src\\BackOffice\\RO\\ContratBundle\\Entity', 10 => $this->targetDirs[3] . '\\src\\BackOffice\\RO\\FactureBundle\\Entity', 11 => $this->targetDirs[3] . '\\src\\BackOffice\\RO\\ReservationBundle\\Entity'));
     $c = new \Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain();
     $c->addDriver($b, 'BackOffice\\RO\\UtilisateurBundle\\Entity');
     $c->addDriver($b, 'BackOffice\\RO\\AgenceBundle\\Entity');
     $c->addDriver($b, 'BackOffice\\RO\\VehiculeBundle\\Entity');
     $c->addDriver($b, 'BackOffice\\RO\\EquipementBundle\\Entity');
     $c->addDriver($b, 'BackOffice\\RO\\ModeleBundle\\Entity');
     $c->addDriver($b, 'BackOffice\\RO\\MarqueBundle\\Entity');
     $c->addDriver($b, 'BackOffice\\RO\\CategorieBundle\\Entity');
     $c->addDriver($b, 'BackOffice\\RO\\EntrepriseBundle\\Entity');
     $c->addDriver($b, 'BackOffice\\RO\\ClientBundle\\Entity');
     $c->addDriver($b, 'BackOffice\\RO\\ContratBundle\\Entity');
     $c->addDriver($b, 'BackOffice\\RO\\FactureBundle\\Entity');
     $c->addDriver($b, 'BackOffice\\RO\\ReservationBundle\\Entity');
     $d = new \Doctrine\ORM\Configuration();
     $d->setEntityNamespaces(array('ROUtilisateurBundle' => 'BackOffice\\RO\\UtilisateurBundle\\Entity', 'ROAgenceBundle' => 'BackOffice\\RO\\AgenceBundle\\Entity', 'ROVehiculeBundle' => 'BackOffice\\RO\\VehiculeBundle\\Entity', 'ROEquipementBundle' => 'BackOffice\\RO\\EquipementBundle\\Entity', 'ROModeleBundle' => 'BackOffice\\RO\\ModeleBundle\\Entity', 'ROMarqueBundle' => 'BackOffice\\RO\\MarqueBundle\\Entity', 'ROCategorieBundle' => 'BackOffice\\RO\\CategorieBundle\\Entity', 'ROEntrepriseBundle' => 'BackOffice\\RO\\EntrepriseBundle\\Entity', 'ROClientBundle' => 'BackOffice\\RO\\ClientBundle\\Entity', 'ROContratBundle' => 'BackOffice\\RO\\ContratBundle\\Entity', 'ROFactureBundle' => 'BackOffice\\RO\\FactureBundle\\Entity', 'ROReservationBundle' => 'BackOffice\\RO\\ReservationBundle\\Entity'));
     $d->setMetadataCacheImpl($this->get('doctrine_cache.providers.doctrine.orm.default_metadata_cache'));
     $d->setQueryCacheImpl($this->get('doctrine_cache.providers.doctrine.orm.default_query_cache'));
     $d->setResultCacheImpl($this->get('doctrine_cache.providers.doctrine.orm.default_result_cache'));
     $d->setMetadataDriverImpl($c);
     $d->setProxyDir(__DIR__ . '/doctrine/orm/Proxies');
     $d->setProxyNamespace('Proxies');
     $d->setAutoGenerateProxyClasses(true);
     $d->setClassMetadataFactoryName('Doctrine\\ORM\\Mapping\\ClassMetadataFactory');
     $d->setDefaultRepositoryClassName('Doctrine\\ORM\\EntityRepository');
     $d->setNamingStrategy(new \Doctrine\ORM\Mapping\DefaultNamingStrategy());
     $d->setEntityListenerResolver($this->get('doctrine.orm.default_entity_listener_resolver'));
     $d->addCustomStringFunction('groupConcat', 'BackOffice\\RO\\UtilisateurBundle\\DQL\\GroupConcat');
     $d->addCustomStringFunction('replaceString', 'BackOffice\\RO\\UtilisateurBundle\\DQL\\ReplaceString');
     $this->services['doctrine.orm.default_entity_manager'] = $instance = \Doctrine\ORM\EntityManager::create($this->get('doctrine.dbal.default_connection'), $d);
     $this->get('doctrine.orm.default_manager_configurator')->configure($instance);
     return $instance;
 }
 /**
  * Gets the 'doctrine.orm.default_entity_manager' service.
  *
  * This service is shared.
  * This method always returns the same instance of the service.
  *
  * @return \Doctrine\ORM\EntityManager A Doctrine\ORM\EntityManager instance.
  */
 protected function getDoctrine_Orm_DefaultEntityManagerService()
 {
     $a = new \Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain();
     $a->addDriver(new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($this->get('annotation_reader'), array(0 => $this->targetDirs[3] . '/src/ServiceBundle/Entity')), 'ServiceBundle\\Entity');
     $b = new \Doctrine\ORM\Configuration();
     $b->setEntityNamespaces(array('ServiceBundle' => 'ServiceBundle\\Entity'));
     $b->setMetadataCacheImpl($this->get('doctrine_cache.providers.doctrine.orm.default_metadata_cache'));
     $b->setQueryCacheImpl($this->get('doctrine_cache.providers.doctrine.orm.default_query_cache'));
     $b->setResultCacheImpl($this->get('doctrine_cache.providers.doctrine.orm.default_result_cache'));
     $b->setMetadataDriverImpl($a);
     $b->setProxyDir(__DIR__ . '/doctrine/orm/Proxies');
     $b->setProxyNamespace('Proxies');
     $b->setAutoGenerateProxyClasses(true);
     $b->setClassMetadataFactoryName('Doctrine\\ORM\\Mapping\\ClassMetadataFactory');
     $b->setDefaultRepositoryClassName('Doctrine\\ORM\\EntityRepository');
     $b->setNamingStrategy(new \Doctrine\ORM\Mapping\UnderscoreNamingStrategy());
     $b->setQuoteStrategy(new \Doctrine\ORM\Mapping\DefaultQuoteStrategy());
     $b->setEntityListenerResolver($this->get('doctrine.orm.default_entity_listener_resolver'));
     $b->addCustomStringFunction('charlength', 'DoctrineExtensions\\Query\\Mysql\\CharLength');
     $b->addCustomStringFunction('concat_ws', 'DoctrineExtensions\\Query\\Mysql\\ConcatWs');
     $b->addCustomStringFunction('countif', 'DoctrineExtensions\\Query\\Mysql\\CountIf');
     $b->addCustomStringFunction('degrees', 'DoctrineExtensions\\Query\\Mysql\\Degrees');
     $b->addCustomStringFunction('field', 'DoctrineExtensions\\Query\\Mysql\\Field');
     $b->addCustomStringFunction('findinset', 'DoctrineExtensions\\Query\\Mysql\\FindInSet');
     $b->addCustomStringFunction('groupconcat', 'DoctrineExtensions\\Query\\Mysql\\GroupConcat');
     $b->addCustomStringFunction('ifelse', 'DoctrineExtensions\\Query\\Mysql\\IfElse');
     $b->addCustomStringFunction('ifnull', 'DoctrineExtensions\\Query\\Mysql\\IfNull');
     $b->addCustomStringFunction('matchagainst', 'DoctrineExtensions\\Query\\Mysql\\MatchAgainst');
     $b->addCustomStringFunction('md5', 'DoctrineExtensions\\Query\\Mysql\\Md5');
     $b->addCustomStringFunction('month', 'DoctrineExtensions\\Query\\Mysql\\Month');
     $b->addCustomStringFunction('monthname', 'DoctrineExtensions\\Query\\Mysql\\MonthName');
     $b->addCustomStringFunction('nullif', 'DoctrineExtensions\\Query\\Mysql\\NullIf');
     $b->addCustomStringFunction('radians', 'DoctrineExtensions\\Query\\Mysql\\Radians');
     $b->addCustomStringFunction('sha1', 'DoctrineExtensions\\Query\\Mysql\\Sha1');
     $b->addCustomStringFunction('sha2', 'DoctrineExtensions\\Query\\Mysql\\Sha2');
     $b->addCustomNumericFunction('acos', 'DoctrineExtensions\\Query\\Mysql\\Acos');
     $b->addCustomNumericFunction('asin', 'DoctrineExtensions\\Query\\Mysql\\Asin');
     $b->addCustomNumericFunction('atan2', 'DoctrineExtensions\\Query\\Mysql\\Atan2');
     $b->addCustomNumericFunction('atan', 'DoctrineExtensions\\Query\\Mysql\\Atan');
     $b->addCustomNumericFunction('cos', 'DoctrineExtensions\\Query\\Mysql\\Cos');
     $b->addCustomNumericFunction('cot', 'DoctrineExtensions\\Query\\Mysql\\Cot');
     $b->addCustomNumericFunction('round', 'DoctrineExtensions\\Query\\Mysql\\Round');
     $b->addCustomNumericFunction('sin', 'DoctrineExtensions\\Query\\Mysql\\Sin');
     $b->addCustomNumericFunction('tan', 'DoctrineExtensions\\Query\\Mysql\\Tan');
     $b->addCustomNumericFunction('time_diff', 'DoctrineExtensions\\Query\\Mysql\\TimeDiff');
     $b->addCustomDatetimeFunction('date', 'DoctrineExtensions\\Query\\Mysql\\Date');
     $b->addCustomDatetimeFunction('dateadd', 'DoctrineExtensions\\Query\\Mysql\\DateAdd');
     $b->addCustomDatetimeFunction('datediff', 'DoctrineExtensions\\Query\\Mysql\\DateDiff');
     $b->addCustomDatetimeFunction('date_format', 'DoctrineExtensions\\Query\\Mysql\\DateFormat');
     $b->addCustomDatetimeFunction('day', 'DoctrineExtensions\\Query\\Mysql\\Day');
     $b->addCustomDatetimeFunction('dayname', 'DoctrineExtensions\\Query\\Mysql\\DayName');
     $b->addCustomDatetimeFunction('strtodate', 'DoctrineExtensions\\Query\\Mysql\\StrToDate');
     $b->addCustomDatetimeFunction('timestampdiff', 'DoctrineExtensions\\Query\\Mysql\\TimestampDiff');
     $b->addCustomDatetimeFunction('week', 'DoctrineExtensions\\Query\\Mysql\\Week');
     $b->addCustomDatetimeFunction('year', 'DoctrineExtensions\\Query\\Mysql\\Year');
     $b->addCustomDatetimeFunction('month', 'DoctrineExtensions\\Query\\Mysql\\Month');
     $this->services['doctrine.orm.default_entity_manager'] = $instance = \Doctrine\ORM\EntityManager::create($this->get('doctrine.dbal.default_connection'), $b);
     $this->get('doctrine.orm.default_manager_configurator')->configure($instance);
     return $instance;
 }
 /**
  * Gets the 'doctrine.orm.default_entity_manager' service.
  *
  * This service is shared.
  * This method always returns the same instance of the service.
  *
  * @return \Doctrine\ORM\EntityManager A Doctrine\ORM\EntityManager instance.
  */
 protected function getDoctrine_Orm_DefaultEntityManagerService()
 {
     $a = new \Doctrine\ORM\Mapping\Driver\SimplifiedYamlDriver(array('/Users/marcu/Projects/Chill/vendor/chill-project/activity/vendor/chill-project/main/Resources/config/doctrine' => 'Chill\\MainBundle\\Entity', '/Users/marcu/Projects/Chill/vendor/chill-project/activity/vendor/chill-project/custom-fields/Resources/config/doctrine' => 'Chill\\CustomFieldsBundle\\Entity', '/Users/marcu/Projects/Chill/vendor/chill-project/activity/vendor/chill-project/person/Resources/config/doctrine' => 'Chill\\PersonBundle\\Entity', '/Users/marcu/Projects/Chill/vendor/chill-project/activity/Resources/config/doctrine' => 'Chill\\ActivityBundle\\Entity'));
     $a->setGlobalBasename('mapping');
     $b = new \Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain();
     $b->addDriver($a, 'Chill\\MainBundle\\Entity');
     $b->addDriver($a, 'Chill\\CustomFieldsBundle\\Entity');
     $b->addDriver($a, 'Chill\\PersonBundle\\Entity');
     $b->addDriver($a, 'Chill\\ActivityBundle\\Entity');
     $c = new \Doctrine\ORM\Configuration();
     $c->setEntityNamespaces(array('ChillMainBundle' => 'Chill\\MainBundle\\Entity', 'ChillCustomFieldsBundle' => 'Chill\\CustomFieldsBundle\\Entity', 'ChillPersonBundle' => 'Chill\\PersonBundle\\Entity', 'ChillActivityBundle' => 'Chill\\ActivityBundle\\Entity'));
     $c->setMetadataCacheImpl($this->get('doctrine_cache.providers.doctrine.orm.default_metadata_cache'));
     $c->setQueryCacheImpl($this->get('doctrine_cache.providers.doctrine.orm.default_query_cache'));
     $c->setResultCacheImpl($this->get('doctrine_cache.providers.doctrine.orm.default_result_cache'));
     $c->setMetadataDriverImpl($b);
     $c->setProxyDir('/Users/marcu/Projects/Chill/vendor/chill-project/activity/Tests/Fixtures/App/app/cache/dev/doctrine/orm/Proxies');
     $c->setProxyNamespace('Proxies');
     $c->setAutoGenerateProxyClasses(true);
     $c->setClassMetadataFactoryName('Doctrine\\ORM\\Mapping\\ClassMetadataFactory');
     $c->setDefaultRepositoryClassName('Doctrine\\ORM\\EntityRepository');
     $c->setNamingStrategy(new \Doctrine\ORM\Mapping\DefaultNamingStrategy());
     $c->setQuoteStrategy(new \Doctrine\ORM\Mapping\DefaultQuoteStrategy());
     $c->setEntityListenerResolver($this->get('doctrine.orm.default_entity_listener_resolver'));
     $c->addCustomStringFunction('unaccent', 'Chill\\MainBundle\\Doctrine\\DQL\\Unaccent');
     $this->services['doctrine.orm.default_entity_manager'] = $instance = \Doctrine\ORM\EntityManager::create($this->get('doctrine.dbal.default_connection'), $c);
     $this->get('doctrine.orm.default_manager_configurator')->configure($instance);
     return $instance;
 }
示例#10
0
 public function __construct()
 {
     global $container;
     $container = new Container();
     $container['session'] = function ($container) {
         $session = new Session();
         if (session_id() == '') {
             $session->start();
         }
         return $session;
     };
     $container['request'] = function ($container) {
         $request = Request::createFromGlobals();
         return $request;
     };
     $container['config'] = function ($container) {
         $config = new ConfigHelper();
         return $config->objInstance;
     };
     $container['translator'] = function ($container) {
         $request = $container['request'];
         $translator = new TranslateHelper($request);
         return $translator->objInstance;
     };
     $container['cacheType'] = $container['config']["fastChatType"];
     $container['fastcache'] = function ($container) {
         phpFastCache::setup("storage", $container['cacheType']);
         phpFastCache::setup("path", BASE_ROOT . "/cache/fastcache/");
         $cache = phpFastCache();
         return $cache;
     };
     $container['twig'] = function ($container) {
         $config = $container['config'];
         $translator = $container['translator'];
         $arrayOfFileSystem = [BASE_ROOT . '/pages/Admin/templates/modules', BASE_ROOT . '/pages/Admin/templates/emails', BASE_ROOT . '/pages/Admin/modules/GererItemShop/templates', BASE_ROOT . '/pages/Admin/modules/GererEquipeJeu/templates', BASE_ROOT . '/pages/Admin/modules/GererEquipeSite/templates', BASE_ROOT . '/pages/Admin/modules/Parametres/templates', BASE_ROOT . '/pages/ItemShop/modules/Hipay/templates', BASE_ROOT . '/pages/ItemShop/modules/Starpass/templates', BASE_ROOT . '/pages/Classements/templates/', BASE_ROOT . '/pages/Inscription/templates/modules', BASE_ROOT . '/pages/Inscription/templates/emails', BASE_ROOT . '/pages/ItemShop/templates/modules', BASE_ROOT . '/pages/ItemShop/templates/emails', BASE_ROOT . '/pages/Messagerie/templates/modules', BASE_ROOT . '/pages/Messagerie/templates/emails', BASE_ROOT . '/pages/Marche/templates/modules', BASE_ROOT . '/pages/Marche/templates/emails', BASE_ROOT . '/pages/MonCompte/templates/modules', BASE_ROOT . '/pages/MonCompte/templates/emails', BASE_ROOT . '/pages/MonPersonnage/templates/modules', BASE_ROOT . '/pages/MonPersonnage/templates/emails', BASE_ROOT . '/pages/Statistiques/templates/modules', BASE_ROOT . '/pages/Votes/templates/', BASE_ROOT . '/pages/_LegacyPages/templates/', BASE_ROOT . '/pages/_Home/templates/modules/', BASE_ROOT . '/core/templates/'];
         if ($config["twigCache"]) {
             $urlCache = BASE_ROOT . $config["twigCacheUrl"];
         } else {
             $urlCache = false;
         }
         $loader = new Twig_Loader_Filesystem($arrayOfFileSystem);
         $twig = new Twig_Environment($loader, array('cache' => $urlCache));
         $twig->addExtension(new Twig_Extensions_Extension_Text());
         $twig->addExtension(new StringFunctionExtension());
         $twig->addExtension(new FonctionsUtilesExtension());
         $twig->addExtension(new HelperExtension());
         $twig->addExtension(new ImageFunctionExtension());
         $twig->addExtension(new DateFunctionExtension());
         $twig->addExtension(new Twig_Extension_Debug());
         $twig->addExtension(new EncryptExtension());
         include BASE_ROOT . '/pages/Tableaux_Arrays.php';
         $twig->addExtension(new \Symfony\Bridge\Twig\Extension\TranslationExtension($translator));
         $twig->addGlobal('session', $container['session']);
         $twig->addGlobal('request', $container['request']);
         $twig->addGlobal('config', $container['config']);
         $twig->addGlobal('urlBase', BASE_ROOT);
         return $twig;
     };
     $container['doctrine.eventManager'] = function ($container) {
         $eventManager = new \Doctrine\Common\EventManager();
         return $eventManager;
     };
     $container['doctrine.connection.default'] = function ($container) {
         $param = $container['config'];
         $config = new \Doctrine\DBAL\Configuration();
         // build connection parameters
         $connectionParameters = array('dbname' => "site", 'user' => $param["bdd"]["user"], 'password' => $param["bdd"]["password"], 'host' => $param["bdd"]["host"], 'port' => $param["bdd"]["port"]);
         switch (strtolower($param["bdd"]["driver"])) {
             case 'mysql':
                 $connectionParameters['driver'] = 'pdo_mysql';
                 $connectionParameters['charset'] = strtolower($param["bdd"]["charset"]);
                 break;
             default:
                 throw new RuntimeException('Database driver ' . $param["bdd"]["driver"] . ' not known by doctrine.');
         }
         /* if (!empty($GLOBALS['TL_CONFIG']['dbPdoDriverOptions'])) {
            $connectionParameters['driverOptions'] = deserialize($GLOBALS['TL_CONFIG']['dbPdoDriverOptions'], true);
            } */
         $connectionParameters['defaultTableOptions'] = array('collate' => 'utf8_general_ci');
         /** @var \Doctrine\Common\EventManager $eventManager */
         $eventManager = $container['doctrine.eventManager'];
         // establish connection
         $connection = \Doctrine\DBAL\DriverManager::getConnection($connectionParameters, $config, $eventManager);
         $connection->getConfiguration()->setSQLLogger(null);
         // fix platform differences
         $platform = $connection->getDatabasePlatform();
         $platform->registerDoctrineTypeMapping('bit', 'boolean');
         return $connection;
     };
     $container['doctrine.orm.entitiesCacheDir'] = function ($container) {
         $entitiesCacheDir = BASE_ROOT . '/cache/doctrine/entities';
         if (!is_dir($entitiesCacheDir)) {
             mkdir($entitiesCacheDir, 0777, true);
         }
         $classLoader = new \Composer\Autoload\ClassLoader();
         $classLoader->add('', array($entitiesCacheDir), true);
         $classLoader->register(true);
         $container['doctrine.orm.entitiesClassLoader'] = $classLoader;
         return $entitiesCacheDir;
     };
     $container['doctrine.orm.proxiesCacheDir'] = function ($container) {
         $proxiesCacheDir = BASE_ROOT . '/cache/doctrine/proxies';
         if (!is_dir($proxiesCacheDir)) {
             mkdir($proxiesCacheDir, 0777, true);
         }
         return $proxiesCacheDir;
     };
     $container['doctrine.orm.repositoriesCacheDir'] = function ($container) {
         $repositoriesCacheDir = BASE_ROOT . '/cache/doctrine/repositories';
         if (!is_dir($repositoriesCacheDir)) {
             mkdir($repositoriesCacheDir, 0777, true);
         }
         return $repositoriesCacheDir;
     };
     $container['doctrine.orm.entityManager'] = function ($container) {
         $param = $container['config'];
         $paths = array(BASE_ROOT . '/core/library/Account/Entity', BASE_ROOT . '/core/library/Player/Entity');
         $isDevMode = false;
         $config = \Doctrine\ORM\Tools\Setup::createConfiguration($isDevMode);
         // Configuration
         $config = new Doctrine\ORM\Configuration();
         $config->addCustomStringFunction('PASSWORD', '\\DoctrinePasswordExtension');
         $config->addCustomStringFunction('RAND', '\\DoctrineRandExtension');
         $config->addCustomStringFunction('WEEK', '\\DoctrineExtensions\\Query\\Mysql\\WEEK');
         $config->addCustomStringFunction('MONTH', '\\DoctrineExtensions\\Query\\Mysql\\MONTH');
         $config->addCustomStringFunction('YEAR', '\\DoctrineExtensions\\Query\\Mysql\\YEAR');
         $config->addCustomStringFunction('IFELSE', '\\DoctrineExtensions\\Query\\Mysql\\IfElse');
         // Proxy Configuration
         $proxiesCacheDir = $container['doctrine.orm.proxiesCacheDir'];
         $config->setProxyDir($proxiesCacheDir);
         $config->setProxyNamespace('entities\\proxies');
         switch ($param["bdd"]["cache"]) {
             case 'apc':
                 $cache = new \Doctrine\Common\Cache\ApcCache();
                 break;
             case 'array':
                 $cache = new \Doctrine\Common\Cache\ArrayCache();
                 break;
             case false:
                 $cache = false;
                 break;
         }
         if (!$cache) {
             // Mapping Configuration
             $entitiesCacheDir = $container['doctrine.orm.entitiesCacheDir'];
             $reader = new \Doctrine\Common\Annotations\FileCacheReader(new \Doctrine\Common\Annotations\AnnotationReader(), $entitiesCacheDir, $debug = false);
         } else {
             $reader = new \Doctrine\Common\Annotations\CachedReader(new \Doctrine\Common\Annotations\AnnotationReader(), $cache, $debug = false);
         }
         $driverImpl = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($reader, $paths);
         //$driverImpl = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver(new \Doctrine\Common\Annotations\AnnotationReader(), $paths);
         // registering noop annotation autoloader - allow all annotations by default
         \Doctrine\Common\Annotations\AnnotationRegistry::registerLoader('class_exists');
         $config->setMetadataDriverImpl($driverImpl);
         // Caching Configuration
         $cache = new \Doctrine\Common\Cache\ArrayCache();
         $config->setMetadataCacheImpl($cache);
         $config->setQueryCacheImpl($cache);
         //$config->setAutoGenerateProxyClasses(false);
         /** @var $connection \Doctrine\DBAL\Connection */
         $connection = $container['doctrine.connection.default'];
         /** @var $eventManager \Doctrine\Common\EventManager */
         $eventManager = $container['doctrine.eventManager'];
         /** @var $entityManager \Doctrine\ORM\EntityManager */
         $entityManager = \Doctrine\ORM\EntityManager::create($connection, $config, $eventManager);
         return $entityManager;
     };
     $this->container = $container;
 }