예제 #1
0
 /**
  * @param $serviceId
  * @return AddressLookupQuotaHelper
  */
 protected function getLookupQuotaHelper($serviceId)
 {
     $entityManager = $this->container->get('entity_manager');
     /** @var AddressLookupQuotaHelperRepositoryDoctrine $quotaHelperRepository */
     $quotaHelperRepository = $this->container->get('addressquotahelper_repository');
     /** @var AddressLookupQuotaHelper $quotaHelper */
     $quotaHelper = $quotaHelperRepository->find($serviceId);
     if (null === $quotaHelper) {
         $quotaHelper = AddressLookupQuotaHelper::registerLookupQuotaHelper($serviceId);
         $quotaHelperRepository->store($quotaHelper);
         $entityManager->flush();
     }
     return $quotaHelper;
 }
 /**
  * @param $id
  * @return AddressLookupQuotaHelper
  */
 public static function registerLookupQuotaHelper($id)
 {
     $volume = new AddressLookupQuotaHelper();
     $volume->setId($id);
     $volume->setLastLookupDateTime(DateTimeService::getUTCnow());
     $volume->setCurrentDailyLookups(0);
     $volume->setCurrentMonthlyLookups(0);
     return $volume;
 }
예제 #3
0
 /**
  * count the lookup and persist to database
  */
 protected function persistentlyCountLookup()
 {
     $this->lookupQuotaHelper->countLookup();
     $this->getEntityManager()->flush();
 }