diff --git a/etc/build/.gitkeep b/etc/build/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/features/admin/adding_block.feature b/features/admin/adding_block.feature index 0b15eb814..b133db9c3 100644 --- a/features/admin/adding_block.feature +++ b/features/admin/adding_block.feature @@ -17,11 +17,11 @@ Feature: Adding blocks Then I should be notified that the block has been created @ui @javascript - Scenario: Adding block with sections - Given there are existing sections named "Blog" and "Homepage" + Scenario: Adding block with collections + Given there are existing collections named "Blog" and "Homepage" When I go to the create block page And I fill the code with "intro" - And I add "Blog" and "Homepage" sections to it + And I add "Blog" and "Homepage" collections to it And I fill the content with "Hello world!" And I add it Then I should be notified that the block has been created diff --git a/features/admin/adding_section.feature b/features/admin/adding_collection.feature similarity index 53% rename from features/admin/adding_section.feature rename to features/admin/adding_collection.feature index 142cabcf7..6001473c2 100644 --- a/features/admin/adding_section.feature +++ b/features/admin/adding_collection.feature @@ -1,45 +1,45 @@ -@managing_sections -Feature: Adding new section +@managing_collections +Feature: Adding new collection In order to present more sophisticated content As an Administrator - I want to be able to add new CMS sections to the store + I want to be able to add new CMS collections to the store Background: Given the store operates on a single channel in "United States" And I am logged in as an administrator @ui - Scenario: Adding new section - When I go to the create section page + Scenario: Adding new collection + When I go to the create collection page And I fill the code with "blog" And I fill the name with "Blog" And I add it - Then I should be notified that new section has been created + Then I should be notified that new collection has been created @ui - Scenario: Trying to add a section with an existing code - Given there is an existing section with "blog" code - When I go to the create section page + Scenario: Trying to add a collection with an existing code + Given there is an existing collection with "blog" code + When I go to the create collection page And I fill the code with "blog" And I try to add it - Then I should be notified that there is already an existing section with provided code + Then I should be notified that there is already an existing collection with provided code @ui - Scenario: Trying to add section with blank data - When I go to the create section page + Scenario: Trying to add collection with blank data + When I go to the create collection page And I try to add it Then I should be notified that "Code, Name" fields cannot be blank @ui - Scenario: Trying to add section with too short data - When I go to the create section page + Scenario: Trying to add collection with too short data + When I go to the create collection page And I fill "Code, Name" fields with 1 character And I try to add it Then I should be notified that "Code, Name" fields are too short @ui - Scenario: Trying to add section with too long data - When I go to the create section page + Scenario: Trying to add collection with too long data + When I go to the create collection page And I fill "Code, Name" fields with 251 characters And I try to add it Then I should be notified that "Code, Name" fields are too long diff --git a/features/admin/adding_page.feature b/features/admin/adding_page.feature index 042a1962c..4657175a7 100644 --- a/features/admin/adding_page.feature +++ b/features/admin/adding_page.feature @@ -74,10 +74,10 @@ Feature: Adding new page @ui @javascript Scenario: Adding page with sections - Given there are existing sections named "Blog" and "Homepage" + Given there are existing collections named "Blog" and "Homepage" When I go to the create page page And I fill the code with "best_day_ever" - And I add "Blog" and "Homepage" sections to it + And I add "Blog" and "Homepage" collections to it And I fill the slug with "Slug" And I fill the name with "Best day ever" And I fill the content with "This was the best day of my life" diff --git a/features/admin/managing_collections.feature b/features/admin/managing_collections.feature new file mode 100644 index 000000000..45f15b18f --- /dev/null +++ b/features/admin/managing_collections.feature @@ -0,0 +1,23 @@ +@managing_collections +Feature: Managing collections + In order to present the content in specific collections in my store + As an Administrator + I want to be able to edit and remove existing collections + + Background: + Given the store operates on a single channel in "United States" + Given I am logged in as an administrator + + @ui + Scenario: Deleting collection + Given there is a collection in the store + When I go to the collections page + And I delete this collection + Then I should be notified that the collection has been deleted + And I should see empty list of collections + + @ui + Scenario: Seeing disabled code field while editing a collection + Given there is a collection in the store + When I want to edit this collection + Then the code field should be disabled diff --git a/features/admin/managing_sections.feature b/features/admin/managing_sections.feature deleted file mode 100644 index ae881ce0b..000000000 --- a/features/admin/managing_sections.feature +++ /dev/null @@ -1,23 +0,0 @@ -@managing_sections -Feature: Managing sections - In order to present the content in specific sections in my store - As an Administrator - I want to be able to edit and remove existing sections - - Background: - Given the store operates on a single channel in "United States" - Given I am logged in as an administrator - - @ui - Scenario: Deleting section - Given there is a section in the store - When I go to the sections page - And I delete this section - Then I should be notified that the section has been deleted - And I should see empty list of sections - - @ui - Scenario: Seeing disabled code field while editing a section - Given there is a section in the store - When I want to edit this section - Then the code field should be disabled diff --git a/features/api/viewing_collections.feature b/features/api/viewing_collections.feature new file mode 100644 index 000000000..f3ab234ea --- /dev/null +++ b/features/api/viewing_collections.feature @@ -0,0 +1,21 @@ +@shop_collections +Feature: Getting data from cms collections + In order to present dynamic content in my store + As an API user + I want to be able to display collections + + Background: + Given the store operates on a single channel in "United States" + And there is a collection in the store + And there is an existing collection with "collection-1" code + + @api + Scenario: Browsing collections + Given I want to browse collections + Then I should see 2 collections in the list + And I should see collection with code "collection-1" + + @api + Scenario: Displaying collection + Given I view collection with code "collection-1" + Then I should see collection name diff --git a/features/api/viewing_pages.feature b/features/api/viewing_pages.feature index 7eb5c23d3..10b6720e9 100644 --- a/features/api/viewing_pages.feature +++ b/features/api/viewing_pages.feature @@ -10,8 +10,8 @@ Feature: Getting data from cms pages And the store has "iPhone 8" and "iPhone X" products And there is a page in the store And this page has these products associated with it - And there are existing sections named "Blog" and "General" - And this page has these sections associated with it + And there are existing collections named "Blog" and "General" + And this page has these collections associated with it And this page has "About us" name And this page has "about" code And this page also has "about-us" slug diff --git a/features/api/viewing_sections.feature b/features/api/viewing_sections.feature deleted file mode 100644 index 9362fb35b..000000000 --- a/features/api/viewing_sections.feature +++ /dev/null @@ -1,21 +0,0 @@ -@shop_sections -Feature: Getting data from cms sections - In order to present dynamic content in my store - As an API user - I want to be able to display sections - - Background: - Given the store operates on a single channel in "United States" - And there is a section in the store - And there is an existing section with "section-1" code - - @api - Scenario: Browsing sections - Given I want to browse sections - Then I should see 2 sections in the list - And I should see section with code "section-1" - - @api - Scenario: Displaying section - Given I view section with code "section-1" - Then I should see section name diff --git a/features/shop/browsing_pages_by_section.feature b/features/shop/browsing_pages_by_section.feature index 8672b3971..cbd2e7cd8 100644 --- a/features/shop/browsing_pages_by_section.feature +++ b/features/shop/browsing_pages_by_section.feature @@ -1,16 +1,16 @@ @shop_pages -Feature: Browsing pages by section +Feature: Browsing pages by collection In order to read content like articles or blog posts As a Customer - I want to browse pages by specific sections + I want to browse pages by specific collections Background: Given the store operates on a single channel in "United States" @ui - Scenario: Browsing pages by section - Given there is a "Blog" section in the store + Scenario: Browsing pages by collection + Given there is a "Blog" collection in the store And there are 15 pages in the store - And these pages have this section associated with it - When I go to the section pages list for the "blog" section + And these pages have this collection associated with it + When I go to the collection pages list for the "blog" collection Then I should see 10 pages on the page diff --git a/features/shop/displaying_page.feature b/features/shop/displaying_page.feature index 2edb83b53..84ea5153e 100644 --- a/features/shop/displaying_page.feature +++ b/features/shop/displaying_page.feature @@ -12,8 +12,8 @@ Feature: Displaying pages Given there is a page in the store And the store has "iPhone 8" and "iPhone X" products And this page has these products associated with it - And there are existing sections named "Blog" and "General" - And this page has these sections associated with it + And there are existing collections named "Blog" and "General" + And this page has these collections associated with it And this page has "About us" name And this page also has "about-us" slug And this page also has "Lorem ipsum" content @@ -21,7 +21,7 @@ Feature: Displaying pages Then I should see a page with "About us" name And I should also see "Lorem ipsum" content And I should also see "iPhone 8" and "iPhone X" products associated with this page - And I should also see "Blog" and "General" sections associated with this page + And I should also see "Blog" and "General" collections associated with this page @ui Scenario: Displaying page link @@ -36,8 +36,8 @@ Feature: Displaying pages Given there is a page in the store And the store has "iPhone 8" and "iPhone X" products And this page has these products associated with it - And there are existing sections named "Blog" and "General" - And this page has these sections associated with it + And there are existing collections named "Blog" and "General" + And this page has these collections associated with it And this page has "About us" name And this page also has "about-us" slug And this page also has "Lorem ipsum" content @@ -46,7 +46,7 @@ Feature: Displaying pages Then I should see a page with "About us" name And I should also see "Lorem ipsum" content And I should also see "iPhone 8" and "iPhone X" products associated with this page - And I should also see "Blog" and "General" sections associated with this page + And I should also see "Blog" and "General" collections associated with this page And I should also see page image @ui @javascript @title diff --git a/spec/Assigner/CollectionsAssignerSpec.php b/spec/Assigner/CollectionsAssignerSpec.php new file mode 100644 index 000000000..898ad2de7 --- /dev/null +++ b/spec/Assigner/CollectionsAssignerSpec.php @@ -0,0 +1,52 @@ +beConstructedWith($collectionRepository); + } + + public function it_is_initializable(): void + { + $this->shouldHaveType(CollectionsAssigner::class); + } + + public function it_implements_collections_assigner_interface(): void + { + $this->shouldHaveType(CollectionsAssignerInterface::class); + } + + public function it_assigns_collections( + CollectionRepositoryInterface $collectionRepository, + CollectionInterface $aboutCollection, + CollectionInterface $blogCollection, + CollectibleInterface $collectionsAware + ): void + { + $collectionRepository->findOneBy(['code' => 'about'])->willReturn($aboutCollection); + $collectionRepository->findOneBy(['code' => 'blog'])->willReturn($blogCollection); + + $collectionsAware->addCollection($aboutCollection)->shouldBeCalled(); + $collectionsAware->addCollection($blogCollection)->shouldBeCalled(); + + $this->assign($collectionsAware, ['about', 'blog']); + } +} diff --git a/spec/Assigner/SectionsAssignerSpec.php b/spec/Assigner/SectionsAssignerSpec.php deleted file mode 100644 index 1f26784cd..000000000 --- a/spec/Assigner/SectionsAssignerSpec.php +++ /dev/null @@ -1,45 +0,0 @@ -beConstructedWith($sectionRepository); - } - - public function it_is_initializable(): void - { - $this->shouldHaveType(SectionsAssigner::class); - } - - public function it_implements_sections_assigner_interface(): void - { - $this->shouldHaveType(SectionsAssignerInterface::class); - } - - public function it_assigns_sections( - SectionRepositoryInterface $sectionRepository, - SectionInterface $aboutSection, - SectionInterface $blogSection, - SectionableInterface $sectionsAware - ): void { - $sectionRepository->findOneBy(['code' => 'about'])->willReturn($aboutSection); - $sectionRepository->findOneBy(['code' => 'blog'])->willReturn($blogSection); - - $sectionsAware->addSection($aboutSection)->shouldBeCalled(); - $sectionsAware->addSection($blogSection)->shouldBeCalled(); - - $this->assign($sectionsAware, ['about', 'blog']); - } -} diff --git a/spec/Entity/BlockSpec.php b/spec/Entity/BlockSpec.php index 782b9f5e0..988f87756 100755 --- a/spec/Entity/BlockSpec.php +++ b/spec/Entity/BlockSpec.php @@ -12,7 +12,7 @@ use BitBag\SyliusCmsPlugin\Entity\Block; use BitBag\SyliusCmsPlugin\Entity\BlockInterface; -use BitBag\SyliusCmsPlugin\Entity\SectionInterface; +use BitBag\SyliusCmsPlugin\Entity\CollectionInterface; use PhpSpec\ObjectBehavior; use Sylius\Component\Core\Model\ChannelInterface; use Sylius\Component\Core\Model\ProductInterface; @@ -57,16 +57,16 @@ public function it_associates_products(ProductInterface $firstProduct, ProductIn $this->hasProduct($firstProduct)->shouldReturn(false); } - public function it_associates_sections(SectionInterface $firstSection, SectionInterface $secondSection): void + public function it_associates_collections(CollectionInterface $firstCollection, CollectionInterface $secondCollection): void { - $this->addSection($firstSection); - $this->hasSection($firstSection)->shouldReturn(true); + $this->addCollection($firstCollection); + $this->hasCollection($firstCollection)->shouldReturn(true); - $this->hasSection($secondSection)->shouldReturn(false); + $this->hasCollection($secondCollection)->shouldReturn(false); - $this->removeSection($firstSection); + $this->removeCollection($firstCollection); - $this->hasSection($firstSection)->shouldReturn(false); + $this->hasCollection($firstCollection)->shouldReturn(false); } public function it_associates_channels(ChannelInterface $firstChannel, ChannelInterface $secondChannel): void diff --git a/spec/Entity/SectionSpec.php b/spec/Entity/CollectionSpec.php similarity index 71% rename from spec/Entity/SectionSpec.php rename to spec/Entity/CollectionSpec.php index 99930c980..fff615fe4 100755 --- a/spec/Entity/SectionSpec.php +++ b/spec/Entity/CollectionSpec.php @@ -10,16 +10,16 @@ namespace spec\BitBag\SyliusCmsPlugin\Entity; -use BitBag\SyliusCmsPlugin\Entity\Section; -use BitBag\SyliusCmsPlugin\Entity\SectionInterface; +use BitBag\SyliusCmsPlugin\Entity\Collection; +use BitBag\SyliusCmsPlugin\Entity\CollectionInterface; use PhpSpec\ObjectBehavior; use Sylius\Component\Resource\Model\ResourceInterface; -final class SectionSpec extends ObjectBehavior +final class CollectionSpec extends ObjectBehavior { public function it_is_initializable(): void { - $this->shouldHaveType(Section::class); + $this->shouldHaveType(Collection::class); } public function it_is_a_resource(): void @@ -27,9 +27,9 @@ public function it_is_a_resource(): void $this->shouldHaveType(ResourceInterface::class); } - public function it_implements_section_interface(): void + public function it_implements_collection_interface(): void { - $this->shouldHaveType(SectionInterface::class); + $this->shouldHaveType(CollectionInterface::class); } public function it_allows_access_via_properties(): void diff --git a/spec/Entity/SectionTranslationSpec.php b/spec/Entity/CollectionTranslationSpec.php similarity index 76% rename from spec/Entity/SectionTranslationSpec.php rename to spec/Entity/CollectionTranslationSpec.php index ea503732c..ff6d3af63 100755 --- a/spec/Entity/SectionTranslationSpec.php +++ b/spec/Entity/CollectionTranslationSpec.php @@ -10,17 +10,17 @@ namespace spec\BitBag\SyliusCmsPlugin\Entity; -use BitBag\SyliusCmsPlugin\Entity\SectionTranslation; -use BitBag\SyliusCmsPlugin\Entity\SectionTranslationInterface; +use BitBag\SyliusCmsPlugin\Entity\CollectionTranslation; +use BitBag\SyliusCmsPlugin\Entity\CollectionTranslationInterface; use PhpSpec\ObjectBehavior; use Sylius\Component\Resource\Model\ResourceInterface; use Sylius\Component\Resource\Model\TranslationInterface; -final class SectionTranslationSpec extends ObjectBehavior +final class CollectionTranslationSpec extends ObjectBehavior { public function it_is_initializable() { - $this->shouldHaveType(SectionTranslation::class); + $this->shouldHaveType(CollectionTranslation::class); } public function it_is_a_resource() @@ -30,7 +30,7 @@ public function it_is_a_resource() public function it_implements_frequently_asked_question_translation_interface() { - $this->shouldHaveType(SectionTranslationInterface::class); + $this->shouldHaveType(CollectionTranslationInterface::class); $this->shouldHaveType(TranslationInterface::class); } diff --git a/spec/Entity/MediaSpec.php b/spec/Entity/MediaSpec.php index 7ff608c2d..1383fe8e3 100755 --- a/spec/Entity/MediaSpec.php +++ b/spec/Entity/MediaSpec.php @@ -12,7 +12,7 @@ use BitBag\SyliusCmsPlugin\Entity\Media; use BitBag\SyliusCmsPlugin\Entity\MediaInterface; -use BitBag\SyliusCmsPlugin\Entity\SectionInterface; +use BitBag\SyliusCmsPlugin\Entity\CollectionInterface; use PhpSpec\ObjectBehavior; use Sylius\Component\Core\Model\ChannelInterface; use Sylius\Component\Core\Model\ProductInterface; @@ -77,16 +77,16 @@ public function it_associates_products(ProductInterface $firstProduct, ProductIn $this->hasProduct($firstProduct)->shouldReturn(false); } - public function it_associates_sections(SectionInterface $firstSection, SectionInterface $secondSection): void + public function it_associates_collections(CollectionInterface $firstCollection, CollectionInterface $secondCollection): void { - $this->addSection($firstSection); - $this->hasSection($firstSection)->shouldReturn(true); + $this->addCollection($firstCollection); + $this->hasCollection($firstCollection)->shouldReturn(true); - $this->hasSection($secondSection)->shouldReturn(false); + $this->hasCollection($secondCollection)->shouldReturn(false); - $this->removeSection($firstSection); + $this->removeCollection($firstCollection); - $this->hasSection($firstSection)->shouldReturn(false); + $this->hasCollection($firstCollection)->shouldReturn(false); } public function it_associates_channels(ChannelInterface $firstChannel, ChannelInterface $secondChannel): void diff --git a/spec/Entity/PageSpec.php b/spec/Entity/PageSpec.php index 0618b8c9b..967d19c53 100755 --- a/spec/Entity/PageSpec.php +++ b/spec/Entity/PageSpec.php @@ -12,7 +12,7 @@ use BitBag\SyliusCmsPlugin\Entity\Page; use BitBag\SyliusCmsPlugin\Entity\PageInterface; -use BitBag\SyliusCmsPlugin\Entity\SectionInterface; +use BitBag\SyliusCmsPlugin\Entity\CollectionInterface; use PhpSpec\ObjectBehavior; use Sylius\Component\Core\Model\ChannelInterface; use Sylius\Component\Core\Model\ProductInterface; @@ -62,16 +62,16 @@ public function it_associates_products(ProductInterface $firstProduct, ProductIn $this->hasProduct($firstProduct)->shouldReturn(false); } - public function it_associates_sections(SectionInterface $firstSection, SectionInterface $secondSection): void + public function it_associates_collections(CollectionInterface $firstCollection, CollectionInterface $secondCollection): void { - $this->addSection($firstSection); - $this->hasSection($firstSection)->shouldReturn(true); + $this->addCollection($firstCollection); + $this->hasCollection($firstCollection)->shouldReturn(true); - $this->hasSection($secondSection)->shouldReturn(false); + $this->hasCollection($secondCollection)->shouldReturn(false); - $this->removeSection($firstSection); + $this->removeCollection($firstCollection); - $this->hasSection($firstSection)->shouldReturn(false); + $this->hasCollection($firstCollection)->shouldReturn(false); } public function it_associates_channels(ChannelInterface $firstChannel, ChannelInterface $secondChannel): void diff --git a/spec/Importer/BlockImporterSpec.php b/spec/Importer/BlockImporterSpec.php index 8801d74c7..a5d5a3687 100644 --- a/spec/Importer/BlockImporterSpec.php +++ b/spec/Importer/BlockImporterSpec.php @@ -14,7 +14,7 @@ use BitBag\SyliusCmsPlugin\Repository\BlockRepositoryInterface; use BitBag\SyliusCmsPlugin\Resolver\ImporterChannelsResolverInterface; use BitBag\SyliusCmsPlugin\Resolver\ImporterProductsResolverInterface; -use BitBag\SyliusCmsPlugin\Resolver\ImporterSectionsResolverInterface; +use BitBag\SyliusCmsPlugin\Resolver\ImporterCollectionsResolverInterface; use BitBag\SyliusCmsPlugin\Resolver\ResourceResolverInterface; use PhpSpec\ObjectBehavior; use Sylius\Component\Locale\Context\LocaleContextInterface; @@ -26,7 +26,7 @@ final class BlockImporterSpec extends ObjectBehavior public function let( ResourceResolverInterface $blockResourceResolver, LocaleContextInterface $localeContext, - ImporterSectionsResolverInterface $importerSectionsResolver, + ImporterCollectionsResolverInterface $importerCollectionsResolver, ImporterChannelsResolverInterface $importerChannelsResolver, ImporterProductsResolverInterface $importerProductsResolver, ValidatorInterface $validator, @@ -35,7 +35,7 @@ public function let( $this->beConstructedWith( $blockResourceResolver, $localeContext, - $importerSectionsResolver, + $importerCollectionsResolver, $importerChannelsResolver, $importerProductsResolver, $validator, @@ -52,13 +52,14 @@ public function it_is_initializable() public function it_imports_block( ResourceResolverInterface $blockResourceResolver, LocaleContextInterface $localeContext, - ImporterSectionsResolverInterface $importerSectionsResolver, + ImporterCollectionsResolverInterface $importerCollectionsResolver, ImporterChannelsResolverInterface $importerChannelsResolver, ImporterProductsResolverInterface $importerProductsResolver, ValidatorInterface $validator, BlockRepositoryInterface $blockRepository, BlockInterface $block - ) { + ) + { $row = ['name_pl' => 'name', 'content_pl' => 'content', 'link_pl' => 'link', 'code' => 'block_code']; $blockResourceResolver->getResource('block_code')->willReturn($block); @@ -72,7 +73,7 @@ public function it_imports_block( $block->setLink('link')->shouldBeCalled(); $block->setContent('content')->shouldBeCalled(); - $importerSectionsResolver->resolve($block, null)->shouldBeCalled(); + $importerCollectionsResolver->resolve($block, null)->shouldBeCalled(); $importerChannelsResolver->resolve($block, null)->shouldBeCalled(); $importerProductsResolver->resolve($block, null)->shouldBeCalled(); diff --git a/spec/Importer/MediaImporterSpec.php b/spec/Importer/MediaImporterSpec.php index 2b8171d85..6f65797ea 100644 --- a/spec/Importer/MediaImporterSpec.php +++ b/spec/Importer/MediaImporterSpec.php @@ -13,7 +13,7 @@ use BitBag\SyliusCmsPlugin\Entity\MediaInterface; use BitBag\SyliusCmsPlugin\Repository\MediaRepositoryInterface; use BitBag\SyliusCmsPlugin\Resolver\ImporterProductsResolverInterface; -use BitBag\SyliusCmsPlugin\Resolver\ImporterSectionsResolverInterface; +use BitBag\SyliusCmsPlugin\Resolver\ImporterCollectionsResolverInterface; use BitBag\SyliusCmsPlugin\Resolver\ResourceResolverInterface; use PhpSpec\ObjectBehavior; use Sylius\Component\Locale\Context\LocaleContextInterface; @@ -25,7 +25,7 @@ final class MediaImporterSpec extends ObjectBehavior public function let( ResourceResolverInterface $mediaResourceResolver, LocaleContextInterface $localeContext, - ImporterSectionsResolverInterface $importerSectionsResolver, + ImporterCollectionsResolverInterface $importerCollectionsResolver, ImporterProductsResolverInterface $importerProductsResolver, ValidatorInterface $validator, MediaRepositoryInterface $mediaRepository @@ -33,7 +33,7 @@ public function let( $this->beConstructedWith( $mediaResourceResolver, $localeContext, - $importerSectionsResolver, + $importerCollectionsResolver, $importerProductsResolver, $validator, $mediaRepository, @@ -49,12 +49,13 @@ public function it_is_initializable() public function it_imports_media( ResourceResolverInterface $mediaResourceResolver, LocaleContextInterface $localeContext, - ImporterSectionsResolverInterface $importerSectionsResolver, + ImporterCollectionsResolverInterface $importerCollectionsResolver, ImporterProductsResolverInterface $importerProductsResolver, ValidatorInterface $validator, MediaRepositoryInterface $mediaRepository, MediaInterface $media - ) { + ) + { $row = ['name_pl' => 'name', 'content_pl' => 'content', 'alt_pl' => 'alt', 'code' => 'media_code']; $mediaResourceResolver->getResource('media_code')->willReturn($media); @@ -68,7 +69,7 @@ public function it_imports_media( $media->setContent('content')->shouldBeCalled(); $media->setAlt('alt')->shouldBeCalled(); - $importerSectionsResolver->resolve($media, null)->shouldBeCalled(); + $importerCollectionsResolver->resolve($media, null)->shouldBeCalled(); $importerProductsResolver->resolve($media, null)->shouldBeCalled(); $validator->validate($media, null, ['bitbag'])->willReturn(new ConstraintViolationList()); diff --git a/spec/Importer/PageImporterSpec.php b/spec/Importer/PageImporterSpec.php index 2a014971d..0b150c71a 100644 --- a/spec/Importer/PageImporterSpec.php +++ b/spec/Importer/PageImporterSpec.php @@ -14,7 +14,7 @@ use BitBag\SyliusCmsPlugin\Entity\PageInterface; use BitBag\SyliusCmsPlugin\Resolver\ImporterChannelsResolverInterface; use BitBag\SyliusCmsPlugin\Resolver\ImporterProductsResolverInterface; -use BitBag\SyliusCmsPlugin\Resolver\ImporterSectionsResolverInterface; +use BitBag\SyliusCmsPlugin\Resolver\ImporterCollectionsResolverInterface; use BitBag\SyliusCmsPlugin\Resolver\MediaProviderResolverInterface; use BitBag\SyliusCmsPlugin\Resolver\ResourceResolverInterface; use Doctrine\ORM\EntityManagerInterface; @@ -32,7 +32,7 @@ public function let( ImageDownloaderInterface $imageDownloader, FactoryInterface $mediaFactory, MediaProviderResolverInterface $mediaProviderResolver, - ImporterSectionsResolverInterface $importerSectionsResolver, + ImporterCollectionsResolverInterface $importerCollectionsResolver, ImporterChannelsResolverInterface $importerChannelsResolver, ImporterProductsResolverInterface $importerProductsResolver, ValidatorInterface $validator, @@ -44,7 +44,7 @@ public function let( $imageDownloader, $mediaFactory, $mediaProviderResolver, - $importerSectionsResolver, + $importerCollectionsResolver, $importerChannelsResolver, $importerProductsResolver, $validator, @@ -61,13 +61,14 @@ public function it_is_initializable() public function it_imports_page_no_url( ResourceResolverInterface $pageResourceResolver, LocaleContextInterface $localeContext, - ImporterSectionsResolverInterface $importerSectionsResolver, + ImporterCollectionsResolverInterface $importerCollectionsResolver, ImporterChannelsResolverInterface $importerChannelsResolver, ImporterProductsResolverInterface $importerProductsResolver, ValidatorInterface $validator, EntityManagerInterface $entityManager, PageInterface $page, - ) { + ) + { $row = [ 'code' => 'page_code', 'slug_pl' => 'slug', @@ -80,7 +81,7 @@ public function it_imports_page_no_url( 'breadcrumb_pl' => 'breadcrumb', 'namewhenlinked_pl' => 'namewhenlinked', 'descriptionwhenlinked_pl' => 'descriptionwhenlinked', - 'sections' => 'sections', + 'collections' => 'collections', 'channels' => 'channels', 'products' => 'products', ]; @@ -103,7 +104,7 @@ public function it_imports_page_no_url( $page->setNameWhenLinked('namewhenlinked')->shouldBeCalled(); $page->setDescriptionWhenLinked('descriptionwhenlinked')->shouldBeCalled(); - $importerSectionsResolver->resolve($page, 'sections')->shouldBeCalled(); + $importerCollectionsResolver->resolve($page, 'collections')->shouldBeCalled(); $importerChannelsResolver->resolve($page, 'channels')->shouldBeCalled(); $importerProductsResolver->resolve($page, 'products')->shouldBeCalled(); diff --git a/spec/Menu/ContentManagementMenuBuilderSpec.php b/spec/Menu/ContentManagementMenuBuilderSpec.php index d5ab533dd..da1bf76e8 100755 --- a/spec/Menu/ContentManagementMenuBuilderSpec.php +++ b/spec/Menu/ContentManagementMenuBuilderSpec.php @@ -52,10 +52,10 @@ public function it_build_menu( $cmsRootMenuItem->setLabelAttribute('icon', 'help')->shouldBeCalled(); $cmsRootMenuItem - ->addChild('sections', ['route' => 'bitbag_sylius_cms_plugin_admin_section_index']) + ->addChild('collections', ['route' => 'bitbag_sylius_cms_plugin_admin_collection_index']) ->willReturn($cmsRootMenuItem) ; - $cmsRootMenuItem->setLabel('bitbag_sylius_cms_plugin.ui.sections')->willReturn($cmsRootMenuItem); + $cmsRootMenuItem->setLabel('bitbag_sylius_cms_plugin.ui.collections')->willReturn($cmsRootMenuItem); $cmsRootMenuItem->setLabelAttribute('icon', 'grid layout')->shouldBeCalled(); $cmsRootMenuItem diff --git a/spec/Resolver/ImporterCollectionsResolverSpec.php b/spec/Resolver/ImporterCollectionsResolverSpec.php new file mode 100644 index 000000000..50568efdb --- /dev/null +++ b/spec/Resolver/ImporterCollectionsResolverSpec.php @@ -0,0 +1,54 @@ +beConstructedWith($collectionsAssigner); + } + + public function it_is_initializable() + { + $this->shouldHaveType(ImporterCollectionsResolver::class); + } + + public function it_resolves_collections_for_collectionable_entity( + CollectionsAssignerInterface $collectionsAssigner, + CollectibleInterface $collectionable + ) { + $collectionsRow = 'collection1, collection2, collection3'; + $collectionsCodes = ['collection1', 'collection2', 'collection3']; + + $collectionsAssigner->assign($collectionable, $collectionsCodes)->shouldBeCalled(); + + $this->resolve($collectionable, $collectionsRow); + } + + public function it_skips_resolution_when_collections_row_is_null( + CollectionsAssignerInterface $collectionsAssigner, + CollectibleInterface $collectionable + ) + { + $collectionsRow = null; + + $collectionsAssigner->assign($collectionable, Argument::any())->shouldNotBeCalled(); + + $this->resolve($collectionable, $collectionsRow); + } +} diff --git a/spec/Resolver/ImporterSectionsResolverSpec.php b/spec/Resolver/ImporterSectionsResolverSpec.php deleted file mode 100644 index 83cc8dd11..000000000 --- a/spec/Resolver/ImporterSectionsResolverSpec.php +++ /dev/null @@ -1,53 +0,0 @@ -beConstructedWith($sectionsAssigner); - } - - public function it_is_initializable() - { - $this->shouldHaveType(ImporterSectionsResolver::class); - } - - public function it_resolves_sections_for_sectionable_entity( - SectionsAssignerInterface $sectionsAssigner, - SectionableInterface $sectionable - ) { - $sectionsRow = 'section1, section2, section3'; - $sectionCodes = ['section1', 'section2', 'section3']; - - $sectionsAssigner->assign($sectionable, $sectionCodes)->shouldBeCalled(); - - $this->resolve($sectionable, $sectionsRow); - } - - public function it_skips_resolution_when_sections_row_is_null( - SectionsAssignerInterface $sectionsAssigner, - SectionableInterface $sectionable - ) { - $sectionsRow = null; - - $sectionsAssigner->assign($sectionable, Argument::any())->shouldNotBeCalled(); - - $this->resolve($sectionable, $sectionsRow); - } -} diff --git a/spec/Sorter/CollectionsSorterSpec.php b/spec/Sorter/CollectionsSorterSpec.php new file mode 100644 index 000000000..2b0116db2 --- /dev/null +++ b/spec/Sorter/CollectionsSorterSpec.php @@ -0,0 +1,96 @@ +shouldHaveType(CollectionsSorter::class); + } + + public function it_implements_collections_sorter_interface(): void + { + $this->shouldHaveType(CollectionsSorterInterface::class); + } + + public function it_sorts_collections_with_one_element( + PageInterface $page, + CollectionInterface $collection + ): void { + $collection->getCode()->willReturn('COLLECTION_CODE'); + $page->getCollections()->willReturn(new ArrayCollection([$collection->getWrappedObject()])); + + $this->sortByCollections([$page])->shouldReturn( + [ + 'COLLECTION_CODE' => ['collection' => $collection, 0 => $page], + ] + ); + } + + public function it_sorts_collections_with_more_elements( + PageInterface $page1, + PageInterface $page2, + PageInterface $page3, + CollectionInterface $collection1, + CollectionInterface $collection2, + CollectionInterface $collection3 + ): void { + $collection1->getCode()->willReturn('COLLECTION_1_CODE'); + $collection2->getCode()->willReturn('COLLECTION_2_CODE'); + $collection3->getCode()->willReturn('COLLECTION_3_CODE'); + + $page1->getCollections()->willReturn(new ArrayCollection( + [$collection1->getWrappedObject(), $collection3->getWrappedObject()] + )); + $page2->getCollections()->willReturn(new ArrayCollection([$collection3->getWrappedObject()])); + $page3->getCollections()->willReturn(new ArrayCollection( + [$collection2->getWrappedObject(), $collection1->getWrappedObject()] + )); + + $this->sortByCollections([$page1, $page2, $page3])->shouldReturn( + [ + 'COLLECTION_1_CODE' => ['collection' => $collection1, 0 => $page1, 1 => $page3], + 'COLLECTION_3_CODE' => ['collection' => $collection3, 0 => $page1, 1 => $page2], + 'COLLECTION_2_CODE' => ['collection' => $collection2, 0 => $page3], + ] + ); + } + + public function it_sorts_collections_with_less_elements( + PageInterface $page1, + PageInterface $page2, + CollectionInterface $collection1, + CollectionInterface $collection2 + ): void { + $collection1->getCode()->willReturn('COLLECTION_1_CODE'); + $collection2->getCode()->willReturn('COLLECTION_2_CODE'); + + $page1->getCollections()->willReturn(new ArrayCollection([$collection1->getWrappedObject()])); + $page2->getCollections()->willReturn(new ArrayCollection([$collection2->getWrappedObject()])); + + $this->sortByCollections([$page1, $page2])->shouldReturn( + [ + 'COLLECTION_1_CODE' => ['collection' => $collection1, 0 => $page1], + 'COLLECTION_2_CODE' => ['collection' => $collection2, 0 => $page2], + ] + ); + } +} diff --git a/spec/Sorter/SectionsSorterSpec.php b/spec/Sorter/SectionsSorterSpec.php deleted file mode 100644 index 3b20091dd..000000000 --- a/spec/Sorter/SectionsSorterSpec.php +++ /dev/null @@ -1,96 +0,0 @@ -shouldHaveType(SectionsSorter::class); - } - - public function it_implements_sections_sorter_interface(): void - { - $this->shouldHaveType(SectionsSorterInterface::class); - } - - public function it_sorts_sections_with_one_element( - PageInterface $page, - SectionInterface $section - ): void { - $section->getCode()->willReturn('SECTION_CODE'); - $page->getSections()->willReturn(new ArrayCollection([$section->getWrappedObject()])); - - $this->sortBySections([$page])->shouldReturn( - [ - 'SECTION_CODE' => ['section' => $section, 0 => $page], - ] - ); - } - - public function it_sorts_sections_with_more_elements( - PageInterface $page1, - PageInterface $page2, - PageInterface $page3, - SectionInterface $section1, - SectionInterface $section2, - SectionInterface $section3 - ): void { - $section1->getCode()->willReturn('SECTION_1_CODE'); - $section2->getCode()->willReturn('SECTION_2_CODE'); - $section3->getCode()->willReturn('SECTION_3_CODE'); - - $page1->getSections()->willReturn(new ArrayCollection( - [$section1->getWrappedObject(), $section3->getWrappedObject()] - )); - $page2->getSections()->willReturn(new ArrayCollection([$section3->getWrappedObject()])); - $page3->getSections()->willReturn(new ArrayCollection( - [$section2->getWrappedObject(), $section1->getWrappedObject()] - )); - - $this->sortBySections([$page1, $page2, $page3])->shouldReturn( - [ - 'SECTION_1_CODE' => ['section' => $section1, 0 => $page1, 1 => $page3], - 'SECTION_3_CODE' => ['section' => $section3, 0 => $page1, 1 => $page2], - 'SECTION_2_CODE' => ['section' => $section2, 0 => $page3], - ] - ); - } - - public function it_sorts_sections_with_less_elements( - PageInterface $page1, - PageInterface $page2, - SectionInterface $section1, - SectionInterface $section2 - ): void { - $section1->getCode()->willReturn('SECTION_1_CODE'); - $section2->getCode()->willReturn('SECTION_2_CODE'); - - $page1->getSections()->willReturn(new ArrayCollection([$section1->getWrappedObject()])); - $page2->getSections()->willReturn(new ArrayCollection([$section2->getWrappedObject()])); - - $this->sortBySections([$page1, $page2])->shouldReturn( - [ - 'SECTION_1_CODE' => ['section' => $section1, 0 => $page1], - 'SECTION_2_CODE' => ['section' => $section2, 0 => $page2], - ] - ); - } -} diff --git a/spec/Twig/Runtime/RenderProductPagesRuntimeSpec.php b/spec/Twig/Runtime/RenderProductPagesRuntimeSpec.php index 1406b14a2..80f4b8a71 100644 --- a/spec/Twig/Runtime/RenderProductPagesRuntimeSpec.php +++ b/spec/Twig/Runtime/RenderProductPagesRuntimeSpec.php @@ -13,9 +13,9 @@ namespace spec\BitBag\SyliusCmsPlugin\Twig\Runtime; use BitBag\SyliusCmsPlugin\Entity\PageInterface; -use BitBag\SyliusCmsPlugin\Entity\SectionInterface; +use BitBag\SyliusCmsPlugin\Entity\CollectionInterface; use BitBag\SyliusCmsPlugin\Repository\PageRepositoryInterface; -use BitBag\SyliusCmsPlugin\Sorter\SectionsSorterInterface; +use BitBag\SyliusCmsPlugin\Sorter\CollectionsSorterInterface; use BitBag\SyliusCmsPlugin\Twig\Runtime\RenderProductPagesRuntime; use BitBag\SyliusCmsPlugin\Twig\Runtime\RenderProductPagesRuntimeInterface; use Doctrine\Common\Collections\ArrayCollection; @@ -31,9 +31,9 @@ public function let( PageRepositoryInterface $pageRepository, ChannelContextInterface $channelContext, Environment $templatingEngine, - SectionsSorterInterface $sectionsSorter + CollectionsSorterInterface $collectionsSorter ): void { - $this->beConstructedWith($pageRepository, $channelContext, $templatingEngine, $sectionsSorter); + $this->beConstructedWith($pageRepository, $channelContext, $templatingEngine, $collectionsSorter); } public function it_is_initializable(): void @@ -52,39 +52,39 @@ public function it_renders_product_pages( ChannelInterface $channel, PageRepositoryInterface $pageRepository, PageInterface $page, - SectionInterface $section, + CollectionInterface $collection, Environment $templatingEngine, - SectionsSorterInterface $sectionsSorter + CollectionsSorterInterface $collectionsSorter ): void { $channel->getCode()->willReturn('WEB'); $channelContext->getChannel()->willReturn($channel); - $page->getSections()->willReturn(new ArrayCollection([$section])); - $section->getCode()->willReturn('SECTION_CODE'); + $page->getCollections()->willReturn(new ArrayCollection([$collection])); + $collection->getCode()->willReturn('COLLECTION_CODE'); $pageRepository->findByProduct($product, 'WEB', null)->willReturn([])->shouldBeCalled(); - $sectionsSorter->sortBySections([])->willReturn([]); - $templatingEngine->render('@BitBagSyliusCmsPlugin/Shop/Product/_pagesBySection.html.twig', ['data' => []])->willReturn('content'); + $collectionsSorter->sortByCollections([])->willReturn([]); + $templatingEngine->render('@BitBagSyliusCmsPlugin/Shop/Product/_pagesByCollection.html.twig', ['data' => []])->willReturn('content'); $this->renderProductPages($product)->shouldReturn('content'); } - public function it_renders_product_pages_with_sections( + public function it_renders_product_pages_with_collections( ChannelContextInterface $channelContext, ProductInterface $product, ChannelInterface $channel, PageRepositoryInterface $pageRepository, PageInterface $page, - SectionInterface $section, + CollectionInterface $collection, Environment $templatingEngine, - SectionsSorterInterface $sectionsSorter + CollectionsSorterInterface $collectionsSorter ): void { $channel->getCode()->willReturn('WEB'); $channelContext->getChannel()->willReturn($channel); - $page->getSections()->willReturn(new ArrayCollection([$section])); - $section->getCode()->willReturn('SECTION_CODE'); - $pageRepository->findByProductAndSectionCode($product, 'SECTION_CODE', 'WEB', null)->willReturn([])->shouldBeCalled(); - $sectionsSorter->sortBySections([])->willReturn([]); - $templatingEngine->render('@BitBagSyliusCmsPlugin/Shop/Product/_pagesBySection.html.twig', ['data' => []])->willReturn('content'); + $page->getCollections()->willReturn(new ArrayCollection([$collection])); + $collection->getCode()->willReturn('COLLECTION_CODE'); + $pageRepository->findByProductAndCollectionCode($product, 'COLLECTION_CODE', 'WEB', null)->willReturn([])->shouldBeCalled(); + $collectionsSorter->sortByCollections([])->willReturn([]); + $templatingEngine->render('@BitBagSyliusCmsPlugin/Shop/Product/_pagesByCollection.html.twig', ['data' => []])->willReturn('content'); - $this->renderProductPages($product, 'SECTION_CODE')->shouldReturn('content'); + $this->renderProductPages($product, 'COLLECTION_CODE')->shouldReturn('content'); } } diff --git a/src/Assigner/CollectionsAssigner.php b/src/Assigner/CollectionsAssigner.php new file mode 100644 index 000000000..808f4dd61 --- /dev/null +++ b/src/Assigner/CollectionsAssigner.php @@ -0,0 +1,34 @@ +collectionRepository->findOneBy(['code' => $collectionCode]); + + Assert::notNull($collection, sprintf('Collection with %s code not found.', $collectionCode)); + $collectionsAware->addCollection($collection); + } + } +} diff --git a/src/Assigner/SectionsAssignerInterface.php b/src/Assigner/CollectionsAssignerInterface.php similarity index 66% rename from src/Assigner/SectionsAssignerInterface.php rename to src/Assigner/CollectionsAssignerInterface.php index ef30f7542..7ad276981 100644 --- a/src/Assigner/SectionsAssignerInterface.php +++ b/src/Assigner/CollectionsAssignerInterface.php @@ -10,9 +10,9 @@ namespace BitBag\SyliusCmsPlugin\Assigner; -use BitBag\SyliusCmsPlugin\Entity\SectionableInterface; +use BitBag\SyliusCmsPlugin\Entity\CollectibleInterface; -interface SectionsAssignerInterface +interface CollectionsAssignerInterface { - public function assign(SectionableInterface $sectionsAware, array $sectionsCodes): void; + public function assign(CollectibleInterface $collectionsAware, array $collectionsCodes): void; } diff --git a/src/Assigner/SectionsAssigner.php b/src/Assigner/SectionsAssigner.php deleted file mode 100644 index 918b62c62..000000000 --- a/src/Assigner/SectionsAssigner.php +++ /dev/null @@ -1,34 +0,0 @@ -sectionRepository->findOneBy(['code' => $sectionCode]); - - Assert::notNull($section, sprintf('Section with %s code not found.', $sectionCode)); - $sectionsAware->addSection($section); - } - } -} diff --git a/src/Entity/Block.php b/src/Entity/Block.php index e596ac140..2037d6cec 100755 --- a/src/Entity/Block.php +++ b/src/Entity/Block.php @@ -17,7 +17,7 @@ class Block implements BlockInterface { use ToggleableTrait; - use SectionableTrait; + use CollectibleTrait; use ProductsAwareTrait; use TaxonAwareTrait; use ChannelsAwareTrait; @@ -28,7 +28,7 @@ class Block implements BlockInterface public function __construct() { $this->initializeTranslationsCollection(); - $this->initializeSectionsCollection(); + $this->initializeCollectionsCollection(); $this->initializeProductsCollection(); $this->initializeTaxonCollection(); $this->initializeChannelsCollection(); diff --git a/src/Entity/BlockInterface.php b/src/Entity/BlockInterface.php index 86dddbdc5..8289d2fbc 100755 --- a/src/Entity/BlockInterface.php +++ b/src/Entity/BlockInterface.php @@ -21,7 +21,7 @@ interface BlockInterface extends ToggleableInterface, ProductsAwareInterface, TaxonAwareInterface, - SectionableInterface, + CollectibleInterface, ChannelsAwareInterface, ContentableInterface { diff --git a/src/Entity/SectionableInterface.php b/src/Entity/BlocksCollectionInterface.php old mode 100755 new mode 100644 similarity index 52% rename from src/Entity/SectionableInterface.php rename to src/Entity/BlocksCollectionInterface.php index 11ebf7e8d..f6fcd828d --- a/src/Entity/SectionableInterface.php +++ b/src/Entity/BlocksCollectionInterface.php @@ -12,18 +12,15 @@ use Doctrine\Common\Collections\Collection; -interface SectionableInterface +interface BlocksCollectionInterface { - public function initializeSectionsCollection(): void; + public function initializeBlocksCollection(): void; - /** - * @return Collection|SectionInterface[] - */ - public function getSections(): ?Collection; + public function getBlocks(): ?Collection; - public function hasSection(SectionInterface $section): bool; + public function hasBlock(BlockInterface $block): bool; - public function addSection(SectionInterface $section): void; + public function addBlock(BlockInterface $block): void; - public function removeSection(SectionInterface $section): void; + public function removeBlock(BlockInterface $block): void; } diff --git a/src/Entity/BlocksCollectionTrait.php b/src/Entity/BlocksCollectionTrait.php new file mode 100644 index 000000000..71bf4c78b --- /dev/null +++ b/src/Entity/BlocksCollectionTrait.php @@ -0,0 +1,48 @@ +blocks = new ArrayCollection(); + } + + public function getBlocks(): ?Collection + { + return $this->blocks; + } + + public function hasBlock(BlockInterface $block): bool + { + return $this->blocks->contains($block); + } + + public function addBlock(BlockInterface $block): void + { + if (false === $this->hasBlock($block)) { + $this->blocks->add($block); + } + } + + public function removeBlock(BlockInterface $block): void + { + if (true === $this->hasBlock($block)) { + $this->blocks->removeElement($block); + } + } +} diff --git a/src/Entity/CollectibleInterface.php b/src/Entity/CollectibleInterface.php new file mode 100755 index 000000000..106ae7f0d --- /dev/null +++ b/src/Entity/CollectibleInterface.php @@ -0,0 +1,29 @@ +collections = new ArrayCollection(); + } + + public function getCollections(): ?Collection + { + return $this->collections; + } + + public function hasCollection(CollectionInterface $collection): bool + { + return $this->collections->contains($collection); + } + + public function addCollection(CollectionInterface $collection): void + { + if (false === $this->hasCollection($collection)) { + $this->collections->add($collection); + } + } + + public function removeCollection(CollectionInterface $collection): void + { + if (true === $this->hasCollection($collection)) { + $this->collections->removeElement($collection); + } + } +} diff --git a/src/Entity/Section.php b/src/Entity/Collection.php similarity index 50% rename from src/Entity/Section.php rename to src/Entity/Collection.php index 12e9e81ce..d80c7b599 100755 --- a/src/Entity/Section.php +++ b/src/Entity/Collection.php @@ -13,20 +13,26 @@ use Sylius\Component\Resource\Model\TranslatableTrait; use Sylius\Component\Resource\Model\TranslationInterface; -class Section implements SectionInterface +class Collection implements CollectionInterface { + use PagesCollectionTrait; + use BlocksCollectionTrait; + use MediaCollectionTrait; use TranslatableTrait { __construct as private initializeTranslationsCollection; } - /** @var int */ - protected $id; + protected ?int $id; - /** @var string|null */ - protected $code; + protected ?string $code = null; + + protected ?string $type = null; public function __construct() { + $this->initializePagesCollection(); + $this->initializeBlocksCollection(); + $this->initializeMediaCollection(); $this->initializeTranslationsCollection(); } @@ -45,31 +51,41 @@ public function setCode(?string $code): void $this->code = $code; } + public function getType(): ?string + { + return $this->type; + } + + public function setType(?string $type): void + { + $this->type = $type; + } + public function getName(): ?string { - /** @var SectionTranslationInterface $sectionTranslationInterface */ - $sectionTranslationInterface = $this->getSectionTranslation(); + /** @var CollectionTranslationInterface $collectionTranslationInterface */ + $collectionTranslationInterface = $this->getCollectionTranslation(); - return $sectionTranslationInterface->getName(); + return $collectionTranslationInterface->getName(); } public function setName(?string $name): void { - /** @var SectionTranslationInterface $sectionTranslationInterface */ - $sectionTranslationInterface = $this->getSectionTranslation(); - $sectionTranslationInterface->setName($name); + /** @var CollectionTranslationInterface $collectionTranslationInterface */ + $collectionTranslationInterface = $this->getCollectionTranslation(); + $collectionTranslationInterface->setName($name); } /** - * @return TranslationInterface|SectionTranslationInterface + * @return TranslationInterface|CollectionTranslationInterface */ - protected function getSectionTranslation(): TranslationInterface + protected function getCollectionTranslation(): TranslationInterface { return $this->getTranslation(); } protected function createTranslation(): TranslationInterface { - return new SectionTranslation(); + return new CollectionTranslation(); } } diff --git a/src/Entity/SectionInterface.php b/src/Entity/CollectionInterface.php similarity index 71% rename from src/Entity/SectionInterface.php rename to src/Entity/CollectionInterface.php index 80687bf2e..1eef9d2d9 100755 --- a/src/Entity/SectionInterface.php +++ b/src/Entity/CollectionInterface.php @@ -13,12 +13,21 @@ use Sylius\Component\Resource\Model\ResourceInterface; use Sylius\Component\Resource\Model\TranslatableInterface; -interface SectionInterface extends ResourceInterface, TranslatableInterface +interface CollectionInterface extends + ResourceInterface, + TranslatableInterface, + PagesCollectionInterface, + BlocksCollectionInterface, + MediaCollectionInterface { public function getCode(): ?string; public function setCode(?string $code): void; + public function getType(): ?string; + + public function setType(?string $type): void; + public function getName(): ?string; public function setName(?string $name): void; diff --git a/src/Entity/SectionTranslation.php b/src/Entity/CollectionTranslation.php similarity index 88% rename from src/Entity/SectionTranslation.php rename to src/Entity/CollectionTranslation.php index 0541bbf1c..48c3859a3 100755 --- a/src/Entity/SectionTranslation.php +++ b/src/Entity/CollectionTranslation.php @@ -12,7 +12,7 @@ use Sylius\Component\Resource\Model\AbstractTranslation; -class SectionTranslation extends AbstractTranslation implements SectionTranslationInterface +class CollectionTranslation extends AbstractTranslation implements CollectionTranslationInterface { /** @var int */ protected $id; diff --git a/src/Entity/SectionTranslationInterface.php b/src/Entity/CollectionTranslationInterface.php similarity index 86% rename from src/Entity/SectionTranslationInterface.php rename to src/Entity/CollectionTranslationInterface.php index eb9bdb6ba..5caa2ec69 100755 --- a/src/Entity/SectionTranslationInterface.php +++ b/src/Entity/CollectionTranslationInterface.php @@ -13,7 +13,7 @@ use Sylius\Component\Resource\Model\ResourceInterface; use Sylius\Component\Resource\Model\TranslationInterface; -interface SectionTranslationInterface extends ResourceInterface, TranslationInterface +interface CollectionTranslationInterface extends ResourceInterface, TranslationInterface { public function getName(): ?string; diff --git a/src/Entity/Media.php b/src/Entity/Media.php index afa9b832c..c7ddfc705 100644 --- a/src/Entity/Media.php +++ b/src/Entity/Media.php @@ -20,7 +20,7 @@ class Media implements MediaInterface { use ToggleableTrait; - use SectionableTrait; + use CollectibleTrait; use ProductsAwareTrait; use ChannelsAwareTrait; use TranslatableTrait { @@ -60,7 +60,7 @@ class Media implements MediaInterface public function __construct() { $this->initializeTranslationsCollection(); - $this->initializeSectionsCollection(); + $this->initializeCollectionsCollection(); $this->initializeProductsCollection(); $this->initializeChannelsCollection(); } diff --git a/src/Entity/MediaCollectionInterface.php b/src/Entity/MediaCollectionInterface.php new file mode 100644 index 000000000..45c1dd98e --- /dev/null +++ b/src/Entity/MediaCollectionInterface.php @@ -0,0 +1,26 @@ +media = new ArrayCollection(); + } + + public function getMedia(): ?Collection + { + return $this->media; + } + + public function hasMedium(MediaInterface $media): bool + { + return $this->media->contains($media); + } + + public function addMedium(MediaInterface $media): void + { + if (false === $this->hasMedium($media)) { + $this->media->add($media); + } + } + + public function removeMedium(MediaInterface $media): void + { + if (true === $this->hasMedium($media)) { + $this->media->removeElement($media); + } + } +} diff --git a/src/Entity/MediaInterface.php b/src/Entity/MediaInterface.php index 7e93c7b78..83478d68a 100644 --- a/src/Entity/MediaInterface.php +++ b/src/Entity/MediaInterface.php @@ -21,7 +21,7 @@ interface MediaInterface extends TranslatableInterface, ToggleableInterface, ProductsAwareInterface, - SectionableInterface, + CollectibleInterface, ChannelsAwareInterface, ContentableInterface { diff --git a/src/Entity/Page.php b/src/Entity/Page.php index 0e6a3a76e..131ff016c 100755 --- a/src/Entity/Page.php +++ b/src/Entity/Page.php @@ -19,7 +19,7 @@ class Page implements PageInterface { use ToggleableTrait; use ProductsAwareTrait; - use SectionableTrait; + use CollectibleTrait; use TimestampableTrait; use ChannelsAwareTrait; use TranslatableTrait { @@ -38,7 +38,7 @@ class Page implements PageInterface public function __construct() { $this->initializeProductsCollection(); - $this->initializeSectionsCollection(); + $this->initializeCollectionsCollection(); $this->initializeTranslationsCollection(); $this->initializeChannelsCollection(); diff --git a/src/Entity/PageInterface.php b/src/Entity/PageInterface.php index b57d01a2d..b154afd76 100755 --- a/src/Entity/PageInterface.php +++ b/src/Entity/PageInterface.php @@ -22,7 +22,7 @@ interface PageInterface extends TranslatableInterface, ToggleableInterface, ProductsAwareInterface, - SectionableInterface, + CollectibleInterface, TimestampableInterface, ChannelsAwareInterface, ContentableInterface, diff --git a/src/Entity/PagesCollectionInterface.php b/src/Entity/PagesCollectionInterface.php new file mode 100644 index 000000000..bd09893f9 --- /dev/null +++ b/src/Entity/PagesCollectionInterface.php @@ -0,0 +1,26 @@ +pages = new ArrayCollection(); + } + + public function getPages(): ?Collection + { + return $this->pages; + } + + public function hasPage(PageInterface $page): bool + { + return $this->pages->contains($page); + } + + public function addPage(PageInterface $page): void + { + if (false === $this->hasPage($page)) { + $this->pages->add($page); + } + } + + public function removePage(PageInterface $page): void + { + if (true === $this->hasPage($page)) { + $this->pages->removeElement($page); + } + } +} diff --git a/src/Entity/SectionableTrait.php b/src/Entity/SectionableTrait.php deleted file mode 100755 index 93168b252..000000000 --- a/src/Entity/SectionableTrait.php +++ /dev/null @@ -1,49 +0,0 @@ -sections = new ArrayCollection(); - } - - public function getSections(): ?Collection - { - return $this->sections; - } - - public function hasSection(SectionInterface $section): bool - { - return $this->sections->contains($section); - } - - public function addSection(SectionInterface $section): void - { - if (false === $this->hasSection($section)) { - $this->sections->add($section); - } - } - - public function removeSection(SectionInterface $section): void - { - if (true === $this->hasSection($section)) { - $this->sections->removeElement($section); - } - } -} diff --git a/src/Fixture/BlockFixture.php b/src/Fixture/BlockFixture.php index f4222a162..2a87c0f8c 100755 --- a/src/Fixture/BlockFixture.php +++ b/src/Fixture/BlockFixture.php @@ -44,7 +44,7 @@ protected function configureOptionsNode(ArrayNodeDefinition $optionsNode): void ->integerNode('products')->defaultNull()->end() ->arrayNode('productCodes')->scalarPrototype()->end()->end() ->arrayNode('taxons')->scalarPrototype()->end()->end() - ->arrayNode('sections')->scalarPrototype()->end()->end() + ->arrayNode('collections')->scalarPrototype()->end()->end() ->arrayNode('channels')->scalarPrototype()->end()->end() ->arrayNode('translations') ->arrayPrototype() diff --git a/src/Fixture/SectionFixture.php b/src/Fixture/CollectionFixture.php similarity index 89% rename from src/Fixture/SectionFixture.php rename to src/Fixture/CollectionFixture.php index 3c4e45c23..ee07390de 100755 --- a/src/Fixture/SectionFixture.php +++ b/src/Fixture/CollectionFixture.php @@ -14,20 +14,20 @@ use Sylius\Bundle\FixturesBundle\Fixture\AbstractFixture; use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; -final class SectionFixture extends AbstractFixture +final class CollectionFixture extends AbstractFixture { - public function __construct(private FixtureFactoryInterface $sectionFixtureFactory) + public function __construct(private FixtureFactoryInterface $collectionFixtureFactory) { } public function load(array $options): void { - $this->sectionFixtureFactory->load($options['custom']); + $this->collectionFixtureFactory->load($options['custom']); } public function getName(): string { - return 'section'; + return 'collection'; } protected function configureOptionsNode(ArrayNodeDefinition $optionsNode): void diff --git a/src/Fixture/Factory/BlockFixtureFactory.php b/src/Fixture/Factory/BlockFixtureFactory.php index 7c8115877..e4d6a6478 100755 --- a/src/Fixture/Factory/BlockFixtureFactory.php +++ b/src/Fixture/Factory/BlockFixtureFactory.php @@ -11,8 +11,8 @@ namespace BitBag\SyliusCmsPlugin\Fixture\Factory; use BitBag\SyliusCmsPlugin\Assigner\ChannelsAssignerInterface; +use BitBag\SyliusCmsPlugin\Assigner\CollectionsAssignerInterface; use BitBag\SyliusCmsPlugin\Assigner\ProductsAssignerInterface; -use BitBag\SyliusCmsPlugin\Assigner\SectionsAssignerInterface; use BitBag\SyliusCmsPlugin\Assigner\TaxonsAssignerInterface; use BitBag\SyliusCmsPlugin\Entity\BlockInterface; use BitBag\SyliusCmsPlugin\Entity\BlockTranslationInterface; @@ -34,7 +34,7 @@ public function __construct( private LocaleContextInterface $localeContext, private ProductsAssignerInterface $productsAssigner, private TaxonsAssignerInterface $taxonsAssigner, - private SectionsAssignerInterface $sectionsAssigner, + private CollectionsAssignerInterface $collectionsAssigner, private ChannelsAssignerInterface $channelAssigner, ) { } @@ -71,7 +71,7 @@ private function createBlock(string $code, array $blockData): void $this->resolveProducts($block, $products); } - $this->sectionsAssigner->assign($block, $blockData['sections']); + $this->collectionsAssigner->assign($block, $blockData['collections']); $this->productsAssigner->assign($block, $blockData['productCodes']); $this->taxonsAssigner->assign($block, $blockData['taxons']); $this->channelAssigner->assign($block, $blockData['channels']); diff --git a/src/Fixture/Factory/CollectionFixtureFactory.php b/src/Fixture/Factory/CollectionFixtureFactory.php new file mode 100755 index 000000000..1155ed7b6 --- /dev/null +++ b/src/Fixture/Factory/CollectionFixtureFactory.php @@ -0,0 +1,57 @@ + $fields) { + /** @var ?CollectionInterface $collection */ + $collection = $this->collectionRepository->findOneBy(['code' => $code]); + if ( + true === $fields['remove_existing'] && + null !== $collection + ) { + $this->collectionRepository->remove($collection); + } + + /** @var CollectionInterface $collection */ + $collection = $this->collectionFactory->createNew(); + + $collection->setCode($code); + + foreach ($fields['translations'] as $localeCode => $translation) { + /** @var CollectionTranslationInterface $collectionTranslation */ + $collectionTranslation = $this->collectionTranslationFactory->createNew(); + + $collectionTranslation->setLocale($localeCode); + $collectionTranslation->setName($translation['name']); + + $collection->addTranslation($collectionTranslation); + } + + $this->collectionRepository->add($collection); + } + } +} diff --git a/src/Fixture/Factory/MediaFixtureFactory.php b/src/Fixture/Factory/MediaFixtureFactory.php index 153c44c0f..d151fd94f 100644 --- a/src/Fixture/Factory/MediaFixtureFactory.php +++ b/src/Fixture/Factory/MediaFixtureFactory.php @@ -11,8 +11,8 @@ namespace BitBag\SyliusCmsPlugin\Fixture\Factory; use BitBag\SyliusCmsPlugin\Assigner\ChannelsAssignerInterface; +use BitBag\SyliusCmsPlugin\Assigner\CollectionsAssignerInterface; use BitBag\SyliusCmsPlugin\Assigner\ProductsAssignerInterface; -use BitBag\SyliusCmsPlugin\Assigner\SectionsAssignerInterface; use BitBag\SyliusCmsPlugin\Entity\MediaInterface; use BitBag\SyliusCmsPlugin\Entity\MediaTranslationInterface; use BitBag\SyliusCmsPlugin\Repository\MediaRepositoryInterface; @@ -28,7 +28,7 @@ public function __construct( private MediaProviderResolverInterface $mediaProviderResolver, private MediaRepositoryInterface $mediaRepository, private ProductsAssignerInterface $productsAssigner, - private SectionsAssignerInterface $sectionsAssigner, + private CollectionsAssignerInterface $collectionsAssigner, private ChannelsAssignerInterface $channelAssigner, ) { } @@ -78,7 +78,7 @@ private function createMedia(string $code, array $mediaData): void $media->addTranslation($mediaTranslation); } - $this->sectionsAssigner->assign($media, $mediaData['sections']); + $this->collectionsAssigner->assign($media, $mediaData['collections']); $this->productsAssigner->assign($media, $mediaData['productCodes']); $this->channelAssigner->assign($media, $mediaData['channels']); diff --git a/src/Fixture/Factory/PageFixtureFactory.php b/src/Fixture/Factory/PageFixtureFactory.php index 3a6827fd3..d1569cdeb 100755 --- a/src/Fixture/Factory/PageFixtureFactory.php +++ b/src/Fixture/Factory/PageFixtureFactory.php @@ -11,8 +11,8 @@ namespace BitBag\SyliusCmsPlugin\Fixture\Factory; use BitBag\SyliusCmsPlugin\Assigner\ChannelsAssignerInterface; +use BitBag\SyliusCmsPlugin\Assigner\CollectionsAssignerInterface; use BitBag\SyliusCmsPlugin\Assigner\ProductsAssignerInterface; -use BitBag\SyliusCmsPlugin\Assigner\SectionsAssignerInterface; use BitBag\SyliusCmsPlugin\Entity\Media; use BitBag\SyliusCmsPlugin\Entity\MediaInterface; use BitBag\SyliusCmsPlugin\Entity\PageInterface; @@ -37,7 +37,7 @@ public function __construct( private PageRepositoryInterface $pageRepository, private MediaProviderResolverInterface $mediaProviderResolver, private ProductsAssignerInterface $productsAssigner, - private SectionsAssignerInterface $sectionsAssigner, + private CollectionsAssignerInterface $collectionsAssigner, private ChannelsAssignerInterface $channelAssigner, private ProductRepositoryInterface $productRepository, private LocaleContextInterface $localeContext, @@ -80,7 +80,7 @@ private function createPage( $this->resolveProductsForChannels($page, $products, $channelsCodes); } - $this->sectionsAssigner->assign($page, $pageData['sections']); + $this->collectionsAssigner->assign($page, $pageData['collections']); $this->productsAssigner->assign($page, $pageData['productCodes']); $this->channelAssigner->assign($page, $channelsCodes); diff --git a/src/Fixture/Factory/SectionFixtureFactory.php b/src/Fixture/Factory/SectionFixtureFactory.php deleted file mode 100755 index 32ccd2d06..000000000 --- a/src/Fixture/Factory/SectionFixtureFactory.php +++ /dev/null @@ -1,57 +0,0 @@ - $fields) { - /** @var ?SectionInterface $section */ - $section = $this->sectionRepository->findOneBy(['code' => $code]); - if ( - true === $fields['remove_existing'] && - null !== $section - ) { - $this->sectionRepository->remove($section); - } - - /** @var SectionInterface $section */ - $section = $this->sectionFactory->createNew(); - - $section->setCode($code); - - foreach ($fields['translations'] as $localeCode => $translation) { - /** @var SectionTranslationInterface $sectionTranslation */ - $sectionTranslation = $this->sectionTranslationFactory->createNew(); - - $sectionTranslation->setLocale($localeCode); - $sectionTranslation->setName($translation['name']); - - $section->addTranslation($sectionTranslation); - } - - $this->sectionRepository->add($section); - } - } -} diff --git a/src/Fixture/MediaFixture.php b/src/Fixture/MediaFixture.php index 4e6d23e02..200e9e19f 100644 --- a/src/Fixture/MediaFixture.php +++ b/src/Fixture/MediaFixture.php @@ -44,7 +44,7 @@ protected function configureOptionsNode(ArrayNodeDefinition $optionsNode): void ->scalarNode('original_name')->isRequired()->cannotBeEmpty()->end() ->booleanNode('enabled')->defaultTrue()->end() ->arrayNode('productCodes')->scalarPrototype()->end()->end() - ->arrayNode('sections')->scalarPrototype()->end()->end() + ->arrayNode('collections')->scalarPrototype()->end()->end() ->arrayNode('channels')->scalarPrototype()->end()->end() ->arrayNode('translations') ->arrayPrototype() diff --git a/src/Fixture/PageFixture.php b/src/Fixture/PageFixture.php index cdd6c5546..3812353c4 100755 --- a/src/Fixture/PageFixture.php +++ b/src/Fixture/PageFixture.php @@ -42,7 +42,7 @@ protected function configureOptionsNode(ArrayNodeDefinition $optionsNode): void ->booleanNode('enabled')->defaultTrue()->end() ->integerNode('products')->defaultNull()->end() ->arrayNode('productCodes')->scalarPrototype()->end()->end() - ->arrayNode('sections')->scalarPrototype()->end()->end() + ->arrayNode('collections')->scalarPrototype()->end()->end() ->arrayNode('channels')->scalarPrototype()->end()->end() ->arrayNode('translations') ->prototype('array') diff --git a/src/Form/Type/SectionAutocompleteChoiceType.php b/src/Form/Type/BlockAutocompleteChoiceType.php old mode 100755 new mode 100644 similarity index 87% rename from src/Form/Type/SectionAutocompleteChoiceType.php rename to src/Form/Type/BlockAutocompleteChoiceType.php index ec57d6918..f99a4a6fc --- a/src/Form/Type/SectionAutocompleteChoiceType.php +++ b/src/Form/Type/BlockAutocompleteChoiceType.php @@ -16,12 +16,12 @@ use Symfony\Component\Form\FormView; use Symfony\Component\OptionsResolver\OptionsResolver; -final class SectionAutocompleteChoiceType extends AbstractType +final class BlockAutocompleteChoiceType extends AbstractType { public function configureOptions(OptionsResolver $resolver): void { $resolver->setDefaults([ - 'resource' => 'bitbag_sylius_cms_plugin.section', + 'resource' => 'bitbag_sylius_cms_plugin.block', 'choice_name' => 'name', 'choice_value' => 'code', ]); @@ -38,7 +38,7 @@ public function buildView( public function getBlockPrefix(): string { - return 'bitbag_section_autocomplete_choice'; + return 'bitbag_block_autocomplete_choice'; } public function getParent(): string diff --git a/src/Form/Type/BlockType.php b/src/Form/Type/BlockType.php index 843e62156..5463527cd 100755 --- a/src/Form/Type/BlockType.php +++ b/src/Form/Type/BlockType.php @@ -34,8 +34,8 @@ public function buildForm(FormBuilderInterface $builder, array $options): void 'label' => 'bitbag_sylius_cms_plugin.ui.code', 'disabled' => null !== $block->getCode(), ]) - ->add('sections', SectionAutocompleteChoiceType::class, [ - 'label' => 'bitbag_sylius_cms_plugin.ui.sections', + ->add('collections', CollectionAutocompleteChoiceType::class, [ + 'label' => 'bitbag_sylius_cms_plugin.ui.collections', 'multiple' => true, ]) ->add('enabled', CheckboxType::class, [ diff --git a/src/Form/Type/CollectionAutocompleteChoiceType.php b/src/Form/Type/CollectionAutocompleteChoiceType.php new file mode 100755 index 000000000..1ac306653 --- /dev/null +++ b/src/Form/Type/CollectionAutocompleteChoiceType.php @@ -0,0 +1,48 @@ +setDefaults([ + 'resource' => 'bitbag_sylius_cms_plugin.collection', + 'choice_name' => 'name', + 'choice_value' => 'code', + ]); + } + + public function buildView( + FormView $view, + FormInterface $form, + array $options, + ): void { + $view->vars['remote_criteria_type'] = 'contains'; + $view->vars['remote_criteria_name'] = 'phrase'; + } + + public function getBlockPrefix(): string + { + return 'bitbag_collection_autocomplete_choice'; + } + + public function getParent(): string + { + return ResourceAutocompleteChoiceType::class; + } +} diff --git a/src/Form/Type/CollectionType.php b/src/Form/Type/CollectionType.php new file mode 100755 index 000000000..c4c2854ec --- /dev/null +++ b/src/Form/Type/CollectionType.php @@ -0,0 +1,88 @@ +add('code', TextType::class, [ + 'label' => 'bitbag_sylius_cms_plugin.ui.code', + 'disabled' => null !== $builder->getData()->getCode(), + ]) + ->add('type', ChoiceType::class, [ + 'label' => 'bitbag_sylius_cms_plugin.ui.type', + 'choices' => [ + 'bitbag_sylius_cms_plugin.ui.page' => self::PAGE, + 'bitbag_sylius_cms_plugin.ui.block' => self::BLOCK, + 'bitbag_sylius_cms_plugin.ui.media' => self::MEDIA, + ], + ]) + ->add('pages', PageAutocompleteChoiceType::class, [ + 'label' => 'bitbag_sylius_cms_plugin.ui.pages', + 'multiple' => true, + ]) + ->add('blocks', BlockAutocompleteChoiceType::class, [ + 'label' => 'bitbag_sylius_cms_plugin.ui.blocks', + 'multiple' => true, + ]) + ->add('media', MediaAutocompleteChoiceType::class, [ + 'label' => 'bitbag_sylius_cms_plugin.ui.media', + 'multiple' => true, + 'media_type' => MediaInterface::IMAGE_TYPE, + ]) + ->add('translations', ResourceTranslationsType::class, [ + 'entry_type' => CollectionTranslationType::class, + ]) + ->addEventListener(FormEvents::PRE_SUBMIT, function (PreSubmitEvent $event): void { + $formData = $event->getData(); + switch ($formData['type']) { + case self::PAGE: + unset($formData['blocks'], $formData['media']); + + break; + case self::BLOCK: + unset($formData['pages'], $formData['media']); + + break; + case self::MEDIA: + unset($formData['pages'], $formData['blocks']); + + break; + } + + $event->setData($formData); + }) + ; + } + + public function getBlockPrefix(): string + { + return 'bitbag_sylius_cms_plugin_collection'; + } +} diff --git a/src/Form/Type/MediaType.php b/src/Form/Type/MediaType.php index 7671a17d9..47ecf8dc7 100644 --- a/src/Form/Type/MediaType.php +++ b/src/Form/Type/MediaType.php @@ -52,8 +52,8 @@ public function buildForm(FormBuilderInterface $builder, array $options): void ->add('file', FileType::class, [ 'label' => 'bitbag_sylius_cms_plugin.ui.file', ]) - ->add('sections', SectionAutocompleteChoiceType::class, [ - 'label' => 'bitbag_sylius_cms_plugin.ui.sections', + ->add('collections', CollectionAutocompleteChoiceType::class, [ + 'label' => 'bitbag_sylius_cms_plugin.ui.collections', 'multiple' => true, ]) ->add('enabled', CheckboxType::class, [ diff --git a/src/Form/Type/PageAutocompleteChoiceType.php b/src/Form/Type/PageAutocompleteChoiceType.php new file mode 100644 index 000000000..b1fd7639b --- /dev/null +++ b/src/Form/Type/PageAutocompleteChoiceType.php @@ -0,0 +1,48 @@ +setDefaults([ + 'resource' => 'bitbag_sylius_cms_plugin.page', + 'choice_name' => 'name', + 'choice_value' => 'code', + ]); + } + + public function buildView( + FormView $view, + FormInterface $form, + array $options, + ): void { + $view->vars['remote_criteria_type'] = 'contains'; + $view->vars['remote_criteria_name'] = 'phrase'; + } + + public function getBlockPrefix(): string + { + return 'bitbag_page_autocomplete_choice'; + } + + public function getParent(): string + { + return ResourceAutocompleteChoiceType::class; + } +} diff --git a/src/Form/Type/PageType.php b/src/Form/Type/PageType.php index a16f092e1..592218d97 100755 --- a/src/Form/Type/PageType.php +++ b/src/Form/Type/PageType.php @@ -40,8 +40,8 @@ public function buildForm(FormBuilderInterface $builder, array $options): void 'label' => 'bitbag_sylius_cms_plugin.ui.images', 'entry_type' => PageTranslationType::class, ]) - ->add('sections', SectionAutocompleteChoiceType::class, [ - 'label' => 'bitbag_sylius_cms_plugin.ui.sections', + ->add('collections', CollectionAutocompleteChoiceType::class, [ + 'label' => 'bitbag_sylius_cms_plugin.ui.collections', 'multiple' => true, ]) ->add('channels', ChannelChoiceType::class, [ diff --git a/src/Form/Type/SectionType.php b/src/Form/Type/SectionType.php deleted file mode 100755 index 6ef143368..000000000 --- a/src/Form/Type/SectionType.php +++ /dev/null @@ -1,38 +0,0 @@ -add('code', TextType::class, [ - 'label' => 'bitbag_sylius_cms_plugin.ui.code', - 'disabled' => null !== $builder->getData()->getCode(), - ]) - ->add('translations', ResourceTranslationsType::class, [ - 'entry_type' => SectionTranslationType::class, - ]) - ; - } - - public function getBlockPrefix(): string - { - return 'bitbag_sylius_cms_plugin_section'; - } -} diff --git a/src/Form/Type/Translation/SectionTranslationType.php b/src/Form/Type/Translation/CollectionTranslationType.php similarity index 86% rename from src/Form/Type/Translation/SectionTranslationType.php rename to src/Form/Type/Translation/CollectionTranslationType.php index 18069a56c..5777d2c0b 100755 --- a/src/Form/Type/Translation/SectionTranslationType.php +++ b/src/Form/Type/Translation/CollectionTranslationType.php @@ -14,7 +14,7 @@ use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; -final class SectionTranslationType extends AbstractResourceType +final class CollectionTranslationType extends AbstractResourceType { public function buildForm(FormBuilderInterface $builder, array $options): void { @@ -27,6 +27,6 @@ public function buildForm(FormBuilderInterface $builder, array $options): void public function getBlockPrefix(): string { - return 'bitbag_sylius_cms_plugin_section_translation'; + return 'bitbag_sylius_cms_plugin_collection_translation'; } } diff --git a/src/Importer/BlockImporter.php b/src/Importer/BlockImporter.php index d0e941366..589785cb4 100644 --- a/src/Importer/BlockImporter.php +++ b/src/Importer/BlockImporter.php @@ -13,8 +13,8 @@ use BitBag\SyliusCmsPlugin\Entity\BlockInterface; use BitBag\SyliusCmsPlugin\Repository\BlockRepositoryInterface; use BitBag\SyliusCmsPlugin\Resolver\ImporterChannelsResolverInterface; +use BitBag\SyliusCmsPlugin\Resolver\ImporterCollectionsResolverInterface; use BitBag\SyliusCmsPlugin\Resolver\ImporterProductsResolverInterface; -use BitBag\SyliusCmsPlugin\Resolver\ImporterSectionsResolverInterface; use BitBag\SyliusCmsPlugin\Resolver\ResourceResolverInterface; use Sylius\Component\Locale\Context\LocaleContextInterface; use Symfony\Component\Validator\Validator\ValidatorInterface; @@ -25,7 +25,7 @@ final class BlockImporter extends AbstractImporter implements BlockImporterInter public function __construct( private ResourceResolverInterface $blockResourceResolver, private LocaleContextInterface $localeContext, - private ImporterSectionsResolverInterface $importerSectionsResolver, + private ImporterCollectionsResolverInterface $importerCollectionsResolver, private ImporterChannelsResolverInterface $importerChannelsResolver, private ImporterProductsResolverInterface $importerProductsResolver, ValidatorInterface $validator, @@ -52,7 +52,7 @@ public function import(array $row): void $block->setContent($this->getTranslatableColumnValue(self::CONTENT_COLUMN, $locale, $row)); } - $this->importerSectionsResolver->resolve($block, $this->getColumnValue(self::SECTIONS_COLUMN, $row)); + $this->importerCollectionsResolver->resolve($block, $this->getColumnValue(self::COLLECTIONS_COLUMN, $row)); $this->importerChannelsResolver->resolve($block, $this->getColumnValue(self::CHANNELS_COLUMN, $row)); $this->importerProductsResolver->resolve($block, $this->getColumnValue(self::PRODUCTS_COLUMN, $row)); diff --git a/src/Importer/BlockImporterInterface.php b/src/Importer/BlockImporterInterface.php index 5be16a7ef..21dccb04d 100644 --- a/src/Importer/BlockImporterInterface.php +++ b/src/Importer/BlockImporterInterface.php @@ -14,7 +14,7 @@ interface BlockImporterInterface extends ImporterInterface { public const CODE_COLUMN = 'code'; - public const SECTIONS_COLUMN = 'sections'; + public const COLLECTIONS_COLUMN = 'collections'; public const CHANNELS_COLUMN = 'channels'; diff --git a/src/Importer/MediaImporter.php b/src/Importer/MediaImporter.php index e5e602d65..161a4ed75 100644 --- a/src/Importer/MediaImporter.php +++ b/src/Importer/MediaImporter.php @@ -12,8 +12,8 @@ use BitBag\SyliusCmsPlugin\Entity\MediaInterface; use BitBag\SyliusCmsPlugin\Repository\MediaRepositoryInterface; +use BitBag\SyliusCmsPlugin\Resolver\ImporterCollectionsResolverInterface; use BitBag\SyliusCmsPlugin\Resolver\ImporterProductsResolverInterface; -use BitBag\SyliusCmsPlugin\Resolver\ImporterSectionsResolverInterface; use BitBag\SyliusCmsPlugin\Resolver\ResourceResolverInterface; use Sylius\Component\Locale\Context\LocaleContextInterface; use Symfony\Component\Validator\Validator\ValidatorInterface; @@ -24,7 +24,7 @@ final class MediaImporter extends AbstractImporter implements MediaImporterInter public function __construct( private ResourceResolverInterface $mediaResourceResolver, private LocaleContextInterface $localeContext, - private ImporterSectionsResolverInterface $importerSectionsResolver, + private ImporterCollectionsResolverInterface $importerCollectionsResolver, private ImporterProductsResolverInterface $importerProductsResolver, ValidatorInterface $validator, private MediaRepositoryInterface $mediaRepository, @@ -51,7 +51,7 @@ public function import(array $row): void $media->setAlt($this->getTranslatableColumnValue(self::ALT_COLUMN, $locale, $row)); } - $this->importerSectionsResolver->resolve($media, $this->getColumnValue(self::SECTIONS_COLUMN, $row)); + $this->importerCollectionsResolver->resolve($media, $this->getColumnValue(self::COLLECTIONS_COLUMN, $row)); $this->importerProductsResolver->resolve($media, $this->getColumnValue(self::PRODUCTS_COLUMN, $row)); $this->validateResource($media, ['bitbag']); diff --git a/src/Importer/MediaImporterInterface.php b/src/Importer/MediaImporterInterface.php index 7dd57f881..c48bfab11 100644 --- a/src/Importer/MediaImporterInterface.php +++ b/src/Importer/MediaImporterInterface.php @@ -16,7 +16,7 @@ interface MediaImporterInterface extends ImporterInterface public const TYPE_COLUMN = 'type'; - public const SECTIONS_COLUMN = 'sections'; + public const COLLECTIONS_COLUMN = 'collections'; public const CHANNELS_COLUMN = 'channels'; diff --git a/src/Importer/PageImporter.php b/src/Importer/PageImporter.php index bcb24b48c..06b405ae8 100644 --- a/src/Importer/PageImporter.php +++ b/src/Importer/PageImporter.php @@ -15,8 +15,8 @@ use BitBag\SyliusCmsPlugin\Entity\PageInterface; use BitBag\SyliusCmsPlugin\Entity\PageTranslationInterface; use BitBag\SyliusCmsPlugin\Resolver\ImporterChannelsResolverInterface; +use BitBag\SyliusCmsPlugin\Resolver\ImporterCollectionsResolverInterface; use BitBag\SyliusCmsPlugin\Resolver\ImporterProductsResolverInterface; -use BitBag\SyliusCmsPlugin\Resolver\ImporterSectionsResolverInterface; use BitBag\SyliusCmsPlugin\Resolver\MediaProviderResolverInterface; use BitBag\SyliusCmsPlugin\Resolver\ResourceResolverInterface; use Doctrine\ORM\EntityManagerInterface; @@ -34,7 +34,7 @@ public function __construct( private ImageDownloaderInterface $imageDownloader, private FactoryInterface $mediaFactory, private MediaProviderResolverInterface $mediaProviderResolver, - private ImporterSectionsResolverInterface $importerSectionsResolver, + private ImporterCollectionsResolverInterface $importerCollectionsResolver, private ImporterChannelsResolverInterface $importerChannelsResolver, private ImporterProductsResolverInterface $importerProductsResolver, ValidatorInterface $validator, @@ -74,7 +74,7 @@ public function import(array $row): void } } - $this->importerSectionsResolver->resolve($page, $this->getColumnValue(self::SECTIONS_COLUMN, $row)); + $this->importerCollectionsResolver->resolve($page, $this->getColumnValue(self::COLLECTIONS_COLUMN, $row)); $this->importerChannelsResolver->resolve($page, $this->getColumnValue(self::CHANNELS_COLUMN, $row)); $this->importerProductsResolver->resolve($page, $this->getColumnValue(self::PRODUCTS_COLUMN, $row)); diff --git a/src/Importer/PageImporterInterface.php b/src/Importer/PageImporterInterface.php index aa00ce707..b8da6d41c 100644 --- a/src/Importer/PageImporterInterface.php +++ b/src/Importer/PageImporterInterface.php @@ -14,7 +14,7 @@ interface PageImporterInterface extends ImporterInterface { public const CODE_COLUMN = 'code'; - public const SECTIONS_COLUMN = 'sections'; + public const COLLECTIONS_COLUMN = 'collections'; public const CHANNELS_COLUMN = 'channels'; diff --git a/src/Menu/ContentManagementMenuBuilder.php b/src/Menu/ContentManagementMenuBuilder.php index c4c5d5b4f..555d7118b 100755 --- a/src/Menu/ContentManagementMenuBuilder.php +++ b/src/Menu/ContentManagementMenuBuilder.php @@ -56,10 +56,10 @@ public function buildMenu(MenuBuilderEvent $menuBuilderEvent): void ; $cmsRootMenuItem - ->addChild('sections', [ - 'route' => 'bitbag_sylius_cms_plugin_admin_section_index', + ->addChild('collections', [ + 'route' => 'bitbag_sylius_cms_plugin_admin_collection_index', ]) - ->setLabel('bitbag_sylius_cms_plugin.ui.sections') + ->setLabel('bitbag_sylius_cms_plugin.ui.collections') ->setLabelAttribute('icon', 'grid layout') ; } diff --git a/src/Migrations/Version20240618091634.php b/src/Migrations/Version20240618091634.php new file mode 100644 index 000000000..587471f1f --- /dev/null +++ b/src/Migrations/Version20240618091634.php @@ -0,0 +1,52 @@ +addSql('CREATE TABLE bitbag_cms_section_pages (section_id INT NOT NULL, page_id INT NOT NULL, INDEX IDX_C96225EED823E37A (section_id), INDEX IDX_C96225EEC4663E4 (page_id), PRIMARY KEY(section_id, page_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE bitbag_cms_section_blocks (section_id INT NOT NULL, block_id INT NOT NULL, INDEX IDX_A9D9C974D823E37A (section_id), INDEX IDX_A9D9C974E9ED820C (block_id), PRIMARY KEY(section_id, block_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE bitbag_cms_section_media (section_id INT NOT NULL, media_id INT NOT NULL, INDEX IDX_833A6197D823E37A (section_id), INDEX IDX_833A6197EA9FDD75 (media_id), PRIMARY KEY(section_id, media_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('ALTER TABLE bitbag_cms_section_pages ADD CONSTRAINT FK_C96225EED823E37A FOREIGN KEY (section_id) REFERENCES bitbag_cms_section (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE bitbag_cms_section_pages ADD CONSTRAINT FK_C96225EEC4663E4 FOREIGN KEY (page_id) REFERENCES bitbag_cms_page (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE bitbag_cms_section_blocks ADD CONSTRAINT FK_A9D9C974D823E37A FOREIGN KEY (section_id) REFERENCES bitbag_cms_section (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE bitbag_cms_section_blocks ADD CONSTRAINT FK_A9D9C974E9ED820C FOREIGN KEY (block_id) REFERENCES bitbag_cms_block (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE bitbag_cms_section_media ADD CONSTRAINT FK_833A6197D823E37A FOREIGN KEY (section_id) REFERENCES bitbag_cms_section (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE bitbag_cms_section_media ADD CONSTRAINT FK_833A6197EA9FDD75 FOREIGN KEY (media_id) REFERENCES bitbag_cms_media (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE bitbag_cms_section ADD type VARCHAR(250) DEFAULT NULL'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('ALTER TABLE bitbag_cms_section_pages DROP FOREIGN KEY FK_C96225EED823E37A'); + $this->addSql('ALTER TABLE bitbag_cms_section_pages DROP FOREIGN KEY FK_C96225EEC4663E4'); + $this->addSql('ALTER TABLE bitbag_cms_section_blocks DROP FOREIGN KEY FK_A9D9C974D823E37A'); + $this->addSql('ALTER TABLE bitbag_cms_section_blocks DROP FOREIGN KEY FK_A9D9C974E9ED820C'); + $this->addSql('ALTER TABLE bitbag_cms_section_media DROP FOREIGN KEY FK_833A6197D823E37A'); + $this->addSql('ALTER TABLE bitbag_cms_section_media DROP FOREIGN KEY FK_833A6197EA9FDD75'); + $this->addSql('DROP TABLE bitbag_cms_section_pages'); + $this->addSql('DROP TABLE bitbag_cms_section_blocks'); + $this->addSql('DROP TABLE bitbag_cms_section_media'); + $this->addSql('ALTER TABLE bitbag_cms_section DROP type'); + } +} diff --git a/src/Repository/BlockRepository.php b/src/Repository/BlockRepository.php index 143e8066f..4d32cc427 100755 --- a/src/Repository/BlockRepository.php +++ b/src/Repository/BlockRepository.php @@ -16,6 +16,8 @@ class BlockRepository extends EntityRepository implements BlockRepositoryInterface { + use TranslationBasedAwareTrait; + public function createListQueryBuilder(string $localeCode): QueryBuilder { return $this->createQueryBuilder('o') @@ -39,21 +41,21 @@ public function findEnabledByCode(string $code, string $channelCode): ?BlockInte ; } - public function findBySectionCode( - string $sectionCode, + public function findByCollectionCode( + string $collectionCode, string $localeCode, string $channelCode, ): array { return $this->createQueryBuilder('o') ->leftJoin('o.translations', 'translation') - ->innerJoin('o.sections', 'section') + ->innerJoin('o.collections', 'collection') ->innerJoin('o.channels', 'channels') ->andWhere('translation.locale = :localeCode') - ->andWhere('section.code = :sectionCode') + ->andWhere('collection.code = :collectionCode') ->andWhere('o.enabled = true') ->andWhere('channels.code = :channelCode') ->setParameter('localeCode', $localeCode) - ->setParameter('sectionCode', $sectionCode) + ->setParameter('collectionCode', $collectionCode) ->setParameter('channelCode', $channelCode) ->getQuery() ->getResult() @@ -80,4 +82,14 @@ public function findByProductCode( ->getResult() ; } + + public function findByNamePart(string $phrase, ?string $locale = null): array + { + return $this->createTranslationBasedQueryBuilder($locale) + ->andWhere('translation.name LIKE :name') + ->setParameter('name', '%' . $phrase . '%') + ->getQuery() + ->getResult() + ; + } } diff --git a/src/Repository/BlockRepositoryInterface.php b/src/Repository/BlockRepositoryInterface.php index 53bb70c68..f84971fdf 100755 --- a/src/Repository/BlockRepositoryInterface.php +++ b/src/Repository/BlockRepositoryInterface.php @@ -20,8 +20,8 @@ public function createListQueryBuilder(string $localeCode): QueryBuilder; public function findEnabledByCode(string $code, string $channelCode): ?BlockInterface; - public function findBySectionCode( - string $sectionCode, + public function findByCollectionCode( + string $collectionCode, string $localeCode, string $channelCode, ): array; @@ -31,4 +31,6 @@ public function findByProductCode( string $localeCode, string $channelCode, ): array; + + public function findByNamePart(string $phrase, ?string $locale = null): array; } diff --git a/src/Repository/SectionRepository.php b/src/Repository/CollectionRepository.php similarity index 76% rename from src/Repository/SectionRepository.php rename to src/Repository/CollectionRepository.php index 2c1791279..65dca814c 100755 --- a/src/Repository/SectionRepository.php +++ b/src/Repository/CollectionRepository.php @@ -10,12 +10,14 @@ namespace BitBag\SyliusCmsPlugin\Repository; -use BitBag\SyliusCmsPlugin\Entity\SectionInterface; +use BitBag\SyliusCmsPlugin\Entity\CollectionInterface; use Doctrine\ORM\QueryBuilder; use Sylius\Bundle\ResourceBundle\Doctrine\ORM\EntityRepository; -class SectionRepository extends EntityRepository implements SectionRepositoryInterface +class CollectionRepository extends EntityRepository implements CollectionRepositoryInterface { + use TranslationBasedAwareTrait; + public function createListQueryBuilder(string $localeCode): QueryBuilder { return $this->createQueryBuilder('o') @@ -35,24 +37,7 @@ public function findByNamePart(string $phrase, ?string $locale = null): array ; } - private function createTranslationBasedQueryBuilder(?string $locale = null): QueryBuilder - { - $queryBuilder = $this->createQueryBuilder('o') - ->addSelect('translation') - ->leftJoin('o.translations', 'translation') - ; - - if (null !== $locale) { - $queryBuilder - ->andWhere('translation.locale = :locale') - ->setParameter('locale', $locale) - ; - } - - return $queryBuilder; - } - - public function findOneByCode(string $code, ?string $localeCode): ?SectionInterface + public function findOneByCode(string $code, ?string $localeCode): ?CollectionInterface { return $this->createQueryBuilder('o') ->leftJoin('o.translations', 'translation') diff --git a/src/Repository/SectionRepositoryInterface.php b/src/Repository/CollectionRepositoryInterface.php similarity index 84% rename from src/Repository/SectionRepositoryInterface.php rename to src/Repository/CollectionRepositoryInterface.php index 7dc03e4bf..b6fa4acdc 100755 --- a/src/Repository/SectionRepositoryInterface.php +++ b/src/Repository/CollectionRepositoryInterface.php @@ -10,17 +10,17 @@ namespace BitBag\SyliusCmsPlugin\Repository; -use BitBag\SyliusCmsPlugin\Entity\SectionInterface; +use BitBag\SyliusCmsPlugin\Entity\CollectionInterface; use Doctrine\ORM\QueryBuilder; use Sylius\Component\Resource\Repository\RepositoryInterface; -interface SectionRepositoryInterface extends RepositoryInterface +interface CollectionRepositoryInterface extends RepositoryInterface { 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 findOneByCode(string $code, ?string $localeCode): ?CollectionInterface; public function findByCodesAndLocale(string $codes, string $localeCode): array; } diff --git a/src/Repository/MediaRepository.php b/src/Repository/MediaRepository.php index e469d8844..e69ae6980 100755 --- a/src/Repository/MediaRepository.php +++ b/src/Repository/MediaRepository.php @@ -44,21 +44,21 @@ public function findOneEnabledByCode( ; } - public function findBySectionCode( - string $sectionCode, + public function findByCollectionCode( + string $collectionCode, string $localeCode, string $channelCode, ): array { return $this->createQueryBuilder('o') ->leftJoin('o.translations', 'translation') - ->innerJoin('o.sections', 'section') + ->innerJoin('o.collections', 'collection') ->innerJoin('o.channels', 'channels') ->andWhere('translation.locale = :localeCode') - ->andWhere('section.code = :sectionCode') + ->andWhere('collection.code = :collectionCode') ->andWhere('o.enabled = true') ->andWhere('channels.code = :channelCode') ->setParameter('localeCode', $localeCode) - ->setParameter('sectionCode', $sectionCode) + ->setParameter('collectionCode', $collectionCode) ->setParameter('channelCode', $channelCode) ->getQuery() ->getResult() diff --git a/src/Repository/MediaRepositoryInterface.php b/src/Repository/MediaRepositoryInterface.php index 17505e3cf..15559203b 100755 --- a/src/Repository/MediaRepositoryInterface.php +++ b/src/Repository/MediaRepositoryInterface.php @@ -24,8 +24,8 @@ public function findOneEnabledByCode( string $channelCode, ): ?MediaInterface; - public function findBySectionCode( - string $sectionCode, + public function findByCollectionCode( + string $collectionCode, string $localeCode, string $channelCode, ): array; diff --git a/src/Repository/PageRepository.php b/src/Repository/PageRepository.php index ebfa26e1a..72e449e80 100755 --- a/src/Repository/PageRepository.php +++ b/src/Repository/PageRepository.php @@ -17,12 +17,14 @@ class PageRepository extends EntityRepository implements PageRepositoryInterface { + use TranslationBasedAwareTrait; + public function createListQueryBuilder(string $localeCode): QueryBuilder { return $this->createQueryBuilder('o') ->addSelect('translation') ->leftJoin('o.translations', 'translation', 'WITH', 'translation.locale = :localeCode') - ->leftJoin('o.sections', 'sections') + ->leftJoin('o.collections', 'collections') ->setParameter('localeCode', $localeCode) ; } @@ -73,28 +75,28 @@ public function findOneEnabledBySlugAndChannelCode( ; } - public function createShopListQueryBuilder(string $sectionCode, string $channelCode): QueryBuilder + public function createShopListQueryBuilder(string $collectionCode, string $channelCode): QueryBuilder { return $this->createQueryBuilder('o') - ->innerJoin('o.sections', 'section') + ->innerJoin('o.collections', 'collection') ->innerJoin('o.channels', 'channels') - ->where('section.code = :sectionCode') + ->where('collection.code = :collectionCode') ->andWhere('o.enabled = true') ->andWhere('channels.code = :channelCode') - ->setParameter('sectionCode', $sectionCode) + ->setParameter('collectionCode', $collectionCode) ->setParameter('channelCode', $channelCode) ; } - public function findBySectionCode(string $sectionCode, ?string $localeCode): array + public function findByCollectionCode(string $collectionCode, ?string $localeCode): array { return $this->createQueryBuilder('o') ->leftJoin('o.translations', 'translation') - ->innerJoin('o.sections', 'section') + ->innerJoin('o.collections', 'collection') ->where('translation.locale = :localeCode') - ->andWhere('section.code = :sectionCode') + ->andWhere('collection.code = :collectionCode') ->andWhere('o.enabled = true') - ->setParameter('sectionCode', $sectionCode) + ->setParameter('collectionCode', $collectionCode) ->setParameter('localeCode', $localeCode) ->getQuery() ->getResult() @@ -126,22 +128,22 @@ public function findByProduct( ; } - public function findByProductAndSectionCode( + public function findByProductAndCollectionCode( ProductInterface $product, - string $sectionCode, + string $collectionCode, string $channelCode, ?\DateTimeInterface $date = null, ): array { $qb = $this->createQueryBuilder('o') ->innerJoin('o.products', 'product') - ->innerJoin('o.sections', 'section') + ->innerJoin('o.collections', 'collection') ->innerJoin('o.channels', 'channel') ->where('o.enabled = true') ->andWhere('product = :product') - ->andWhere('section.code = :sectionCode') + ->andWhere('collection.code = :collectionCode') ->andWhere('channel.code = :channelCode') ->setParameter('product', $product) - ->setParameter('sectionCode', $sectionCode) + ->setParameter('collectionCode', $collectionCode) ->setParameter('channelCode', $channelCode) ; @@ -166,4 +168,14 @@ private function addDateFilter(QueryBuilder $qb, \DateTimeInterface $date): void ->setParameter('date', $date) ; } + + public function findByNamePart(string $phrase, ?string $locale = null): array + { + return $this->createTranslationBasedQueryBuilder($locale) + ->andWhere('translation.name LIKE :name') + ->setParameter('name', '%' . $phrase . '%') + ->getQuery() + ->getResult() + ; + } } diff --git a/src/Repository/PageRepositoryInterface.php b/src/Repository/PageRepositoryInterface.php index afa541021..754fa7307 100755 --- a/src/Repository/PageRepositoryInterface.php +++ b/src/Repository/PageRepositoryInterface.php @@ -29,9 +29,9 @@ public function findOneEnabledBySlugAndChannelCode( string $channelCode, ): ?PageInterface; - public function createShopListQueryBuilder(string $sectionCode, string $channelCode): QueryBuilder; + public function createShopListQueryBuilder(string $collectionCode, string $channelCode): QueryBuilder; - public function findBySectionCode(string $sectionCode, ?string $localeCode): array; + public function findByCollectionCode(string $collectionCode, ?string $localeCode): array; public function findByProduct( ProductInterface $product, @@ -39,10 +39,12 @@ public function findByProduct( ?\DateTimeInterface $date, ): array; - public function findByProductAndSectionCode( + public function findByProductAndCollectionCode( ProductInterface $product, - string $sectionCode, + string $collectionCode, string $channelCode, ?\DateTimeInterface $date, ): array; + + public function findByNamePart(string $phrase, ?string $locale = null): array; } diff --git a/src/Repository/TranslationBasedAwareTrait.php b/src/Repository/TranslationBasedAwareTrait.php new file mode 100644 index 000000000..20d668536 --- /dev/null +++ b/src/Repository/TranslationBasedAwareTrait.php @@ -0,0 +1,33 @@ +createQueryBuilder('o') + ->addSelect('translation') + ->leftJoin('o.translations', 'translation') + ; + + if (null !== $locale) { + $queryBuilder + ->andWhere('translation.locale = :locale') + ->setParameter('locale', $locale) + ; + } + + return $queryBuilder; + } +} diff --git a/src/Resolver/ImporterCollectionsResolver.php b/src/Resolver/ImporterCollectionsResolver.php new file mode 100644 index 000000000..d803ecebc --- /dev/null +++ b/src/Resolver/ImporterCollectionsResolver.php @@ -0,0 +1,35 @@ +collectionsAssigner->assign($collectionable, $collectionCodes); + } +} diff --git a/src/Resolver/ImporterSectionsResolverInterface.php b/src/Resolver/ImporterCollectionsResolverInterface.php similarity index 65% rename from src/Resolver/ImporterSectionsResolverInterface.php rename to src/Resolver/ImporterCollectionsResolverInterface.php index 877ef441e..23c931e95 100644 --- a/src/Resolver/ImporterSectionsResolverInterface.php +++ b/src/Resolver/ImporterCollectionsResolverInterface.php @@ -10,9 +10,9 @@ namespace BitBag\SyliusCmsPlugin\Resolver; -use BitBag\SyliusCmsPlugin\Entity\SectionableInterface; +use BitBag\SyliusCmsPlugin\Entity\CollectibleInterface; -interface ImporterSectionsResolverInterface +interface ImporterCollectionsResolverInterface { - public function resolve(SectionableInterface $sectionable, ?string $sectionsRow): void; + public function resolve(CollectibleInterface $collectionable, ?string $collectionsRow): void; } diff --git a/src/Resolver/ImporterSectionsResolver.php b/src/Resolver/ImporterSectionsResolver.php deleted file mode 100644 index a97eebdec..000000000 --- a/src/Resolver/ImporterSectionsResolver.php +++ /dev/null @@ -1,35 +0,0 @@ -sectionsAssigner->assign($sectionable, $sectionCodes); - } -} diff --git a/src/Resources/assets/admin/js/bitbag/bitbag-choose-collection-type.js b/src/Resources/assets/admin/js/bitbag/bitbag-choose-collection-type.js new file mode 100644 index 000000000..f2b39f95c --- /dev/null +++ b/src/Resources/assets/admin/js/bitbag/bitbag-choose-collection-type.js @@ -0,0 +1,35 @@ +/* + * This file was created by developers working at BitBag + * Do you need more information about us and what we do? Visit our https://bitbag.io website! + * We are hiring developers from all over the world. Join us and start your new, exciting adventure and become part of us: https://bitbag.io/career +*/ + +export class HandleChooseCollectionType { + init() { + window.addEventListener('DOMContentLoaded', () => { + const typeField = document.getElementById('bitbag_sylius_cms_plugin_collection_type'); + const fields = { + page: document.getElementById('collection-type-pages'), + block: document.getElementById('collection-type-blocks'), + media: document.getElementById('collection-type-media') + }; + + const hideAllFields = () => { + Object.values(fields).forEach(field => field.style.display = 'none'); + }; + + const showField = (type) => { + hideAllFields(); + if (fields[type]) { + fields[type].style.display = 'block'; + } + }; + + showField(typeField.value); + + typeField.addEventListener('change', (event) => { + showField(event.target.value); + }); + }); + } +} diff --git a/src/Resources/assets/admin/js/bitbag/index.js b/src/Resources/assets/admin/js/bitbag/index.js index 101892e2a..5d48e0b92 100644 --- a/src/Resources/assets/admin/js/bitbag/index.js +++ b/src/Resources/assets/admin/js/bitbag/index.js @@ -2,3 +2,4 @@ export {HandleCsvUpload} from './bitbag-upload-csv'; export {HandleSlugUpdate} from './bitbag-page-slug'; export {HandlePreview} from './bitbag-cms-preview'; export {HandleAutoComplete} from './bitbag-media-autocomplete'; +export {HandleChooseCollectionType} from './bitbag-choose-collection-type'; diff --git a/src/Resources/assets/admin/js/index.js b/src/Resources/assets/admin/js/index.js index 3f4948984..d95ec1147 100644 --- a/src/Resources/assets/admin/js/index.js +++ b/src/Resources/assets/admin/js/index.js @@ -1,4 +1,10 @@ -import {HandleCsvUpload, HandleSlugUpdate, HandlePreview, HandleAutoComplete} from './bitbag'; +import { + HandleCsvUpload, + HandleSlugUpdate, + HandlePreview, + HandleAutoComplete, + HandleChooseCollectionType +} from './bitbag'; if (document.querySelector('[data-bb-target="cms-import"]')) { new HandleCsvUpload().init(); @@ -15,3 +21,7 @@ if (document.querySelectorAll('[data-bb-cms-preview-btn]').length > 0) { if (document.querySelector('[data-bb-target="cms-handle-autocomplete"]')) { new HandleAutoComplete().init(); } + +if (document.querySelector('.collection-type-items')) { + new HandleChooseCollectionType().init(); +} diff --git a/src/Resources/config/api_resources/Block.xml b/src/Resources/config/api_resources/Block.xml index 738c929ff..7e4f23d3d 100644 --- a/src/Resources/config/api_resources/Block.xml +++ b/src/Resources/config/api_resources/Block.xml @@ -36,7 +36,7 @@ - + diff --git a/src/Resources/config/api_resources/Section.xml b/src/Resources/config/api_resources/Collection.xml similarity index 75% rename from src/Resources/config/api_resources/Section.xml rename to src/Resources/config/api_resources/Collection.xml index f2b44066d..26a3340ff 100644 --- a/src/Resources/config/api_resources/Section.xml +++ b/src/Resources/config/api_resources/Collection.xml @@ -3,7 +3,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://api-platform.com/schema/metadata https://api-platform.com/schema/metadata/metadata-2.0.xsd" > - + shop:cms:read @@ -19,17 +19,17 @@ sylius - + GET - /shop/cms-plugin/sections + /shop/cms-plugin/collections - + GET - /shop/cms-plugin/sections/{id} + /shop/cms-plugin/collections/{id} diff --git a/src/Resources/config/api_resources/Media.xml b/src/Resources/config/api_resources/Media.xml index 733b47e18..3ba129221 100644 --- a/src/Resources/config/api_resources/Media.xml +++ b/src/Resources/config/api_resources/Media.xml @@ -42,7 +42,7 @@ - + diff --git a/src/Resources/config/api_resources/Page.xml b/src/Resources/config/api_resources/Page.xml index 04bd60772..d679a0969 100644 --- a/src/Resources/config/api_resources/Page.xml +++ b/src/Resources/config/api_resources/Page.xml @@ -40,7 +40,7 @@ - + diff --git a/src/Resources/config/config.yml b/src/Resources/config/config.yml index 169ee6614..311f64932 100755 --- a/src/Resources/config/config.yml +++ b/src/Resources/config/config.yml @@ -14,8 +14,8 @@ parameters: bitbag_sylius_cms_plugin.form.type.translation.page.validation_groups: "%bitbag_validation_group%" bitbag_sylius_cms_plugin.form.type.frequently_asked_question.validation_groups: "%bitbag_validation_group%" bitbag_sylius_cms_plugin.form.type.translation.frequently_asked_question.validation_groups: "%bitbag_validation_group%" - bitbag_sylius_cms_plugin.form.type.section.validation_groups: "%bitbag_validation_group%" - bitbag_sylius_cms_plugin.form.type.translation.section.validation_groups: "%bitbag_validation_group%" + bitbag_sylius_cms_plugin.form.type.collection.validation_groups: "%bitbag_validation_group%" + bitbag_sylius_cms_plugin.form.type.translation.collection.validation_groups: "%bitbag_validation_group%" bitbag_sylius_cms_plugin.form.type.translation.media.validation_groups: "%bitbag_validation_group%" bitbag_sylius_cms_plugin.form.type.media.validation_groups: "%bitbag_validation_group%" bitbag_sylius_cms_plugin.uploader.filesystem: bitbag_sylius_cms_plugin_media diff --git a/src/Resources/config/doctrine/Block.orm.xml b/src/Resources/config/doctrine/Block.orm.xml index 9cebf77ef..c176b5c25 100644 --- a/src/Resources/config/doctrine/Block.orm.xml +++ b/src/Resources/config/doctrine/Block.orm.xml @@ -14,7 +14,7 @@ - + diff --git a/src/Resources/config/doctrine/Collection.orm.xml b/src/Resources/config/doctrine/Collection.orm.xml new file mode 100644 index 000000000..1c1799b92 --- /dev/null +++ b/src/Resources/config/doctrine/Collection.orm.xml @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Resources/config/doctrine/SectionTranslation.orm.xml b/src/Resources/config/doctrine/CollectionTranslation.orm.xml similarity index 83% rename from src/Resources/config/doctrine/SectionTranslation.orm.xml rename to src/Resources/config/doctrine/CollectionTranslation.orm.xml index 0dd78094a..6a03524e5 100644 --- a/src/Resources/config/doctrine/SectionTranslation.orm.xml +++ b/src/Resources/config/doctrine/CollectionTranslation.orm.xml @@ -5,7 +5,7 @@ xsi:schemaLocation="https://doctrine-project.org/schemas/orm/doctrine-mapping https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> - + diff --git a/src/Resources/config/doctrine/Media.orm.xml b/src/Resources/config/doctrine/Media.orm.xml index 562b1a164..f6f4267ad 100644 --- a/src/Resources/config/doctrine/Media.orm.xml +++ b/src/Resources/config/doctrine/Media.orm.xml @@ -24,7 +24,7 @@ - + diff --git a/src/Resources/config/doctrine/Page.orm.xml b/src/Resources/config/doctrine/Page.orm.xml index 44e28cb8c..f03af5f64 100644 --- a/src/Resources/config/doctrine/Page.orm.xml +++ b/src/Resources/config/doctrine/Page.orm.xml @@ -25,7 +25,7 @@ - + diff --git a/src/Resources/config/doctrine/Section.orm.xml b/src/Resources/config/doctrine/Section.orm.xml deleted file mode 100644 index 29f59fff5..000000000 --- a/src/Resources/config/doctrine/Section.orm.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - diff --git a/src/Resources/config/grids/admin.yml b/src/Resources/config/grids/admin.yml index 4e25dc246..85b7a3868 100755 --- a/src/Resources/config/grids/admin.yml +++ b/src/Resources/config/grids/admin.yml @@ -2,5 +2,5 @@ imports: - { resource: "@BitBagSyliusCmsPlugin/Resources/config/grids/admin/block.yml" } - { resource: "@BitBagSyliusCmsPlugin/Resources/config/grids/admin/page.yml" } - { resource: "@BitBagSyliusCmsPlugin/Resources/config/grids/admin/frequently_asked_question.yml" } - - { resource: "@BitBagSyliusCmsPlugin/Resources/config/grids/admin/section.yml" } + - { resource: "@BitBagSyliusCmsPlugin/Resources/config/grids/admin/collection.yml" } - { resource: "@BitBagSyliusCmsPlugin/Resources/config/grids/admin/media.yml" } diff --git a/src/Resources/config/grids/admin/block.yml b/src/Resources/config/grids/admin/block.yml index 3b98296cd..759bb4af8 100755 --- a/src/Resources/config/grids/admin/block.yml +++ b/src/Resources/config/grids/admin/block.yml @@ -23,12 +23,12 @@ sylius_grid: sortable: ~ options: template: "@SyliusUi/Grid/Field/enabled.html.twig" - sections: + collections: type: twig - label: bitbag_sylius_cms_plugin.ui.sections + label: bitbag_sylius_cms_plugin.ui.collections path: . options: - template: "@BitBagSyliusCmsPlugin/Grid/Field/sections.html.twig" + template: "@BitBagSyliusCmsPlugin/Grid/Field/collections.html.twig" filters: search: type: string diff --git a/src/Resources/config/grids/admin/section.yml b/src/Resources/config/grids/admin/collection.yml similarity index 81% rename from src/Resources/config/grids/admin/section.yml rename to src/Resources/config/grids/admin/collection.yml index 293b6f460..aa66d3296 100755 --- a/src/Resources/config/grids/admin/section.yml +++ b/src/Resources/config/grids/admin/collection.yml @@ -1,10 +1,10 @@ sylius_grid: grids: - bitbag_sylius_cms_plugin_admin_section: + bitbag_sylius_cms_plugin_admin_collection: driver: name: doctrine/orm options: - class: "%bitbag_sylius_cms_plugin.model.section.class%" + class: "%bitbag_sylius_cms_plugin.model.collection.class%" repository: method: createListQueryBuilder arguments: ["%locale%"] @@ -16,6 +16,10 @@ sylius_grid: type: string label: bitbag_sylius_cms_plugin.ui.code sortable: ~ + type: + type: string + label: bitbag_sylius_cms_plugin.ui.type + sortable: ~ name: type: string label: bitbag_sylius_cms_plugin.ui.name diff --git a/src/Resources/config/grids/admin/page.yml b/src/Resources/config/grids/admin/page.yml index 16c700ab5..93d1c3efc 100755 --- a/src/Resources/config/grids/admin/page.yml +++ b/src/Resources/config/grids/admin/page.yml @@ -30,27 +30,27 @@ sylius_grid: type: string label: bitbag_sylius_cms_plugin.ui.slug sortable: translation.slug - sections: + collections: type: twig - label: bitbag_sylius_cms_plugin.ui.sections + label: bitbag_sylius_cms_plugin.ui.collections path: . options: - template: "@BitBagSyliusCmsPlugin/Grid/Field/sections.html.twig" + template: "@BitBagSyliusCmsPlugin/Grid/Field/collections.html.twig" filters: search: type: string label: sylius.ui.search options: fields: [code] - sections: + collections: type: entity - label: bitbag_sylius_cms_plugin.ui.sections + label: bitbag_sylius_cms_plugin.ui.collections form_options: - class: "%bitbag_sylius_cms_plugin.model.section.class%" + class: "%bitbag_sylius_cms_plugin.model.collection.class%" choice_label: name choice_value: code options: - fields: [sections.code] + fields: [collections.code] actions: main: import: diff --git a/src/Resources/config/grids/shop/page.yml b/src/Resources/config/grids/shop/page.yml index 55c64fd27..664414b1f 100755 --- a/src/Resources/config/grids/shop/page.yml +++ b/src/Resources/config/grids/shop/page.yml @@ -8,7 +8,7 @@ sylius_grid: repository: method: createShopListQueryBuilder arguments: - sectionCode: $sectionCode + collectionCode: $collectionCode channelCode: expr:service('sylius.context.channel').getChannel().getCode() sorting: createdAt: desc diff --git a/src/Resources/config/resources.yml b/src/Resources/config/resources.yml index 6812caa9d..df0a8c254 100755 --- a/src/Resources/config/resources.yml +++ b/src/Resources/config/resources.yml @@ -2,5 +2,5 @@ imports: - { resource: resources/block.yml } - { resource: resources/page.yml } - { resource: resources/frequently_asked_question.yml } - - { resource: resources/section.yml } + - { resource: resources/collection.yml } - { resource: resources/media.yml } diff --git a/src/Resources/config/resources/collection.yml b/src/Resources/config/resources/collection.yml new file mode 100755 index 000000000..f21b9fbbe --- /dev/null +++ b/src/Resources/config/resources/collection.yml @@ -0,0 +1,14 @@ +sylius_resource: + resources: + bitbag_sylius_cms_plugin.collection: + driver: doctrine/orm + classes: + model: BitBag\SyliusCmsPlugin\Entity\Collection + interface: BitBag\SyliusCmsPlugin\Entity\CollectionInterface + form: BitBag\SyliusCmsPlugin\Form\Type\CollectionType + repository: BitBag\SyliusCmsPlugin\Repository\CollectionRepository + factory: Sylius\Component\Resource\Factory\TranslatableFactory + translation: + classes: + model: BitBag\SyliusCmsPlugin\Entity\CollectionTranslation + interface: BitBag\SyliusCmsPlugin\Entity\CollectionTranslationInterface diff --git a/src/Resources/config/resources/section.yml b/src/Resources/config/resources/section.yml deleted file mode 100755 index 2a79787c0..000000000 --- a/src/Resources/config/resources/section.yml +++ /dev/null @@ -1,14 +0,0 @@ -sylius_resource: - resources: - bitbag_sylius_cms_plugin.section: - driver: doctrine/orm - classes: - model: BitBag\SyliusCmsPlugin\Entity\Section - interface: BitBag\SyliusCmsPlugin\Entity\SectionInterface - form: BitBag\SyliusCmsPlugin\Form\Type\SectionType - repository: BitBag\SyliusCmsPlugin\Repository\SectionRepository - factory: Sylius\Component\Resource\Factory\TranslatableFactory - translation: - classes: - model: BitBag\SyliusCmsPlugin\Entity\SectionTranslation - interface: BitBag\SyliusCmsPlugin\Entity\SectionTranslationInterface diff --git a/src/Resources/config/routing/admin.yml b/src/Resources/config/routing/admin.yml index 1bb6633ba..ce010fc3c 100755 --- a/src/Resources/config/routing/admin.yml +++ b/src/Resources/config/routing/admin.yml @@ -7,8 +7,8 @@ bitbag_sylius_cms_plugin_admin_page: bitbag_sylius_cms_plugin_admin_frequently_asked_question: resource: "@BitBagSyliusCmsPlugin/Resources/config/routing/admin/frequently_asked_question.yml" -bitbag_sylius_cms_plugin_admin_section: - resource: "@BitBagSyliusCmsPlugin/Resources/config/routing/admin/section.yml" +bitbag_sylius_cms_plugin_admin_collection: + resource: "@BitBagSyliusCmsPlugin/Resources/config/routing/admin/collection.yml" bitbag_sylius_cms_plugin_admin_media: resource: "@BitBagSyliusCmsPlugin/Resources/config/routing/admin/media.yml" diff --git a/src/Resources/config/routing/admin/block.yml b/src/Resources/config/routing/admin/block.yml index a9ea22c3e..d913040fc 100755 --- a/src/Resources/config/routing/admin/block.yml +++ b/src/Resources/config/routing/admin/block.yml @@ -27,3 +27,31 @@ bitbag_sylius_cms_plugin_admin_block_preview: _controller: bitbag_sylius_cms_plugin.controller.block::previewAction _sylius: template: "@BitBagSyliusCmsPlugin/Block/preview.html.twig" + +bitbag_sylius_cms_plugin_admin_ajax_block_by_name_phrase: + path: /ajax/blocks/search + methods: [GET] + defaults: + _format: json + _controller: bitbag_sylius_cms_plugin.controller.block::indexAction + _sylius: + serialization_groups: [Autocomplete] + permission: true + repository: + method: findByNamePart + arguments: + phrase: $phrase + locale: null + +bitbag_sylius_cms_plugin_admin_ajax_block_by_code: + path: /ajax/blocks/code + methods: [GET] + defaults: + _format: json + _controller: bitbag_sylius_cms_plugin.controller.block::indexAction + _sylius: + serialization_groups: [Autocomplete] + permission: true + repository: + method: findBy + arguments: [code: $code] diff --git a/src/Resources/config/routing/admin/section.yml b/src/Resources/config/routing/admin/collection.yml similarity index 54% rename from src/Resources/config/routing/admin/section.yml rename to src/Resources/config/routing/admin/collection.yml index 18af15ec5..df6142861 100755 --- a/src/Resources/config/routing/admin/section.yml +++ b/src/Resources/config/routing/admin/collection.yml @@ -1,28 +1,28 @@ -bitbag_sylius_cms_plugin_admin_section: +bitbag_sylius_cms_plugin_admin_collection: resource: | - alias: bitbag_sylius_cms_plugin.section + alias: bitbag_sylius_cms_plugin.collection section: admin templates: '@BitBagSyliusCmsPlugin/CrudUi' redirect: update - grid: bitbag_sylius_cms_plugin_admin_section + grid: bitbag_sylius_cms_plugin_admin_collection except: ['show'] permission: true vars: all: - header: bitbag_sylius_cms_plugin.ui.sections_header - subheader: bitbag_sylius_cms_plugin.ui.sections_subheader + header: bitbag_sylius_cms_plugin.ui.collections_header + subheader: bitbag_sylius_cms_plugin.ui.collections_subheader templates: - form: "@BitBagSyliusCmsPlugin/Section/Crud/_form.html.twig" + form: "@BitBagSyliusCmsPlugin/Collection/Crud/_form.html.twig" index: icon: grid layout type: sylius.resource -bitbag_sylius_cms_plugin_admin_ajax_section_by_name_phrase: - path: /ajax/sections/search +bitbag_sylius_cms_plugin_admin_ajax_collection_by_name_phrase: + path: /ajax/collections/search methods: [GET] defaults: _format: json - _controller: bitbag_sylius_cms_plugin.controller.section::indexAction + _controller: bitbag_sylius_cms_plugin.controller.collection::indexAction _sylius: serialization_groups: [Autocomplete] permission: true @@ -32,12 +32,12 @@ bitbag_sylius_cms_plugin_admin_ajax_section_by_name_phrase: phrase: $phrase locale: null -bitbag_sylius_cms_plugin_admin_ajax_section_by_code: - path: /ajax/sections/code +bitbag_sylius_cms_plugin_admin_ajax_collection_by_code: + path: /ajax/collections/code methods: [GET] defaults: _format: json - _controller: bitbag_sylius_cms_plugin.controller.section::indexAction + _controller: bitbag_sylius_cms_plugin.controller.collection::indexAction _sylius: serialization_groups: [Autocomplete] permission: true diff --git a/src/Resources/config/routing/admin/page.yml b/src/Resources/config/routing/admin/page.yml index d1ed40f68..042d1942f 100755 --- a/src/Resources/config/routing/admin/page.yml +++ b/src/Resources/config/routing/admin/page.yml @@ -25,3 +25,31 @@ bitbag_sylius_cms_plugin_admin_page_preview: _sylius: template: "@BitBagSyliusCmsPlugin/Page/preview.html.twig" id: null + +bitbag_sylius_cms_plugin_admin_ajax_page_by_name_phrase: + path: /ajax/pages/search + methods: [GET] + defaults: + _format: json + _controller: bitbag_sylius_cms_plugin.controller.page::indexAction + _sylius: + serialization_groups: [Autocomplete] + permission: true + repository: + method: findByNamePart + arguments: + phrase: $phrase + locale: null + +bitbag_sylius_cms_plugin_admin_ajax_page_by_code: + path: /ajax/pages/code + methods: [GET] + defaults: + _format: json + _controller: bitbag_sylius_cms_plugin.controller.page::indexAction + _sylius: + serialization_groups: [Autocomplete] + permission: true + repository: + method: findBy + arguments: [code: $code] diff --git a/src/Resources/config/routing/shop.yml b/src/Resources/config/routing/shop.yml index 596f3276e..68f2b3b7a 100755 --- a/src/Resources/config/routing/shop.yml +++ b/src/Resources/config/routing/shop.yml @@ -7,8 +7,8 @@ bitbag_sylius_cms_plugin_shop_page: bitbag_sylius_cms_plugin_shop_frequently_asked_question: resource: "@BitBagSyliusCmsPlugin/Resources/config/routing/shop/frequently_asked_question.yml" -bitbag_sylius_cms_plugin_shop_section: - resource: "@BitBagSyliusCmsPlugin/Resources/config/routing/shop/section.yml" +bitbag_sylius_cms_plugin_shop_collection: + resource: "@BitBagSyliusCmsPlugin/Resources/config/routing/shop/collection.yml" bitbag_sylius_cms_plugin_shop_media: resource: "@BitBagSyliusCmsPlugin/Resources/config/routing/shop/media.yml" diff --git a/src/Resources/config/routing/shop/block.yml b/src/Resources/config/routing/shop/block.yml index d597c0cbb..d027a36cc 100755 --- a/src/Resources/config/routing/shop/block.yml +++ b/src/Resources/config/routing/shop/block.yml @@ -9,17 +9,17 @@ bitbag_sylius_cms_plugin_shop_block_render: arguments: - $code -bitbag_sylius_cms_plugin_shop_block_index_by_section_code: - path: /blocks/section/{sectionCode} +bitbag_sylius_cms_plugin_shop_block_index_by_collection_code: + path: /blocks/collection/{collectionCode} methods: [GET] defaults: _controller: bitbag_sylius_cms_plugin.controller.block::indexAction _sylius: template: $template repository: - method: findBySectionCode + method: findByCollectionCode arguments: - - $sectionCode + - $collectionCode - "expr:service('sylius.context.locale').getLocaleCode()" - "expr:service('sylius.context.channel').getChannel().getCode()" diff --git a/src/Resources/config/routing/shop/section.yml b/src/Resources/config/routing/shop/collection.yml similarity index 63% rename from src/Resources/config/routing/shop/section.yml rename to src/Resources/config/routing/shop/collection.yml index 9c40f6185..9168e5cc0 100755 --- a/src/Resources/config/routing/shop/section.yml +++ b/src/Resources/config/routing/shop/collection.yml @@ -1,8 +1,8 @@ -bitbag_sylius_cms_plugin_shop_section_show: - path: /section/{code} +bitbag_sylius_cms_plugin_shop_collection_show: + path: /collection/{code} methods: [GET] defaults: - _controller: bitbag_sylius_cms_plugin.controller.section::showAction + _controller: bitbag_sylius_cms_plugin.controller.collection::showAction _sylius: template: $template repository: @@ -11,11 +11,11 @@ bitbag_sylius_cms_plugin_shop_section_show: - $code - "expr:service('sylius.context.locale').getLocaleCode()" -bitbag_sylius_cms_plugin_shop_section_show_codes: - path: /sections/{codes} +bitbag_sylius_cms_plugin_shop_collection_show_codes: + path: /collections/{codes} methods: [GET] defaults: - _controller: bitbag_sylius_cms_plugin.controller.section::indexAction + _controller: bitbag_sylius_cms_plugin.controller.collection::indexAction _sylius: template: $template repository: diff --git a/src/Resources/config/routing/shop/media.yml b/src/Resources/config/routing/shop/media.yml index b40e4d5c6..5f2cad417 100755 --- a/src/Resources/config/routing/shop/media.yml +++ b/src/Resources/config/routing/shop/media.yml @@ -32,17 +32,17 @@ bitbag_sylius_cms_plugin_shop_media_inline: _controller: bitbag_sylius_cms_plugin.controller.media.overriden::downloadMediaAction disposition: !php/const Symfony\Component\HttpFoundation\ResponseHeaderBag::DISPOSITION_INLINE -bitbag_sylius_cms_plugin_shop_media_index_by_section_code: - path: /media/section/{sectionCode} +bitbag_sylius_cms_plugin_shop_media_index_by_collection_code: + path: /media/collection/{collectionCode} methods: [GET] defaults: _controller: bitbag_sylius_cms_plugin.controller.media.overriden::indexAction _sylius: template: $template repository: - method: findBySectionCode + method: findByCollectionCode arguments: - - $sectionCode + - $collectionCode - "expr:service('sylius.context.locale').getLocaleCode()" - "expr:service('sylius.context.channel').getChannel().getCode()" diff --git a/src/Resources/config/routing/shop/page.yml b/src/Resources/config/routing/shop/page.yml index be23e1dfe..8057393be 100755 --- a/src/Resources/config/routing/shop/page.yml +++ b/src/Resources/config/routing/shop/page.yml @@ -25,8 +25,8 @@ bitbag_sylius_cms_plugin_shop_page_show_link_by_code: - $code - "expr:service('sylius.context.locale').getLocaleCode()" -bitbag_sylius_cms_plugin_shop_page_index_by_section_code: - path: /pages/{sectionCode} +bitbag_sylius_cms_plugin_shop_page_index_by_collection_code: + path: /pages/{collectionCode} methods: [GET] defaults: _controller: bitbag_sylius_cms_plugin.controller.page.overriden::indexAction @@ -34,26 +34,26 @@ bitbag_sylius_cms_plugin_shop_page_index_by_section_code: template: "@BitBagSyliusCmsPlugin/Shop/Page/index.html.twig" grid: bitbag_sylius_cms_plugin_shop_page repository: - method: findBySectionCode + method: findByCollectionCode arguments: - - $sectionCode + - $collectionCode - "expr:service('sylius.context.locale').getLocaleCode()" -bitbag_sylius_cms_plugin_shop_page_index_by_section_code_no_grid: - path: /pages/{sectionCode}/no-grid +bitbag_sylius_cms_plugin_shop_page_index_by_collection_code_no_grid: + path: /pages/{collectionCode}/no-grid methods: [GET] defaults: _controller: bitbag_sylius_cms_plugin.controller.page.overriden::indexAction _sylius: template: "@BitBagSyliusCmsPlugin/Shop/Page/index.html.twig" repository: - method: findBySectionCode + method: findByCollectionCode arguments: - - $sectionCode + - $collectionCode - "expr:service('sylius.context.locale').getLocaleCode()" -bitbag_sylius_cms_plugin_shop_page_index_by_section_code_template: - path: /pages-template/{sectionCode} +bitbag_sylius_cms_plugin_shop_page_index_by_collection_code_template: + path: /pages-template/{collectionCode} methods: [GET] defaults: _controller: bitbag_sylius_cms_plugin.controller.page.overriden::indexAction @@ -61,7 +61,7 @@ bitbag_sylius_cms_plugin_shop_page_index_by_section_code_template: template: $template grid: bitbag_sylius_cms_plugin_shop_page repository: - method: findBySectionCode + method: findByCollectionCode arguments: - - $sectionCode + - $collectionCode - "expr:service('sylius.context.locale').getLocaleCode()" diff --git a/src/Resources/config/serialization/Block.xml b/src/Resources/config/serialization/Block.xml index 0faacbba8..409b83860 100644 --- a/src/Resources/config/serialization/Block.xml +++ b/src/Resources/config/serialization/Block.xml @@ -13,7 +13,7 @@ shop:cms:read - + shop:cms:read diff --git a/src/Resources/config/serialization/Section.xml b/src/Resources/config/serialization/Collection.xml similarity index 89% rename from src/Resources/config/serialization/Section.xml rename to src/Resources/config/serialization/Collection.xml index bced61249..6f11af78c 100644 --- a/src/Resources/config/serialization/Section.xml +++ b/src/Resources/config/serialization/Collection.xml @@ -3,7 +3,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/serializer-mapping https://symfony.com/schema/dic/serializer-mapping/serializer-mapping-1.0.xsd" > - + shop:cms:read diff --git a/src/Resources/config/serialization/SectionTranslation.xml b/src/Resources/config/serialization/CollectionTranslation.xml similarity index 86% rename from src/Resources/config/serialization/SectionTranslation.xml rename to src/Resources/config/serialization/CollectionTranslation.xml index 505f7c914..e5ed8d09f 100644 --- a/src/Resources/config/serialization/SectionTranslation.xml +++ b/src/Resources/config/serialization/CollectionTranslation.xml @@ -3,7 +3,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/serializer-mapping https://symfony.com/schema/dic/serializer-mapping/serializer-mapping-1.0.xsd" > - + shop:cms:read diff --git a/src/Resources/config/serialization/Media.xml b/src/Resources/config/serialization/Media.xml index 61dcde6ab..cbdd96e19 100644 --- a/src/Resources/config/serialization/Media.xml +++ b/src/Resources/config/serialization/Media.xml @@ -31,7 +31,7 @@ shop:cms:read - + shop:cms:read diff --git a/src/Resources/config/serializer/Entity.Block.yml b/src/Resources/config/serializer/Entity.Block.yml new file mode 100644 index 000000000..785a05373 --- /dev/null +++ b/src/Resources/config/serializer/Entity.Block.yml @@ -0,0 +1,17 @@ +BitBag\SyliusCmsPlugin\Entity\Block: + exclusion_policy: ALL + xml_root_name: block + properties: + id: + expose: true + type: integer + xml_attribute: true + groups: [Autocomplete] + code: + expose: true + type: string + groups: [Autocomplete] + virtual_properties: + getName: + serialized_name: name + groups: [Autocomplete] diff --git a/src/Resources/config/serializer/Entity.Section.yml b/src/Resources/config/serializer/Entity.Collection.yml similarity index 84% rename from src/Resources/config/serializer/Entity.Section.yml rename to src/Resources/config/serializer/Entity.Collection.yml index 96a51ea3d..b98b6ee9a 100644 --- a/src/Resources/config/serializer/Entity.Section.yml +++ b/src/Resources/config/serializer/Entity.Collection.yml @@ -1,6 +1,6 @@ -BitBag\SyliusCmsPlugin\Entity\Section: +BitBag\SyliusCmsPlugin\Entity\Collection: exclusion_policy: ALL - xml_root_name: section + xml_root_name: collection properties: id: expose: true diff --git a/src/Resources/config/serializer/Entity.Page.yml b/src/Resources/config/serializer/Entity.Page.yml new file mode 100644 index 000000000..2bda04f44 --- /dev/null +++ b/src/Resources/config/serializer/Entity.Page.yml @@ -0,0 +1,17 @@ +BitBag\SyliusCmsPlugin\Entity\Page: + exclusion_policy: ALL + xml_root_name: page + properties: + id: + expose: true + type: integer + xml_attribute: true + groups: [Autocomplete] + code: + expose: true + type: string + groups: [Autocomplete] + virtual_properties: + getName: + serialized_name: name + groups: [Autocomplete] diff --git a/src/Resources/config/services.xml b/src/Resources/config/services.xml index a2879038d..25bcef1cb 100644 --- a/src/Resources/config/services.xml +++ b/src/Resources/config/services.xml @@ -42,6 +42,6 @@ %bitbag_sylius_cms_plugin.uploader.filesystem% - + diff --git a/src/Resources/config/services/assigner.xml b/src/Resources/config/services/assigner.xml index ae5fe46c4..f17b90ed3 100644 --- a/src/Resources/config/services/assigner.xml +++ b/src/Resources/config/services/assigner.xml @@ -16,8 +16,8 @@ - - + + diff --git a/src/Resources/config/services/fixture.xml b/src/Resources/config/services/fixture.xml index 1b862c9ca..4ec3a4558 100644 --- a/src/Resources/config/services/fixture.xml +++ b/src/Resources/config/services/fixture.xml @@ -19,8 +19,8 @@ - - + + @@ -38,7 +38,7 @@ - + @@ -48,7 +48,7 @@ - + @@ -62,10 +62,10 @@ - - - - + + + + @@ -74,7 +74,7 @@ - + diff --git a/src/Resources/config/services/form.xml b/src/Resources/config/services/form.xml index 70601a9ae..87053c778 100644 --- a/src/Resources/config/services/form.xml +++ b/src/Resources/config/services/form.xml @@ -46,15 +46,15 @@ - - %bitbag_sylius_cms_plugin.model.section.class% - %bitbag_sylius_cms_plugin.form.type.section.validation_groups% + + %bitbag_sylius_cms_plugin.model.collection.class% + %bitbag_sylius_cms_plugin.form.type.collection.validation_groups% - - %bitbag_sylius_cms_plugin.model.section_translation.class% - %bitbag_sylius_cms_plugin.form.type.translation.section.validation_groups% + + %bitbag_sylius_cms_plugin.model.collection_translation.class% + %bitbag_sylius_cms_plugin.form.type.translation.collection.validation_groups% diff --git a/src/Resources/config/services/importer.xml b/src/Resources/config/services/importer.xml index 636f252e4..c26824853 100644 --- a/src/Resources/config/services/importer.xml +++ b/src/Resources/config/services/importer.xml @@ -12,7 +12,7 @@ - + @@ -23,7 +23,7 @@ - + @@ -34,7 +34,7 @@ - + diff --git a/src/Resources/config/services/resolver.xml b/src/Resources/config/services/resolver.xml index 6fce6c8a0..17932ff16 100644 --- a/src/Resources/config/services/resolver.xml +++ b/src/Resources/config/services/resolver.xml @@ -10,9 +10,9 @@ code - - - + + + code @@ -51,8 +51,8 @@ - - + + diff --git a/src/Resources/config/services/twig.xml b/src/Resources/config/services/twig.xml index 7ab15a413..8b9593a6f 100644 --- a/src/Resources/config/services/twig.xml +++ b/src/Resources/config/services/twig.xml @@ -43,7 +43,7 @@ - + diff --git a/src/Resources/config/validation/Section.xml b/src/Resources/config/validation/Collection.xml similarity index 85% rename from src/Resources/config/validation/Section.xml rename to src/Resources/config/validation/Collection.xml index a9034efda..32e54e8db 100644 --- a/src/Resources/config/validation/Section.xml +++ b/src/Resources/config/validation/Collection.xml @@ -3,12 +3,12 @@ xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping http://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd"> - + - + @@ -16,7 +16,7 @@ - + @@ -24,15 +24,15 @@ - - + + - + diff --git a/src/Resources/config/validation/SectionTranslation.xml b/src/Resources/config/validation/CollectionTranslation.xml similarity index 84% rename from src/Resources/config/validation/SectionTranslation.xml rename to src/Resources/config/validation/CollectionTranslation.xml index 4c1bd58cc..cd00cb378 100644 --- a/src/Resources/config/validation/SectionTranslation.xml +++ b/src/Resources/config/validation/CollectionTranslation.xml @@ -3,10 +3,10 @@ xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping http://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd"> - + - + @@ -14,8 +14,8 @@ - - + + diff --git a/src/Resources/translations/messages.cs.yml b/src/Resources/translations/messages.cs.yml index 75b576807..ba4cbd5c1 100755 --- a/src/Resources/translations/messages.cs.yml +++ b/src/Resources/translations/messages.cs.yml @@ -1,7 +1,10 @@ bitbag_sylius_cms_plugin: ui: + collections: Kolekce blocks: Bloky + block: Blok pages: Stránky + page: Stránka title: Titul cms: content_management: Obsahový management diff --git a/src/Resources/translations/messages.cs_CZ.yml b/src/Resources/translations/messages.cs_CZ.yml index 75b576807..ba4cbd5c1 100755 --- a/src/Resources/translations/messages.cs_CZ.yml +++ b/src/Resources/translations/messages.cs_CZ.yml @@ -1,7 +1,10 @@ bitbag_sylius_cms_plugin: ui: + collections: Kolekce blocks: Bloky + block: Blok pages: Stránky + page: Stránka title: Titul cms: content_management: Obsahový management diff --git a/src/Resources/translations/messages.de.yml b/src/Resources/translations/messages.de.yml index 56a44c9f0..3d16cb13c 100755 --- a/src/Resources/translations/messages.de.yml +++ b/src/Resources/translations/messages.de.yml @@ -1,7 +1,9 @@ bitbag_sylius_cms_plugin: ui: blocks: Blöcke + block: Block pages: Seiten + page: Seite content_management: Inhaltsverwaltung cms: Inhaltsverwaltung enabled: Aktiviert @@ -30,9 +32,9 @@ bitbag_sylius_cms_plugin: link: Link title: Titel csv_file: CSV-Datei - sections: Sektionen - sections_header: Sektionen - sections_subheader: Verwalte deine Sektionen + collections: Sammlungen + collections_header: Sammlungen + collections_subheader: Verwalten Sie Ihre Sammlungen faq_subheader: Verwalte häufig gestellte Fragen frequently_asked_questions: Häufig gestellte Fragen question: Frage diff --git a/src/Resources/translations/messages.en.yml b/src/Resources/translations/messages.en.yml index 55eb6b00e..377eefe4b 100755 --- a/src/Resources/translations/messages.en.yml +++ b/src/Resources/translations/messages.en.yml @@ -1,7 +1,9 @@ bitbag_sylius_cms_plugin: ui: blocks: Blocks + block: Block pages: Pages + page: Page content_management: Content management cms: Content management enabled: Enabled @@ -29,9 +31,9 @@ bitbag_sylius_cms_plugin: frequently_asked_questions: Frequently asked questions question: Question answer: Answer - sections: Sections - sections_header: Sections - sections_subheader: Manage your sections + collections: Collections + collections_header: Collections + collections_subheader: Manage your collections position: Position channels: Channels preview: Preview diff --git a/src/Resources/translations/messages.es.yml b/src/Resources/translations/messages.es.yml index 158a2025f..cc481724e 100755 --- a/src/Resources/translations/messages.es.yml +++ b/src/Resources/translations/messages.es.yml @@ -1,7 +1,9 @@ bitbag_sylius_cms_plugin: ui: blocks: Bloques + block: Bloque pages: Páginas + page: Página content_management: Gestión de contenido cms: Gestión de contenido enabled: Activo @@ -30,8 +32,8 @@ bitbag_sylius_cms_plugin: frequently_asked_questions: Preguntas frecuentes question: Pregunta answer: Respuesta - sections: Secciones - sections_header: Secciones - sections_subheader: Gestiona tus secciones + collections: Colecciones + collections_header: Colecciones + collections_subheader: Gestiona tus colecciones position: Posición title: Título diff --git a/src/Resources/translations/messages.fr.yml b/src/Resources/translations/messages.fr.yml index d0a2eeb9d..904e9b1e9 100755 --- a/src/Resources/translations/messages.fr.yml +++ b/src/Resources/translations/messages.fr.yml @@ -1,7 +1,9 @@ bitbag_sylius_cms_plugin: ui: blocks: Blocs + block: Bloc pages: Pages + page: Page content_management: Gestion de contenu cms: Gestion de contenu enabled: Activée @@ -27,9 +29,9 @@ bitbag_sylius_cms_plugin: frequently_asked_questions: Questions fréquentes (FAQ) question: Question answer: Réponse - sections: Sections - sections_header: Sections - sections_subheader: Gérer vos sections + collections: Collections + collections_header: Collections + collections_subheader: Gérer vos collections position: Position channels: Canaux preview: Prévisualisation diff --git a/src/Resources/translations/messages.hr.yml b/src/Resources/translations/messages.hr.yml index c062cb7d0..c19fddac3 100755 --- a/src/Resources/translations/messages.hr.yml +++ b/src/Resources/translations/messages.hr.yml @@ -1,7 +1,9 @@ bitbag_sylius_cms_plugin: ui: blocks: Blokovi + block: Blok pages: Stranice + page: Stranica content_management: Uređivanje sadržaja cms: Uređivanje sadržaja enabled: Omogućeno @@ -30,8 +32,8 @@ bitbag_sylius_cms_plugin: frequently_asked_questions: Često postavljena pitanja question: Pitanje answer: Odgovor - sections: Kategorije - sections_header: Kategorije - sections_subheader: Uredi kategorije + collections: Kolekcije + collections_header: Kolekcije + collections_subheader: Uredi kolekcije position: Pozicija (redosljed) title: Titula diff --git a/src/Resources/translations/messages.lt.yml b/src/Resources/translations/messages.lt.yml index b25ebe8f5..055fa1245 100644 --- a/src/Resources/translations/messages.lt.yml +++ b/src/Resources/translations/messages.lt.yml @@ -1,7 +1,9 @@ bitbag_sylius_cms_plugin: ui: blocks: Blokai + block: Blokas pages: Puslapiai + page: Puslapis content_management: Turinio valdymas cms: Turinio valdymas enabled: Įjungta @@ -27,9 +29,9 @@ bitbag_sylius_cms_plugin: frequently_asked_questions: Dažniausiai užduodami klausimai question: Klausimas answer: Atsakymas - sections: Blokų grupė - sections_header: Blokų grupė - sections_subheader: Blokų grupių tvarkymas + collections: Kolekcijos + collections_header: Kolekcijos + collections_subheader: Tvarkykite savo kolekcijas position: Pozicija channels: Kanalai preview: Peržiūra diff --git a/src/Resources/translations/messages.nl.yml b/src/Resources/translations/messages.nl.yml index ddb8f49a9..59c94b119 100755 --- a/src/Resources/translations/messages.nl.yml +++ b/src/Resources/translations/messages.nl.yml @@ -1,7 +1,9 @@ bitbag_sylius_cms_plugin: ui: blocks: Blokken + block: Blok pages: Pagina's + page: Pagina content_management: Beheer inhoud cms: Beheer inhoud enabled: Ingeschakeld @@ -29,8 +31,8 @@ bitbag_sylius_cms_plugin: frequently_asked_questions: Veelgestelde vragen question: Vraag answer: Antwoord - sections: Secties - sections_header: Secties - sections_subheader: Beheer secties + collections: Collecties + collections_header: Collecties + collections_subheader: Beheer collecties position: Positie title: Titel diff --git a/src/Resources/translations/messages.pl.yml b/src/Resources/translations/messages.pl.yml index 9c3f34761..f469d53bc 100755 --- a/src/Resources/translations/messages.pl.yml +++ b/src/Resources/translations/messages.pl.yml @@ -1,7 +1,9 @@ bitbag_sylius_cms_plugin: ui: blocks: Bloki + block: Blok pages: Strony + page: Strona content_management: Zarządzanie treścią cms: Zarządzanie treścią enabled: Włączony @@ -30,9 +32,9 @@ bitbag_sylius_cms_plugin: frequently_asked_questions: Najczęściej zadawane pytania question: Pytanie answer: Odpowiedź - sections: Sekcje - sections_header: Sekcje - sections_subheader: Zarządzaj sekcjami + collections: Kolekcje + collections_header: Kolekcje + collections_subheader: Zarządzaj kolekcjami position: Pozycja title: Tytuł empty_name: Brak nazwy diff --git a/src/Resources/translations/messages.ru.yml b/src/Resources/translations/messages.ru.yml index 3459c5620..f3b82f082 100755 --- a/src/Resources/translations/messages.ru.yml +++ b/src/Resources/translations/messages.ru.yml @@ -1,7 +1,9 @@ bitbag_sylius_cms_plugin: ui: blocks: Блоки + block: Блок pages: Страницы + page: Страница content_management: Наполнение cms: Управление наполнением enabled: Вкл @@ -27,9 +29,9 @@ bitbag_sylius_cms_plugin: frequently_asked_questions: Часто задаваемые вопросы question: Вопрос answer: Ответ - sections: Разделы - sections_header: Разделы - sections_subheader: Управление разделами + collections: Коллекции + collections_header: Коллекции + collections_subheader: Управляйте своими коллекциями position: Позиция channels: Каналы preview: Предпросмотр diff --git a/src/Resources/translations/messages.sk.yml b/src/Resources/translations/messages.sk.yml index 3d6de1ee8..1185b5b14 100644 --- a/src/Resources/translations/messages.sk.yml +++ b/src/Resources/translations/messages.sk.yml @@ -1,7 +1,9 @@ bitbag_sylius_cms_plugin: ui: blocks: Bloky + block: Blok pages: Stránky + page: Stránka content_management: Správa obsahu cms: Správa obsahu enabled: Aktívny @@ -27,9 +29,9 @@ bitbag_sylius_cms_plugin: frequently_asked_questions: Časté otázky question: Otázka answer: Odpoveď - sections: Sekcie - sections_header: Sekcie - sections_subheader: Spravujte vaše sekcie + collections: Kolekcie + collections_header: Kolekcie + collections_subheader: Spravujte své sbírky position: Pozícia channels: Kanál preview: Náhľad diff --git a/src/Resources/translations/messages.uk.yml b/src/Resources/translations/messages.uk.yml index 89fb0c878..b2a528276 100755 --- a/src/Resources/translations/messages.uk.yml +++ b/src/Resources/translations/messages.uk.yml @@ -1,7 +1,9 @@ bitbag_sylius_cms_plugin: ui: blocks: Блоки + block: Блок pages: Сторінки + page: Сторінка content_management: Наповнення cms: Управління Наповненням enabled: Вкл @@ -27,9 +29,9 @@ bitbag_sylius_cms_plugin: frequently_asked_questions: FAQ question: Питання answer: Відповідь - sections: Розділи - sections_header: Розділи - sections_subheader: Управління розділами + collections: Колекції + collections_header: Колекції + collections_subheader: Керуйте своїми колекціями position: Позиція channels: Канали preview: Попередній перегляд diff --git a/src/Resources/translations/validators.cs.yml b/src/Resources/translations/validators.cs.yml index 97165ce72..6f2e129e4 100644 --- a/src/Resources/translations/validators.cs.yml +++ b/src/Resources/translations/validators.cs.yml @@ -59,9 +59,9 @@ bitbag_sylius_cms_plugin: answer: not_blank: Odpověď nemůže být prázdná. min_length: Odpověď musí obsahovat alespoň {{ limit }} znaků. - section: + collection: code: - unique: Existuje již sekce s tímto kódem. + unique: Existuje již kolekce s tímto kódem. not_blank: Kód nesmí být prázdný. min_length: Kód musí mít alespoň {{ limit }} znaků. max_length: Kód nemůže být delší než {{ limit }} znaků. diff --git a/src/Resources/translations/validators.en.yml b/src/Resources/translations/validators.en.yml index a182eada3..cd797a83e 100755 --- a/src/Resources/translations/validators.en.yml +++ b/src/Resources/translations/validators.en.yml @@ -59,13 +59,13 @@ bitbag_sylius_cms_plugin: answer: not_blank: Answer cannot be blank. min_length: Answer must be at least {{ limit }} characters long. - section: + collection: code: - unique: There is an existing section with this code. + unique: There is an existing collection with this code. not_blank: Code cannot be blank. min_length: Code must be at least {{ limit }} characters long. max_length: Code can not be longer than {{ limit }} characters. - regex: Section code can only be comprised of letters, numbers, dashes and underscores. + regex: Collection code can only be comprised of letters, numbers, dashes and underscores. name: not_blank: Name cannot be blank. min_length: Name must be at least {{ limit }} characters long. diff --git a/src/Resources/translations/validators.es.yml b/src/Resources/translations/validators.es.yml index 76f0ece39..3e889b30c 100755 --- a/src/Resources/translations/validators.es.yml +++ b/src/Resources/translations/validators.es.yml @@ -52,9 +52,9 @@ bitbag_sylius_cms_plugin: answer: not_blank: La respuesta no puede ir vacía. min_length: La respuesta debe tener al menos {{ limit }} caracteres. - section: + collection: code: - unique: Ya existe una sección con este código. + unique: Ya existe una coleccion con este código. not_blank: El código no puede ir vacío. min_length: El código debe tener al menos {{ limit }} caracteres. max_length: El código no puede tener más de {{ limit }} caracteres. diff --git a/src/Resources/translations/validators.fr.yml b/src/Resources/translations/validators.fr.yml index c5a83f8d5..9c34147e0 100755 --- a/src/Resources/translations/validators.fr.yml +++ b/src/Resources/translations/validators.fr.yml @@ -56,9 +56,9 @@ bitbag_sylius_cms_plugin: answer: not_blank: La réponse ne peut pas être vide. min_length: La réponse doit faire au moins {{ limit }} caractères. - section: + collection: code: - unique: Il existe déjà une section avec ce code. + unique: Il existe déjà une collection avec ce code. not_blank: Le code ne peut pas être vide. min_length: Le code doit faire au moins {{ limit }} caractères. max_length: Le code ne peut pas dépasser {{ limit }} caractères. diff --git a/src/Resources/translations/validators.hr.yml b/src/Resources/translations/validators.hr.yml index 4f4e8512c..34197f151 100755 --- a/src/Resources/translations/validators.hr.yml +++ b/src/Resources/translations/validators.hr.yml @@ -52,9 +52,9 @@ bitbag_sylius_cms_plugin: answer: not_blank: Odgovor ne može biti prazan. min_length: Odgovor mora sadržavati minimalno {{ limit }} znaka. - section: + collection: code: - unique: Postoji kategorija sa istim kodom. + unique: Postoji kolekcija sa istim kodom. not_blank: Kod ne može biti prazan. min_length: Kod mora sadržavati minimalno {{ limit }} znaka. max_length: Kod ne može biti duži od {{ limit }} znakova. diff --git a/src/Resources/translations/validators.lt.yml b/src/Resources/translations/validators.lt.yml index af148ddfe..a0bfc9a4a 100644 --- a/src/Resources/translations/validators.lt.yml +++ b/src/Resources/translations/validators.lt.yml @@ -56,9 +56,9 @@ bitbag_sylius_cms_plugin: answer: not_blank: Atsakymą įvesti privaloma. min_length: Atsakymo ilgis turi būti bent {{ limit }} simb. - section: + collection: code: - unique: Blokų grupė su tokiu kodu jau egzistuoja. + unique: Yra kolekcija su šiuo kodu. not_blank: Kodą įvesti privaloma. min_length: Kodo ilgis turi būti bent {{ limit }} simb. max_length: Kodas negali būti ilgesnis nei {{ limit }} simb. diff --git a/src/Resources/translations/validators.nl.yml b/src/Resources/translations/validators.nl.yml index 43919988a..cc7a415d0 100755 --- a/src/Resources/translations/validators.nl.yml +++ b/src/Resources/translations/validators.nl.yml @@ -52,9 +52,9 @@ bitbag_sylius_cms_plugin: answer: not_blank: Antwoord is verplicht en mag niet leeg zijn. min_length: Antwoord moet minstens {{ limit }} tekens lang zijn. - section: + collection: code: - unique: Er bestaat al een sectie met deze code. + unique: Er bestaat al een collectie met deze code. not_blank: Code is verplicht en mag niet leeg zijn. min_length: Code moet minstens {{ limit }} tekens lang zijn. max_length: Code mag niet langer zijn dan {{ limit }} tekens. diff --git a/src/Resources/translations/validators.pl.yml b/src/Resources/translations/validators.pl.yml index 43c7ac5aa..f84036487 100755 --- a/src/Resources/translations/validators.pl.yml +++ b/src/Resources/translations/validators.pl.yml @@ -52,7 +52,7 @@ bitbag_sylius_cms_plugin: answer: not_blank: Answer cannot be blank. min_length: Answer must be at least {{ limit }} characters long. - section: + collection: code: unique: There is an existing section with this code. not_blank: Code cannot be blank. diff --git a/src/Resources/translations/validators.ru.yml b/src/Resources/translations/validators.ru.yml index 60a297340..2f1507bb2 100755 --- a/src/Resources/translations/validators.ru.yml +++ b/src/Resources/translations/validators.ru.yml @@ -52,9 +52,9 @@ bitbag_sylius_cms_plugin: answer: not_blank: Ответ не может быть пустым. min_length: Ответ должен быть длиной хотя бы {{ limit }} знаков. - section: + collection: code: - unique: Раздел с таким кодом уже существет. + unique: Существует существующая коллекция с этим кодом. not_blank: Код не может быть пустым. min_length: Код должен быть длиной хотя бы {{ limit }} знаков. max_length: Код не может быть длиннее {{ limit }} знаков. diff --git a/src/Resources/translations/validators.sk.yml b/src/Resources/translations/validators.sk.yml index 337ae8e02..8239c59d0 100755 --- a/src/Resources/translations/validators.sk.yml +++ b/src/Resources/translations/validators.sk.yml @@ -56,9 +56,9 @@ bitbag_sylius_cms_plugin: answer: not_blank: Odpoveď nesmie byť prázdna. min_length: Odpoveď musí mať najmenej {{ limit }} znakov. - section: + collection: code: - unique: Sekcia s týmto kódom už existuje. + unique: Kolekce s týmto kódom už existuje. not_blank: Kód nesmie byť prázdny. min_length: Kód musí mať najmenej {{ limit }} znakov. max_length: Kód nesmie mať viac ako {{ limit }} znakov. diff --git a/src/Resources/translations/validators.uk.yml b/src/Resources/translations/validators.uk.yml index 7502d94e7..9e7e901f4 100755 --- a/src/Resources/translations/validators.uk.yml +++ b/src/Resources/translations/validators.uk.yml @@ -52,9 +52,9 @@ bitbag_sylius_cms_plugin: answer: not_blank: Відповідь не може бути порожньою. min_length: Відповідь має бути довжиною хоча б {{ limit }} знаків. - section: + collection: code: - unique: Розділ з таким кодом уже існує. + unique: Існує колекція з цим кодом. not_blank: Код не може бути порожнім. min_length: Код має бути довжиною хоча б {{ limit }} знаків. max_length: Код не може бути довшим за {{ limit }} знаків. diff --git a/src/Resources/views/Block/Crud/_form.html.twig b/src/Resources/views/Block/Crud/_form.html.twig index 0af0ed0f5..979e42571 100755 --- a/src/Resources/views/Block/Crud/_form.html.twig +++ b/src/Resources/views/Block/Crud/_form.html.twig @@ -11,12 +11,12 @@ {{ form_row(form.enabled) }} {{ form_row(form.products) }} {{ form_row(form.taxons) }} - {{ form_row(form.sections) }} + {{ form_row(form.collections) }} {{ form_row(form.channels) }} - diff --git a/src/Resources/views/Collection/Crud/_form.html.twig b/src/Resources/views/Collection/Crud/_form.html.twig new file mode 100755 index 000000000..dbdd2f157 --- /dev/null +++ b/src/Resources/views/Collection/Crud/_form.html.twig @@ -0,0 +1,30 @@ +{% from '@SyliusAdmin/Macro/translationForm.html.twig' import translationForm %} +{% form_theme form '@BitBagSyliusCmsPlugin/Form/theme.html.twig' %} + +{{ form_errors(form) }} + +
+
+
+ {{ form_row(form.code) }} + {{ form_row(form.type) }} +
+
+
+ {{ form_row(form.pages) }} +
+
+ {{ form_row(form.blocks) }} +
+
+ {{ form_row(form.media) }} +
+
+
+
+ +
+
+ {{ translationForm(form.translations) }} +
+
diff --git a/src/Resources/views/Form/theme.html.twig b/src/Resources/views/Form/theme.html.twig index 1693acf61..6df30e724 100755 --- a/src/Resources/views/Form/theme.html.twig +++ b/src/Resources/views/Form/theme.html.twig @@ -1,11 +1,19 @@ {% extends '@SyliusUi/Form/theme.html.twig' %} -{% block bitbag_section_autocomplete_choice_row %} - {{ form_row(form, {'remote_url': path('bitbag_sylius_cms_plugin_admin_ajax_section_by_name_phrase'), 'load_edit_url': path('bitbag_sylius_cms_plugin_admin_ajax_section_by_code')}) }} +{% block bitbag_collection_autocomplete_choice_row %} + {{ form_row(form, {'remote_url': path('bitbag_sylius_cms_plugin_admin_ajax_collection_by_name_phrase'), 'load_edit_url': path('bitbag_sylius_cms_plugin_admin_ajax_collection_by_code')}) }} +{% endblock %} + +{% block bitbag_page_autocomplete_choice_row %} + {{ form_row(form, {'remote_url': path('bitbag_sylius_cms_plugin_admin_ajax_page_by_name_phrase'), 'load_edit_url': path('bitbag_sylius_cms_plugin_admin_ajax_page_by_code')}) }} +{% endblock %} + +{% block bitbag_block_autocomplete_choice_row %} + {{ form_row(form, {'remote_url': path('bitbag_sylius_cms_plugin_admin_ajax_block_by_name_phrase'), 'load_edit_url': path('bitbag_sylius_cms_plugin_admin_ajax_block_by_code')}) }} {% endblock %} {% block bitbag_media_autocomplete_choice_row %} -
- -
-
- {{ translationForm(form.translations) }} -
-
diff --git a/src/Resources/views/Shop/Page/Index/_section.html.twig b/src/Resources/views/Shop/Page/Index/_collection.html.twig similarity index 52% rename from src/Resources/views/Shop/Page/Index/_section.html.twig rename to src/Resources/views/Shop/Page/Index/_collection.html.twig index ff9a3dbd8..2e23dfae2 100755 --- a/src/Resources/views/Shop/Page/Index/_section.html.twig +++ b/src/Resources/views/Shop/Page/Index/_collection.html.twig @@ -1,3 +1,3 @@

- {{ section.name }} + {{ collection.name }}

diff --git a/src/Resources/views/Shop/Page/Show/_collections.html.twig b/src/Resources/views/Shop/Page/Show/_collections.html.twig new file mode 100755 index 000000000..0dd9e995d --- /dev/null +++ b/src/Resources/views/Shop/Page/Show/_collections.html.twig @@ -0,0 +1,6 @@ +{% if page.collections|length > 0 %} + {{ 'bitbag_sylius_cms_plugin.ui.collections'|trans }}: + {% for collection in page.collections %} +
{{ collection.name }} + {% endfor %} +{% endif %} diff --git a/src/Resources/views/Shop/Page/Show/_sections.html.twig b/src/Resources/views/Shop/Page/Show/_sections.html.twig deleted file mode 100755 index 1634ea25d..000000000 --- a/src/Resources/views/Shop/Page/Show/_sections.html.twig +++ /dev/null @@ -1,6 +0,0 @@ -{% if page.sections|length > 0 %} - {{ 'bitbag_sylius_cms_plugin.ui.sections'|trans }}: - {% for section in page.sections %} - {{ section.name }} - {% endfor %} -{% endif %} diff --git a/src/Resources/views/Shop/Page/index.html.twig b/src/Resources/views/Shop/Page/index.html.twig index c34ffc0f3..8ba4ac47c 100755 --- a/src/Resources/views/Shop/Page/index.html.twig +++ b/src/Resources/views/Shop/Page/index.html.twig @@ -5,7 +5,7 @@ {% block content %} {% if resources.data|length > 0 %} - {{ render(path('bitbag_sylius_cms_plugin_shop_section_show', {'code' : app.request.get('sectionCode'), 'template' : '@BitBagSyliusCmsPlugin/Shop/Page/Index/_section.html.twig'})) }} + {{ render(path('bitbag_sylius_cms_plugin_shop_collection_show', {'code' : app.request.get('collectionCode'), 'template' : '@BitBagSyliusCmsPlugin/Shop/Page/Index/_collection.html.twig'})) }} {% endif %}
diff --git a/src/Resources/views/Shop/Page/show.html.twig b/src/Resources/views/Shop/Page/show.html.twig index d36002715..a62f89963 100755 --- a/src/Resources/views/Shop/Page/show.html.twig +++ b/src/Resources/views/Shop/Page/show.html.twig @@ -42,8 +42,8 @@
{{ bitbag_cms_render_content(page) }}
-
- {% include '@BitBagSyliusCmsPlugin/Shop/Page/Show/_sections.html.twig' %} +
+ {% include '@BitBagSyliusCmsPlugin/Shop/Page/Show/_collections.html.twig' %}
{% if page.products|length > 0 %} diff --git a/src/Resources/views/Shop/Product/_pagesBySection.html.twig b/src/Resources/views/Shop/Product/_pagesByCollection.html.twig similarity index 96% rename from src/Resources/views/Shop/Product/_pagesBySection.html.twig rename to src/Resources/views/Shop/Product/_pagesByCollection.html.twig index 8a695a5bd..a8e01f3bc 100644 --- a/src/Resources/views/Shop/Product/_pagesBySection.html.twig +++ b/src/Resources/views/Shop/Product/_pagesByCollection.html.twig @@ -1,6 +1,6 @@ {% for column in data %}

- {{ column.section.name }} + {{ column.collection.name }}

diff --git a/src/Sorter/CollectionsSorter.php b/src/Sorter/CollectionsSorter.php new file mode 100644 index 000000000..7e03e77ad --- /dev/null +++ b/src/Sorter/CollectionsSorter.php @@ -0,0 +1,46 @@ +updateCollectionsArray($page, $result); + } + + return $result; + } + + private function updateCollectionsArray(PageInterface $page, array $currentResult): array + { + Assert::isIterable($page->getCollections()); + foreach ($page->getCollections() as $collection) { + $collectionCode = $collection->getCode(); + Assert::notNull($collectionCode); + if (!array_key_exists($collectionCode, $currentResult)) { + $currentResult[$collectionCode] = []; + $currentResult[$collectionCode]['collection'] = $collection; + } + + $currentResult[$collectionCode][] = $page; + } + + return $currentResult; + } +} diff --git a/src/Sorter/SectionsSorterInterface.php b/src/Sorter/CollectionsSorterInterface.php similarity index 79% rename from src/Sorter/SectionsSorterInterface.php rename to src/Sorter/CollectionsSorterInterface.php index 156e9ab58..1bfd479b6 100644 --- a/src/Sorter/SectionsSorterInterface.php +++ b/src/Sorter/CollectionsSorterInterface.php @@ -10,7 +10,7 @@ namespace BitBag\SyliusCmsPlugin\Sorter; -interface SectionsSorterInterface +interface CollectionsSorterInterface { - public function sortBySections(array $pages): array; + public function sortByCollections(array $pages): array; } diff --git a/src/Sorter/SectionsSorter.php b/src/Sorter/SectionsSorter.php deleted file mode 100644 index 4f32b3e9f..000000000 --- a/src/Sorter/SectionsSorter.php +++ /dev/null @@ -1,46 +0,0 @@ -updateSectionsArray($page, $result); - } - - return $result; - } - - private function updateSectionsArray(PageInterface $page, array $currentResult): array - { - Assert::isIterable($page->getSections()); - foreach ($page->getSections() as $section) { - $sectionCode = $section->getCode(); - Assert::notNull($sectionCode); - if (!array_key_exists($sectionCode, $currentResult)) { - $currentResult[$sectionCode] = []; - $currentResult[$sectionCode]['section'] = $section; - } - - $currentResult[$sectionCode][] = $page; - } - - return $currentResult; - } -} diff --git a/src/Twig/Runtime/RenderProductPagesRuntime.php b/src/Twig/Runtime/RenderProductPagesRuntime.php index ad8f0cdf7..f930ee963 100644 --- a/src/Twig/Runtime/RenderProductPagesRuntime.php +++ b/src/Twig/Runtime/RenderProductPagesRuntime.php @@ -11,7 +11,7 @@ namespace BitBag\SyliusCmsPlugin\Twig\Runtime; use BitBag\SyliusCmsPlugin\Repository\PageRepositoryInterface; -use BitBag\SyliusCmsPlugin\Sorter\SectionsSorterInterface; +use BitBag\SyliusCmsPlugin\Sorter\CollectionsSorterInterface; use Sylius\Component\Channel\Context\ChannelContextInterface; use Sylius\Component\Core\Model\ProductInterface; use Twig\Environment; @@ -23,23 +23,23 @@ public function __construct( private PageRepositoryInterface $pageRepository, private ChannelContextInterface $channelContext, private Environment $templatingEngine, - private SectionsSorterInterface $sectionsSorter, + private CollectionsSorterInterface $collectionsSorter, ) { } - public function renderProductPages(ProductInterface $product, string $sectionCode = null): string + public function renderProductPages(ProductInterface $product, string $collectionCode = null): string { $channelCode = $this->channelContext->getChannel()->getCode(); Assert::notNull($channelCode, 'Channel code for channel is null'); - if (null !== $sectionCode) { - $pages = $this->pageRepository->findByProductAndSectionCode($product, $sectionCode, $channelCode, null); + if (null !== $collectionCode) { + $pages = $this->pageRepository->findByProductAndCollectionCode($product, $collectionCode, $channelCode, null); } else { $pages = $this->pageRepository->findByProduct($product, $channelCode, null); } - $data = $this->sectionsSorter->sortBySections($pages); + $data = $this->collectionsSorter->sortByCollections($pages); - return $this->templatingEngine->render('@BitBagSyliusCmsPlugin/Shop/Product/_pagesBySection.html.twig', [ + return $this->templatingEngine->render('@BitBagSyliusCmsPlugin/Shop/Product/_pagesByCollection.html.twig', [ 'data' => $data, ]); } diff --git a/src/Twig/Runtime/RenderProductPagesRuntimeInterface.php b/src/Twig/Runtime/RenderProductPagesRuntimeInterface.php index 65bc49130..b8cb4be4b 100644 --- a/src/Twig/Runtime/RenderProductPagesRuntimeInterface.php +++ b/src/Twig/Runtime/RenderProductPagesRuntimeInterface.php @@ -15,5 +15,5 @@ interface RenderProductPagesRuntimeInterface extends RuntimeExtensionInterface { - public function renderProductPages(ProductInterface $product, string $sectionCode = null): string; + public function renderProductPages(ProductInterface $product, string $collectionCode = null): string; } diff --git a/tests/Application/config/packages/bitbag_sylius_cms_plugin.yaml b/tests/Application/config/packages/bitbag_sylius_cms_plugin.yaml index 12b0a714b..e3f397167 100644 --- a/tests/Application/config/packages/bitbag_sylius_cms_plugin.yaml +++ b/tests/Application/config/packages/bitbag_sylius_cms_plugin.yaml @@ -11,7 +11,7 @@ sylius_fixtures: orm_purger: ~ logger: ~ fixtures: - section: + collection: options: custom: blog: @@ -46,20 +46,20 @@ sylius_fixtures:
Click one of the below products to see what you can do with the blocks in your product view!
- section_info_block: + collection_info_block: channels: - "FASHION_WEB" - sections: + collections: - "products" translations: en_US: content: |
- The block you can see on the left is just a block associated with a section named Products + The block you can see on the left is just a block associated with a collection named Products

With this feature, you can render any block you want on the product page, like size table, delivery information, or even promotion banner.

It's done with a simple controller render:

-
{{ render(path('bitbag_sylius_cms_plugin_shop_block_index_by_section_code', {'sectionCode' : 'products', 'template' : '@BitBagSyliusCmsPlugin/Shop/Block/index.html.twig'})) }}
+
{{ render(path('bitbag_sylius_cms_plugin_shop_block_index_by_collection_code', {'collectionCode' : 'products', 'template' : '@BitBagSyliusCmsPlugin/Shop/Block/index.html.twig'})) }}
product_info_block: channels: - "FASHION_WEB" @@ -99,7 +99,7 @@ sylius_fixtures: lorem_ipsum: channels: - "FASHION_WEB" - sections: + collections: - "homepage" translations: en_US: @@ -191,7 +191,7 @@ sylius_fixtures: type: image path: "%fixtures_dir%/sale.jpeg" original_name: "sale.jpeg" - sections: + collections: - "products" media_with_products: type: image @@ -221,7 +221,7 @@ sylius_fixtures: - "FASHION_WEB" number: 14 products: 5 - sections: + collections: - "blog" translations: en_US: @@ -248,7 +248,7 @@ sylius_fixtures: products: 5 channels: - "FASHION_WEB" - sections: + collections: - "general" - "store" translations: diff --git a/tests/Application/templates/bundles/SyliusShopBundle/Product/show.html.twig b/tests/Application/templates/bundles/SyliusShopBundle/Product/show.html.twig index 050512ac4..ca16f8453 100755 --- a/tests/Application/templates/bundles/SyliusShopBundle/Product/show.html.twig +++ b/tests/Application/templates/bundles/SyliusShopBundle/Product/show.html.twig @@ -50,7 +50,7 @@
- {{ render(path('bitbag_sylius_cms_plugin_shop_block_index_by_section_code', {'sectionCode' : 'products', 'template' : '@BitBagSyliusCmsPlugin/Shop/Block/index.html.twig'})) }} + {{ render(path('bitbag_sylius_cms_plugin_shop_block_index_by_collection_code', {'collectionCode' : 'products', 'template' : '@BitBagSyliusCmsPlugin/Shop/Block/index.html.twig'})) }} {{ render(path('bitbag_sylius_cms_plugin_shop_block_index_by_product_code', {'productCode' : product.code, 'template' : '@BitBagSyliusCmsPlugin/Shop/Block/index.html.twig'})) }} diff --git a/tests/Application/templates/bundles/SyliusShopBundle/layout.html.twig b/tests/Application/templates/bundles/SyliusShopBundle/layout.html.twig index 4d53edd1b..a01d3ced3 100755 --- a/tests/Application/templates/bundles/SyliusShopBundle/layout.html.twig +++ b/tests/Application/templates/bundles/SyliusShopBundle/layout.html.twig @@ -105,7 +105,7 @@