Skip to content

Commit

Permalink
Merge pull request #233 from Netimage/more-new-features
Browse files Browse the repository at this point in the history
More new features
  • Loading branch information
bitbager authored Feb 20, 2019
2 parents a09c029 + b66967a commit 265d88c
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 2 deletions.
15 changes: 15 additions & 0 deletions src/Repository/PageRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,21 @@ public function createShopListQueryBuilder(string $sectionCode, string $channelC
;
}

public function findBySectionCode(string $sectionCode, ?string $localeCode): array
{
return $this->createQueryBuilder('o')
->leftJoin('o.translations', 'translation')
->innerJoin('o.sections', 'section')
->where('translation.locale = :localeCode')
->andWhere('section.code = :sectionCode')
->andWhere('o.enabled = true')
->setParameter('sectionCode', $sectionCode)
->setParameter('localeCode', $localeCode)
->getQuery()
->getResult()
;
}

public function findByProduct(ProductInterface $product, string $channelCode): array
{
return $this->createQueryBuilder('o')
Expand Down
2 changes: 2 additions & 0 deletions src/Repository/PageRepositoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ public function findOneEnabledBySlugAndChannelCode(

public function createShopListQueryBuilder(string $sectionCode, string $channelCode): QueryBuilder;

public function findBySectionCode(string $sectionCode, ?string $localeCode): array;

public function findByProduct(ProductInterface $product, string $channelCode): array;

public function findByProductAndSectionCode(ProductInterface $product, string $sectionCode, string $channelCode): array;
Expand Down
13 changes: 13 additions & 0 deletions src/Repository/SectionRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,17 @@ public function findOneByCode(string $code, ?string $localeCode): ?SectionInterf
->getOneOrNullResult()
;
}

public function findByCodesAndLocale(string $codes, string $localeCode): array
{
return $this->createQueryBuilder('o')
->leftJoin('o.translations', 'translation')
->where('translation.locale = :localeCode')
->andWhere('o.code IN(:codes)')
->setParameter('codes', explode(',', $codes))
->setParameter('localeCode', $localeCode)
->getQuery()
->getResult()
;
}
}
2 changes: 2 additions & 0 deletions src/Repository/SectionRepositoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@ public function createListQueryBuilder(string $localeCode): QueryBuilder;
public function findByNamePart(string $phrase, ?string $locale = null): array;

public function findOneByCode(string $code, ?string $localeCode): ?SectionInterface;

public function findByCodesAndLocale(string $codes, string $localeCode): array;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ BitBag\SyliusCmsPlugin\Entity\FrequentlyAskedQuestionTranslation:
fields:
question:
column: question
type: string
length: 1500
type: text
nullable: false
answer:
column: answer
Expand Down
30 changes: 30 additions & 0 deletions src/Resources/config/routing/shop/page.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,33 @@ bitbag_sylius_cms_plugin_shop_page_index_by_section_code:
_sylius:
template: "@BitBagSyliusCmsPlugin/Shop/Page/index.html.twig"
grid: bitbag_sylius_cms_plugin_shop_page
repository:
method: findBySectionCode
arguments:
- $sectionCode
- "expr:service('sylius.context.locale').getLocaleCode()"
-
bitbag_sylius_cms_plugin_shop_page_index_by_section_code_no_grid:
path: /pages/{sectionCode}/no-grid
methods: [GET]
defaults:
_controller: bitbag_sylius_cms_plugin.controller.page:indexAction
_sylius:
template: "@BitBagSyliusCmsPlugin/Shop/Page/index.html.twig"
repository:
method: findBySectionCode
arguments:
- $sectionCode
- "expr:service('sylius.context.locale').getLocaleCode()"

bitbag_sylius_cms_plugin_shop_page_index_by_section_code_template:
path: /pages-template/{sectionCode}
defaults:
_controller: bitbag_sylius_cms_plugin.controller.page:indexAction
_sylius:
template: $template
repository:
method: findBySectionCode
arguments:
- $sectionCode
- "expr:service('sylius.context.locale').getLocaleCode()"
14 changes: 14 additions & 0 deletions src/Resources/config/routing/shop/section.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,17 @@ bitbag_sylius_cms_plugin_shop_section_show:
arguments:
- $code
- "expr:service('sylius.context.locale').getLocaleCode()"

bitbag_sylius_cms_plugin_shop_section_show_codes:
path: /sections/{codes}
methods: [GET]
defaults:
_controller: bitbag_sylius_cms_plugin.controller.section:indexAction
_sylius:
template: $template
repository:
method: findByCodesAndLocale
arguments:
- $codes
- "expr:service('sylius.context.locale').getLocaleCode()"

0 comments on commit 265d88c

Please sign in to comment.