diff --git a/README.md b/README.md index 1cc76418..a41e77a1 100644 --- a/README.md +++ b/README.md @@ -519,6 +519,19 @@ You can : * subclass the MoneyFormatter and rewrite the getDefaultNumberFormater method to set a application wide NumberFormatter +Using the TbbcMoneyBundle without doctrine +------------------------------------------ + +You have to disable the pair history service in order to use the TbbcMoneyBundle without doctrine. + +``` +tbbc_money: + enable_pair_history: true +``` + +Note : you can imagine to code your own PairHistoryManager for mongodb or propel, it is very easy to do. Don't +hesitate to submit a PR with your code and your tests. + Optimizations ------------- diff --git a/TbbcMoneyBundle.php b/TbbcMoneyBundle.php index 05fcf501..3dd61dfd 100644 --- a/TbbcMoneyBundle.php +++ b/TbbcMoneyBundle.php @@ -27,15 +27,17 @@ public function boot() { parent::boot(); - if(!Type::hasType(MoneyType::NAME)) { - Type::addType(MoneyType::NAME, 'Tbbc\MoneyBundle\Type\MoneyType'); - } - - $entityManagerNameList = $this->container->getParameter('doctrine.entity_managers'); - foreach($entityManagerNameList as $entityManagerName) { - $em = $this->container->get($entityManagerName); - if (!$em->getConnection()->getDatabasePlatform()->hasDoctrineTypeMappingFor(MoneyType::NAME)) { - $em->getConnection()->getDatabasePlatform()->registerDoctrineTypeMapping(MoneyType::NAME, MoneyType::NAME); + if($this->container->hasParameter('doctrine.entity_managers')){ + if(!Type::hasType(MoneyType::NAME)) { + Type::addType(MoneyType::NAME, 'Tbbc\MoneyBundle\Type\MoneyType'); + } + + $entityManagerNameList = $this->container->getParameter('doctrine.entity_managers'); + foreach($entityManagerNameList as $entityManagerName) { + $em = $this->container->get($entityManagerName); + if (!$em->getConnection()->getDatabasePlatform()->hasDoctrineTypeMappingFor(MoneyType::NAME)) { + $em->getConnection()->getDatabasePlatform()->registerDoctrineTypeMapping(MoneyType::NAME, MoneyType::NAME); + } } } }