public function setUp()
 {
     $config = new \Doctrine\ORM\Configuration();
     $config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache());
     $config->setQueryCacheImpl(new \Doctrine\Common\Cache\ArrayCache());
     $config->setProxyDir(__DIR__ . '/Proxies');
     $config->setProxyNamespace('DoctrineExtensions\\Tests\\Proxies');
     $config->setAutoGenerateProxyClasses(true);
     $config->setMetadataDriverImpl($config->newDefaultAnnotationDriver(__DIR__ . '/../Entities'));
     $config->setCustomDatetimeFunctions(array('DATEADD' => 'DoctrineExtensions\\Query\\Mysql\\DateAdd', 'DATEDIFF' => 'DoctrineExtensions\\Query\\Mysql\\DateDiff', 'DATESUB' => 'DoctrineExtensions\\Query\\Mysql\\DateSub', 'FROM_UNIXTIME' => 'DoctrineExtensions\\Query\\Mysql\\FromUnixtime', 'UNIX_TIMESTAMP' => 'DoctrineExtensions\\Query\\Mysql\\UnixTimestamp'));
     $config->setCustomNumericFunctions(array('ACOS' => 'DoctrineExtensions\\Query\\Mysql\\Acos', 'ASIN' => 'DoctrineExtensions\\Query\\Mysql\\Asin', 'ATAN' => 'DoctrineExtensions\\Query\\Mysql\\Atan', 'ATAN2' => 'DoctrineExtensions\\Query\\Mysql\\Atan2', 'COS' => 'DoctrineExtensions\\Query\\Mysql\\Cos', 'COT' => 'DoctrineExtensions\\Query\\Mysql\\Cot', 'DEGREES' => 'DoctrineExtensions\\Query\\Mysql\\Degrees', 'RADIANS' => 'DoctrineExtensions\\Query\\Mysql\\Radians', 'SIN' => 'DoctrineExtensions\\Query\\Mysql\\Sin', 'TAN' => 'DoctrineExtensions\\Query\\Mysql\\Tan'));
     $config->setCustomStringFunctions(array('ASCII' => 'DoctrineExtensions\\Query\\Mysql\\Ascii', 'CHAR_LENGTH' => 'DoctrineExtensions\\Query\\Mysql\\CharLength', 'CONCAT_WS' => 'DoctrineExtensions\\Query\\Mysql\\ConcatWs', 'FIELD' => 'DoctrineExtensions\\Query\\Mysql\\Field', 'FIND_IN_SET' => 'DoctrineExtensions\\Query\\Mysql\\FindInSet', 'LEAST' => 'DoctrineExtensions\\Query\\Mysql\\Least', 'REPLACE' => 'DoctrineExtensions\\Query\\Mysql\\Replace', 'SOUNDEX' => 'DoctrineExtensions\\Query\\Mysql\\Soundex', 'STR_TO_DATE' => 'DoctrineExtensions\\Query\\Mysql\\StrToDate', 'SUBSTRING_INDEX' => 'DoctrineExtensions\\Query\\Mysql\\SubstringIndex'));
     $this->entityManager = \Doctrine\ORM\EntityManager::create(array('driver' => 'pdo_sqlite', 'memory' => true), $config);
 }
 public function setUp()
 {
     $config = new \Doctrine\ORM\Configuration();
     $config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache());
     $config->setQueryCacheImpl(new \Doctrine\Common\Cache\ArrayCache());
     $config->setProxyDir(__DIR__ . '/Proxies');
     $config->setProxyNamespace('DoctrineExtensions\\Tests\\Proxies');
     $config->setAutoGenerateProxyClasses(true);
     $config->setMetadataDriverImpl($config->newDefaultAnnotationDriver(__DIR__ . '/../Entities'));
     $config->setCustomDatetimeFunctions(array('YEAR' => 'DoctrineExtensions\\Query\\Sqlite\\Year', 'WEEKDAY' => 'DoctrineExtensions\\Query\\Sqlite\\WeekDay', 'WEEK' => 'DoctrineExtensions\\Query\\Sqlite\\Week', 'Month' => 'DoctrineExtensions\\Query\\Sqlite\\Month', 'MINUTE' => 'DoctrineExtensions\\Query\\Sqlite\\Minute', 'HOUR' => 'DoctrineExtensions\\Query\\Sqlite\\Hour', 'DAY' => 'DoctrineExtensions\\Query\\Sqlite\\Day', 'DATE' => 'DoctrineExtensions\\Query\\Sqlite\\Date', 'STRFTIME' => 'DoctrineExtensions\\Query\\Sqlite\\StrfTime', 'DATE_FORMAT' => 'DoctrineExtensions\\Query\\Sqlite\\DateFormat'));
     $config->setCustomNumericFunctions(array('ROUND' => 'DoctrineExtensions\\Query\\Sqlite\\Round'));
     $config->setCustomStringFunctions(array('CONCAT_WS' => 'DoctrineExtensions\\Query\\Sqlite\\ConcatWs', 'IFNULL' => 'DoctrineExtensions\\Query\\Sqlite\\IfNull', 'REPLACE' => 'DoctrineExtensions\\Query\\Sqlite\\Replace'));
     $this->entityManager = \Doctrine\ORM\EntityManager::create(array('driver' => 'pdo_sqlite', 'memory' => true), $config);
     $configuration = $this->entityManager->getConfiguration();
     if (method_exists($configuration, 'getQuoteStrategy') === false) {
         // doctrine < 2.3
         $this->columnAlias = 'sclr0';
     } else {
         $this->columnAlias = $configuration->getQuoteStrategy()->getColumnAlias('sclr', 0, $this->entityManager->getConnection()->getDatabasePlatform(), $this->entityManager->getClassMetadata('DoctrineExtensions\\Tests\\Entities\\Date'));
     }
 }
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     /** @var $options \DoctrineORMModule\Options\Configuration */
     $options = $this->getOptions($serviceLocator);
     $config = new \Doctrine\ORM\Configuration();
     $config->setAutoGenerateProxyClasses($options->getGenerateProxies());
     $config->setProxyDir($options->getProxyDir());
     $config->setProxyNamespace($options->getProxyNamespace());
     $config->setEntityNamespaces($options->getEntityNamespaces());
     $config->setCustomDatetimeFunctions($options->getDatetimeFunctions());
     $config->setCustomStringFunctions($options->getStringFunctions());
     $config->setCustomNumericFunctions($options->getNumericFunctions());
     foreach ($options->getNamedQueries() as $name => $query) {
         $config->addNamedQuery($name, $query);
     }
     foreach ($options->getNamedNativeQueries() as $name => $query) {
         $config->addNamedNativeQuery($name, $query['sql'], new $query['rsm']());
     }
     foreach ($options->getCustomHydrationModes() as $modeName => $hydrator) {
         $config->addCustomHydrationMode($modeName, $hydrator);
     }
     foreach ($options->getFilters() as $name => $class) {
         $config->addFilter($name, $class);
     }
     $config->setMetadataCacheImpl($serviceLocator->get($options->getMetadataCache()));
     $config->setQueryCacheImpl($serviceLocator->get($options->getQueryCache()));
     $config->setMetadataDriverImpl($serviceLocator->get($options->getDriver()));
     if ($namingStrategy = $options->getNamingStrategy()) {
         if (is_string($namingStrategy)) {
             if (!$serviceLocator->has($namingStrategy)) {
                 throw new InvalidArgumentException(sprintf('Naming strategy "%s" not found', $namingStrategy));
             }
             $config->setNamingStrategy($serviceLocator->get($namingStrategy));
         } else {
             $config->setNamingStrategy($namingStrategy);
         }
     }
     $this->setupDBALConfiguration($serviceLocator, $config);
     return $config;
 }
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     /** @var $options \DoctrineORMModule\Options\Configuration */
     $options = $this->getOptions($serviceLocator);
     $config = new \Doctrine\ORM\Configuration();
     $config->setAutoGenerateProxyClasses($options->getGenerateProxies());
     $config->setProxyDir($options->getProxyDir());
     $config->setProxyNamespace($options->getProxyNamespace());
     $config->setEntityNamespaces($options->getEntityNamespaces());
     $config->setCustomDatetimeFunctions($options->getDatetimeFunctions());
     $config->setCustomStringFunctions($options->getStringFunctions());
     $config->setCustomNumericFunctions($options->getNumericFunctions());
     foreach ($options->getNamedQueries() as $name => $query) {
         $config->addNamedQuery($name, $query);
     }
     foreach ($options->getNamedNativeQueries() as $name => $query) {
         $config->addNamedNativeQuery($name, $query['sql'], new $query['rsm']());
     }
     $config->setMetadataCacheImpl($serviceLocator->get($options->getMetadataCache()));
     $config->setQueryCacheImpl($serviceLocator->get($options->getQueryCache()));
     $config->setMetadataDriverImpl($serviceLocator->get($options->getDriver()));
     $this->setupDBALConfiguration($serviceLocator, $config);
     return $config;
 }
 /**
  * The Entity Manager - why we're all here!
  */
 private function registerEntityManager()
 {
     $this->app->singleton(EntityManagerInterface::class, function ($app) {
         $dconfig = new \Doctrine\ORM\Configuration();
         AnnotationRegistry::registerAutoloadNamespace(Config::get('d2bdoctrine.namespaces.models'), Config::get('d2bdoctrine.paths.models'));
         AnnotationRegistry::registerLoader('class_exists');
         $reader = new AnnotationReader();
         $driver = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($reader, Config::get('d2bdoctrine.paths.models'));
         /*
           $driver = new \Doctrine\ORM\Mapping\Driver\XmlDriver(
               array( Config::get( 'd2bdoctrine.paths.xml_schema' ) )
           );
         */
         $dconfig->setMetadataDriverImpl($driver);
         $dconfig->setProxyDir(Config::get('d2bdoctrine.paths.proxies'));
         $dconfig->setProxyNamespace(Config::get('d2bdoctrine.namespaces.proxies'));
         $dconfig->setAutoGenerateProxyClasses(Config::get('d2bdoctrine.autogen_proxies'));
         $lconfig = $this->laravelToDoctrineConfigMapper();
         //load prefix listener
         if (isset($lconfig['prefix']) && $lconfig['prefix'] && $lconfig['prefix'] !== '') {
             $tablePrefix = new TablePrefix($lconfig['prefix']);
             $eventManager->addEventListener(Events::loadClassMetadata, $tablePrefix);
         }
         if (isset($lconfig['slaves'])) {
             $driver = new Driver();
             $dconfig->setCustomDatetimeFunctions($this->datetime);
             $dconfig->setCustomNumericFunctions($this->numeric);
             $dconfig->setCustomStringFunctions($this->string);
             $connection = new MasterSlaveConnection($lconfig, $driver);
             $em = EntityManager::create($connection, $dconfig);
             return $em;
         }
         $dconfig->setCustomDatetimeFunctions($this->datetime);
         $dconfig->setCustomNumericFunctions($this->numeric);
         $dconfig->setCustomStringFunctions($this->string);
         $em = EntityManager::create($lconfig, $dconfig);
         return $em;
     });
 }