public function cleanUp()
 {
     $maxEndtime = Customweb_Core_Util_System::getScriptExecutionEndTime() - 4;
     // Remove all contexts which are not changed in the last 2 days and the state is not completed.
     $where = 'updatedOn < NOW() - INTERVAL 2 DAY AND state != "completed" LIMIT 0,40';
     $entities = $this->entityManager->search($this->contextEntityName, $where);
     foreach ($entities as $entity) {
         if ($maxEndtime > time()) {
             $this->entityManager->remove($entity);
         } else {
             break;
         }
     }
 }
예제 #2
0
 /**
  * Fetches a list of transaction which can be used as alias transactions for the given order context.
  * 
  * @param Customweb_Payment_Authorization_IOrderContext $orderContext
  * @return Customweb_Payment_Entity_AbstractTransaction[]
  */
 public function getAliasTransactions(Customweb_Payment_Authorization_IOrderContext $orderContext)
 {
     $customerId = $orderContext->getCustomerId();
     if ($customerId === null) {
         return array();
     }
     $transactions = $this->manager->search($this->transactionClassName, 'customerId = >customerId AND paymentMachineName = >paymentMethodName AND aliasActive = "y" AND aliasForDisplay IS NOT NULL AND aliasForDisplay != ""', 'createdOn DESC', array('>customerId' => $customerId, '>paymentMethodName' => $orderContext->getPaymentMethod()->getPaymentMethodName()));
     $result = array();
     foreach ($transactions as $transaction) {
         /* @var $transaction Customweb_Payment_Entity_AbstractTransaction */
         if (!isset($result[$transaction->getAliasForDisplay()])) {
             $result[$transaction->getAliasForDisplay()] = $transaction;
         }
     }
     return $result;
 }