mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 17:10:53 +00:00
[DQL] Change hardcoded enabled value to parameter in where statements
This commit is contained in:
parent
7d299ef84f
commit
bcc12ba2b6
5 changed files with 18 additions and 9 deletions
|
|
@ -35,7 +35,7 @@ Your extending repository class should look like that:
|
|||
{
|
||||
return $this->createQueryBuilder('o')
|
||||
->innerJoin('o.channels', 'channel')
|
||||
->andWhere('o.enabled = true')
|
||||
->andWhere('o.enabled = :enabled')
|
||||
->andWhere('channel = :channel')
|
||||
->innerJoin('o.productTaxons', 'productTaxons')
|
||||
->addOrderBy('productTaxons.position', 'asc')
|
||||
|
|
@ -43,6 +43,7 @@ Your extending repository class should look like that:
|
|||
->andWhere('taxon.code = :code')
|
||||
->setParameter('code', $code)
|
||||
->setParameter('channel', $channel)
|
||||
->setParameter('enabled', true)
|
||||
->setMaxResults($count)
|
||||
->getQuery()
|
||||
->getResult();
|
||||
|
|
|
|||
|
|
@ -32,9 +32,10 @@ class PaymentMethodRepository extends BasePaymentMethodRepository implements Pay
|
|||
public function findEnabledForChannel(ChannelInterface $channel): array
|
||||
{
|
||||
return $this->createQueryBuilder('o')
|
||||
->andWhere('o.enabled = true')
|
||||
->andWhere('o.enabled = :enabled')
|
||||
->andWhere(':channel MEMBER OF o.channels')
|
||||
->setParameter('channel', $channel)
|
||||
->setParameter('enabled', true)
|
||||
->addOrderBy('o.position')
|
||||
->getQuery()
|
||||
->getResult()
|
||||
|
|
|
|||
|
|
@ -87,9 +87,10 @@ class ProductRepository extends BaseProductRepository implements ProductReposito
|
|||
|
||||
$queryBuilder
|
||||
->andWhere(':channel MEMBER OF o.channels')
|
||||
->andWhere('o.enabled = true')
|
||||
->andWhere('o.enabled = :enabled')
|
||||
->setParameter('locale', $locale)
|
||||
->setParameter('channel', $channel)
|
||||
->setParameter('enabled', true)
|
||||
;
|
||||
|
||||
// Grid hack, we do not need to join these if we don't sort by price
|
||||
|
|
@ -128,10 +129,11 @@ class ProductRepository extends BaseProductRepository implements ProductReposito
|
|||
->addSelect('translation')
|
||||
->innerJoin('o.translations', 'translation', 'WITH', 'translation.locale = :locale')
|
||||
->andWhere(':channel MEMBER OF o.channels')
|
||||
->andWhere('o.enabled = true')
|
||||
->andWhere('o.enabled = :enabled')
|
||||
->addOrderBy('o.createdAt', 'DESC')
|
||||
->setParameter('channel', $channel)
|
||||
->setParameter('locale', $locale)
|
||||
->setParameter('enabled', true)
|
||||
->setMaxResults($count)
|
||||
->getQuery()
|
||||
->getResult()
|
||||
|
|
@ -145,10 +147,11 @@ class ProductRepository extends BaseProductRepository implements ProductReposito
|
|||
->innerJoin('o.translations', 'translation', 'WITH', 'translation.locale = :locale')
|
||||
->andWhere('translation.slug = :slug')
|
||||
->andWhere(':channel MEMBER OF o.channels')
|
||||
->andWhere('o.enabled = true')
|
||||
->andWhere('o.enabled = :enabled')
|
||||
->setParameter('channel', $channel)
|
||||
->setParameter('locale', $locale)
|
||||
->setParameter('slug', $slug)
|
||||
->setParameter('enabled', true)
|
||||
->getQuery()
|
||||
->getOneOrNullResult()
|
||||
;
|
||||
|
|
@ -171,9 +174,10 @@ class ProductRepository extends BaseProductRepository implements ProductReposito
|
|||
$product = $this->createQueryBuilder('o')
|
||||
->where('o.code = :code')
|
||||
->andWhere(':channel MEMBER OF o.channels')
|
||||
->andWhere('o.enabled = true')
|
||||
->andWhere('o.enabled = :enabled')
|
||||
->setParameter('channel', $channel)
|
||||
->setParameter('code', $code)
|
||||
->setParameter('enabled', true)
|
||||
->getQuery()
|
||||
->getOneOrNullResult()
|
||||
;
|
||||
|
|
|
|||
|
|
@ -50,10 +50,11 @@ class ShippingMethodRepository extends BaseShippingMethodRepository implements S
|
|||
protected function createEnabledForChannelQueryBuilder(ChannelInterface $channel): QueryBuilder
|
||||
{
|
||||
return $this->createQueryBuilder('o')
|
||||
->andWhere('o.enabled = true')
|
||||
->andWhere('o.enabled = :enabled')
|
||||
->andWhere('o.archivedAt IS NULL')
|
||||
->andWhere(':channel MEMBER OF o.channels')
|
||||
->setParameter('channel', $channel)
|
||||
->setParameter('enabled', true)
|
||||
;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,10 +40,11 @@ class TaxonRepository extends EntityRepository implements TaxonRepositoryInterfa
|
|||
->addSelect('child')
|
||||
->innerJoin('o.parent', 'parent')
|
||||
->leftJoin('o.children', 'child')
|
||||
->andWhere('o.enabled = true')
|
||||
->andWhere('o.enabled = :enabled')
|
||||
->andWhere('parent.code = :parentCode')
|
||||
->addOrderBy('o.position')
|
||||
->setParameter('parentCode', ($menuTaxon !== null) ? $menuTaxon->getCode() : 'category')
|
||||
->setParameter('enabled', true)
|
||||
->getQuery()
|
||||
->getResult()
|
||||
;
|
||||
|
|
@ -54,11 +55,12 @@ class TaxonRepository extends EntityRepository implements TaxonRepositoryInterfa
|
|||
return $this->createQueryBuilder('o')
|
||||
->addSelect('translation')
|
||||
->innerJoin('o.translations', 'translation')
|
||||
->andWhere('o.enabled = true')
|
||||
->andWhere('o.enabled = :enabled')
|
||||
->andWhere('translation.slug = :slug')
|
||||
->andWhere('translation.locale = :locale')
|
||||
->setParameter('slug', $slug)
|
||||
->setParameter('locale', $locale)
|
||||
->setParameter('enabled', true)
|
||||
->getQuery()
|
||||
->getOneOrNullResult()
|
||||
;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue