mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 09:02:12 +00:00
[CoreBundle] Remove not-used code & drop dependency: "athari/yalinqo"
This commit is contained in:
parent
ed177a3982
commit
3f81f2b36a
4 changed files with 18 additions and 104 deletions
|
|
@ -21,7 +21,6 @@
|
|||
"require": {
|
||||
"php": ">=5.3.3",
|
||||
|
||||
"athari/yalinqo": "*@dev",
|
||||
"doctrine/doctrine-bundle": "1.2.*@dev",
|
||||
"doctrine/orm": "~2.3",
|
||||
"friendsofsymfony/rest-bundle": "~1.0",
|
||||
|
|
|
|||
45
composer.lock
generated
45
composer.lock
generated
|
|
@ -3,7 +3,7 @@
|
|||
"This file locks the dependencies of your project to a known state",
|
||||
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file"
|
||||
],
|
||||
"hash": "d4846a6e67b041fbb23bbde18b18a7e2",
|
||||
"hash": "e63dbd3e632fa96dae2b6185934875e6",
|
||||
"packages": [
|
||||
{
|
||||
"name": "ajbdev/authorizenet-php-api",
|
||||
|
|
@ -38,48 +38,6 @@
|
|||
],
|
||||
"time": "2013-02-11 21:09:06"
|
||||
},
|
||||
{
|
||||
"name": "athari/yalinqo",
|
||||
"version": "dev-master",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/Athari/YaLinqo.git",
|
||||
"reference": "6b3247909e037f218cca624c561d8a47ceeed6d2"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/Athari/YaLinqo/zipball/6b3247909e037f218cca624c561d8a47ceeed6d2",
|
||||
"reference": "6b3247909e037f218cca624c561d8a47ceeed6d2",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"files": [
|
||||
"YaLinqo/Linq.php"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"Simplified BSD"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Alexander Prokhorov"
|
||||
}
|
||||
],
|
||||
"description": "YaLinqo, a LINQ-to-objects library for PHP",
|
||||
"homepage": "https://github.com/Athari/YaLinqo",
|
||||
"keywords": [
|
||||
"linq",
|
||||
"linqo",
|
||||
"query",
|
||||
"statistic"
|
||||
],
|
||||
"time": "2013-05-08 12:59:02"
|
||||
},
|
||||
{
|
||||
"name": "doctrine/annotations",
|
||||
"version": "v1.1.2",
|
||||
|
|
@ -4558,7 +4516,6 @@
|
|||
],
|
||||
"minimum-stability": "stable",
|
||||
"stability-flags": {
|
||||
"athari/yalinqo": 20,
|
||||
"doctrine/doctrine-bundle": 20,
|
||||
"friendsofsymfony/user-bundle": 20,
|
||||
"knplabs/knp-menu": 20,
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ namespace Sylius\Bundle\CoreBundle\Repository;
|
|||
|
||||
use FOS\UserBundle\Model\UserInterface;
|
||||
use Sylius\Bundle\CartBundle\Doctrine\ORM\CartRepository;
|
||||
use YaLinqo\Enumerable;
|
||||
|
||||
class OrderRepository extends CartRepository
|
||||
{
|
||||
|
|
@ -33,7 +32,7 @@ class OrderRepository extends CartRepository
|
|||
}
|
||||
|
||||
/**
|
||||
* Gets orders by user
|
||||
* Gets orders for user.
|
||||
*
|
||||
* @param UserInterface $user
|
||||
* @param array $sorting
|
||||
|
|
@ -56,10 +55,9 @@ class OrderRepository extends CartRepository
|
|||
*/
|
||||
public function findForDetailsPage($id)
|
||||
{
|
||||
$queryBuilder = $this->getQueryBuilder();
|
||||
|
||||
$this->_em->getFilters()->disable('softdeleteable');
|
||||
|
||||
$queryBuilder = $this->getQueryBuilder();
|
||||
$queryBuilder
|
||||
->leftJoin('o.adjustments', 'adjustment')
|
||||
->leftJoin('o.user', 'user')
|
||||
|
|
@ -97,19 +95,18 @@ class OrderRepository extends CartRepository
|
|||
->setParameter('id', $id)
|
||||
;
|
||||
|
||||
$result = $queryBuilder
|
||||
return $queryBuilder
|
||||
->getQuery()
|
||||
->getOneOrNullResult()
|
||||
;
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create filter paginator.
|
||||
*
|
||||
* @param array $criteria
|
||||
* @param array $sorting
|
||||
* @param array $criteria
|
||||
* @param array $sorting
|
||||
* @param boolean $deleted
|
||||
*
|
||||
* @return PagerfantaInterface
|
||||
*/
|
||||
|
|
@ -165,41 +162,9 @@ class OrderRepository extends CartRepository
|
|||
return $this->getPaginator($queryBuilder);
|
||||
}
|
||||
|
||||
public function getTotalStatistics(\DateTime $from = null, \DateTime $to = null)
|
||||
public function findBetweenDates(\DateTime $from, \DateTime $to, $state = null)
|
||||
{
|
||||
$from = null === $from ? new \DateTime('1 year ago') : $from;
|
||||
$to = null === $to ? new \DateTime() : $to;
|
||||
|
||||
return Enumerable::from($this->findBetweenDates($from, $to))
|
||||
->groupBy(function ($order) {
|
||||
return $order->getCreatedAt()->format('m');
|
||||
}, '$v->getTotal()', function ($orders) {
|
||||
return Enumerable::from($orders)->sum();
|
||||
})
|
||||
->toValues()
|
||||
->toArray()
|
||||
;
|
||||
}
|
||||
|
||||
public function getCountStatistics(\DateTime $from = null, \DateTime $to = null)
|
||||
{
|
||||
$from = null === $from ? new \DateTime('1 year ago') : $from;
|
||||
$to = null === $to ? new \DateTime() : $to;
|
||||
|
||||
return Enumerable::from($this->findBetweenDates($from, $to))
|
||||
->groupBy(function ($order) {
|
||||
return $order->getCreatedAt()->format('m');
|
||||
}, null, function ($orders) {
|
||||
return Enumerable::from($orders)->count();
|
||||
})
|
||||
->toValues()
|
||||
->toArray()
|
||||
;
|
||||
}
|
||||
|
||||
public function findBetweenDates(\DateTime $from, \DateTime $to)
|
||||
{
|
||||
$queryBuilder = $this->getCollectionQueryBuilderBetweenDates($from, $to);
|
||||
$queryBuilder = $this->getCollectionQueryBuilderBetweenDates($from, $to, $state);
|
||||
|
||||
return $queryBuilder
|
||||
->getQuery()
|
||||
|
|
@ -209,13 +174,7 @@ class OrderRepository extends CartRepository
|
|||
|
||||
public function countBetweenDates(\DateTime $from, \DateTime $to, $state = null)
|
||||
{
|
||||
$queryBuilder = $this->getCollectionQueryBuilderBetweenDates($from, $to);
|
||||
if (null !== $state) {
|
||||
$queryBuilder
|
||||
->andWhere('o.state = :state')
|
||||
->setParameter('state', $state)
|
||||
;
|
||||
}
|
||||
$queryBuilder = $this->getCollectionQueryBuilderBetweenDates($from, $to, $state);
|
||||
|
||||
return $queryBuilder
|
||||
->select('count(o.id)')
|
||||
|
|
@ -226,13 +185,7 @@ class OrderRepository extends CartRepository
|
|||
|
||||
public function revenueBetweenDates(\DateTime $from, \DateTime $to, $state = null)
|
||||
{
|
||||
$queryBuilder = $this->getCollectionQueryBuilderBetweenDates($from, $to);
|
||||
if (null !== $state) {
|
||||
$queryBuilder
|
||||
->andWhere('o.state = :state')
|
||||
->setParameter('state', $state)
|
||||
;
|
||||
}
|
||||
$queryBuilder = $this->getCollectionQueryBuilderBetweenDates($from, $to, $state);
|
||||
|
||||
return $queryBuilder
|
||||
->select('sum(o.total)')
|
||||
|
|
@ -241,9 +194,15 @@ class OrderRepository extends CartRepository
|
|||
;
|
||||
}
|
||||
|
||||
protected function getCollectionQueryBuilderBetweenDates(\DateTime $from, \DateTime $to)
|
||||
protected function getCollectionQueryBuilderBetweenDates(\DateTime $from, \DateTime $to, $state = null)
|
||||
{
|
||||
$queryBuilder = $this->getCollectionQueryBuilder();
|
||||
if (null !== $state) {
|
||||
$queryBuilder
|
||||
->andWhere('o.state = :state')
|
||||
->setParameter('state', $state)
|
||||
;
|
||||
}
|
||||
|
||||
return $queryBuilder
|
||||
->andWhere($queryBuilder->expr()->gte('o.createdAt', ':from'))
|
||||
|
|
|
|||
|
|
@ -39,7 +39,6 @@
|
|||
"sylius/payments-bundle": "1.0.*@dev",
|
||||
"sylius/flow-bundle": "1.0.*@dev",
|
||||
"sylius/resource-bundle": "1.0.*@dev",
|
||||
"athari/yalinqo": "*@dev",
|
||||
"friendsofsymfony/user-bundle": "2.0.*@dev",
|
||||
"jms/serializer-bundle": "0.12.*",
|
||||
"knplabs/gaufrette": "0.2.*@dev",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue