Skip to content

Commit

Permalink
Merge pull request Sylius#7318 from lchrusciel/repository-method-refugee
Browse files Browse the repository at this point in the history
[Core] Move repository method from order to core
  • Loading branch information
pjedrzejewski committed Jan 30, 2017
2 parents e8daaf1 + f3b8204 commit 96353b2
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 21 deletions.
3 changes: 3 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ After:

### Order / OrderBundle

* Method `findOrdersUnpaidSince` of `Sylius\Bundle\OrderBundle\Doctrine\ORM\OrderRepository` has been moved to `Sylius\Bundle\CoreBundle\Doctrine\ORM\OrderRepository` as it depends on Core component.
If you haven't been using this method, you can remove the 'CoreBundle' dependency.

### Payment / PaymentBundle

* Changed default ``Payment::$state`` from *new* to *cart*.
Expand Down
21 changes: 21 additions & 0 deletions src/Sylius/Bundle/CoreBundle/Doctrine/ORM/OrderRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
use Sylius\Component\Core\Model\CustomerInterface;
use Sylius\Component\Core\Model\OrderInterface;
use Sylius\Component\Core\Model\PromotionCouponInterface;
use Sylius\Component\Core\OrderCheckoutStates;
use Sylius\Component\Core\OrderPaymentStates;
use Sylius\Component\Core\Repository\OrderRepositoryInterface;

class OrderRepository extends BaseOrderRepository implements OrderRepositoryInterface
Expand Down Expand Up @@ -209,4 +211,23 @@ public function findLatestInChannel($count, ChannelInterface $channel)
->getResult()
;
}

/**
* {@inheritdoc}
*/
public function findOrdersUnpaidSince(\DateTime $terminalDate)
{
return $this->createQueryBuilder('o')
->where('o.checkoutState = :checkoutState')
->andWhere('o.paymentState != :paymentState')
->andWhere('o.state = :orderState')
->andWhere('o.checkoutCompletedAt < :terminalDate')
->setParameter('checkoutState', OrderCheckoutStates::STATE_COMPLETED)
->setParameter('paymentState', OrderPaymentStates::STATE_PAID)
->setParameter('orderState', OrderInterface::STATE_NEW)
->setParameter('terminalDate', $terminalDate)
->getQuery()
->getResult()
;
}
}
21 changes: 0 additions & 21 deletions src/Sylius/Bundle/OrderBundle/Doctrine/ORM/OrderRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
namespace Sylius\Bundle\OrderBundle\Doctrine\ORM;

use Sylius\Bundle\ResourceBundle\Doctrine\ORM\EntityRepository;
use Sylius\Component\Core\OrderCheckoutStates;
use Sylius\Component\Core\OrderPaymentStates;
use Sylius\Component\Order\Model\OrderInterface;
use Sylius\Component\Order\Repository\OrderRepositoryInterface;

Expand Down Expand Up @@ -110,23 +108,4 @@ public function findCartsNotModifiedSince(\DateTime $terminalDate)
->getResult()
;
}

/**
* {@inheritdoc}
*/
public function findOrdersUnpaidSince(\DateTime $terminalDate)
{
return $this->createQueryBuilder('o')
->andWhere('o.checkoutState = :checkoutState')
->andWhere('o.paymentState != :paymentState')
->andWhere('o.state = :orderState')
->andWhere('o.checkoutCompletedAt < :terminalDate')
->setParameter('checkoutState', OrderCheckoutStates::STATE_COMPLETED)
->setParameter('paymentState', OrderPaymentStates::STATE_PAID)
->setParameter('orderState', OrderInterface::STATE_NEW)
->setParameter('terminalDate', $terminalDate)
->getQuery()
->getResult()
;
}
}

0 comments on commit 96353b2

Please sign in to comment.