From 84eff88201fcedcefb9fb57addaadd0b1332c37d Mon Sep 17 00:00:00 2001 From: jkindly Date: Tue, 18 Jun 2024 11:39:30 +0200 Subject: [PATCH 01/25] OP-320: Add possibility to select section type and fill up collection of items of this type --- src/Entity/BlockableInterface.php | 26 ++++++++++ src/Entity/BlockableTrait.php | 49 +++++++++++++++++++ src/Entity/MediableInterface.php | 26 ++++++++++ src/Entity/MediableTrait.php | 49 +++++++++++++++++++ src/Entity/PageableInterface.php | 26 ++++++++++ src/Entity/PageableTrait.php | 49 +++++++++++++++++++ src/Entity/Section.php | 24 +++++++-- src/Entity/SectionInterface.php | 11 ++++- src/Form/Type/BlockAutocompleteChoiceType.php | 48 ++++++++++++++++++ src/Form/Type/PageAutocompleteChoiceType.php | 48 ++++++++++++++++++ src/Form/Type/SectionType.php | 47 ++++++++++++++++++ src/Repository/BlockRepository.php | 12 +++++ src/Repository/BlockRepositoryInterface.php | 2 + src/Repository/PageRepository.php | 12 +++++ src/Repository/PageRepositoryInterface.php | 2 + src/Repository/SectionRepository.php | 19 +------ src/Repository/TranslationBasedAwareTrait.php | 33 +++++++++++++ src/Resources/config/doctrine/Section.orm.xml | 35 +++++++++++++ src/Resources/config/grids/admin/section.yml | 4 ++ src/Resources/config/routing/admin/block.yml | 28 +++++++++++ src/Resources/config/routing/admin/page.yml | 28 +++++++++++ .../config/serializer/Entity.Block.yml | 17 +++++++ .../config/serializer/Entity.Page.yml | 17 +++++++ src/Resources/views/Form/theme.html.twig | 10 +++- .../views/Section/Crud/_form.html.twig | 13 +++++ 25 files changed, 612 insertions(+), 23 deletions(-) create mode 100644 src/Entity/BlockableInterface.php create mode 100644 src/Entity/BlockableTrait.php create mode 100644 src/Entity/MediableInterface.php create mode 100644 src/Entity/MediableTrait.php create mode 100644 src/Entity/PageableInterface.php create mode 100644 src/Entity/PageableTrait.php create mode 100644 src/Form/Type/BlockAutocompleteChoiceType.php create mode 100644 src/Form/Type/PageAutocompleteChoiceType.php create mode 100644 src/Repository/TranslationBasedAwareTrait.php create mode 100644 src/Resources/config/serializer/Entity.Block.yml create mode 100644 src/Resources/config/serializer/Entity.Page.yml diff --git a/src/Entity/BlockableInterface.php b/src/Entity/BlockableInterface.php new file mode 100644 index 000000000..477443bbc --- /dev/null +++ b/src/Entity/BlockableInterface.php @@ -0,0 +1,26 @@ +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/MediableInterface.php b/src/Entity/MediableInterface.php new file mode 100644 index 000000000..b4fc57f15 --- /dev/null +++ b/src/Entity/MediableInterface.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/PageableInterface.php b/src/Entity/PageableInterface.php new file mode 100644 index 000000000..6271fbbb5 --- /dev/null +++ b/src/Entity/PageableInterface.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/Section.php b/src/Entity/Section.php index 12e9e81ce..6a92ad284 100755 --- a/src/Entity/Section.php +++ b/src/Entity/Section.php @@ -15,18 +15,24 @@ class Section implements SectionInterface { + use PageableTrait; + use BlockableTrait; + use MediableTrait; 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,6 +51,16 @@ 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 */ diff --git a/src/Entity/SectionInterface.php b/src/Entity/SectionInterface.php index 80687bf2e..677c9c6f2 100755 --- a/src/Entity/SectionInterface.php +++ b/src/Entity/SectionInterface.php @@ -13,12 +13,21 @@ use Sylius\Component\Resource\Model\ResourceInterface; use Sylius\Component\Resource\Model\TranslatableInterface; -interface SectionInterface extends ResourceInterface, TranslatableInterface +interface SectionInterface extends + ResourceInterface, + TranslatableInterface, + PageableInterface, + BlockableInterface, + MediableInterface { 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/Form/Type/BlockAutocompleteChoiceType.php b/src/Form/Type/BlockAutocompleteChoiceType.php new file mode 100644 index 000000000..f99a4a6fc --- /dev/null +++ b/src/Form/Type/BlockAutocompleteChoiceType.php @@ -0,0 +1,48 @@ +setDefaults([ + 'resource' => 'bitbag_sylius_cms_plugin.block', + '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_block_autocomplete_choice'; + } + + public function getParent(): string + { + return ResourceAutocompleteChoiceType::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/SectionType.php b/src/Form/Type/SectionType.php index 6ef143368..e3c886ab8 100755 --- a/src/Form/Type/SectionType.php +++ b/src/Form/Type/SectionType.php @@ -10,14 +10,24 @@ namespace BitBag\SyliusCmsPlugin\Form\Type; +use BitBag\SyliusCmsPlugin\Entity\MediaInterface; use BitBag\SyliusCmsPlugin\Form\Type\Translation\SectionTranslationType; use Sylius\Bundle\ResourceBundle\Form\Type\AbstractResourceType; use Sylius\Bundle\ResourceBundle\Form\Type\ResourceTranslationsType; +use Symfony\Component\Form\Event\PreSubmitEvent; +use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; +use Symfony\Component\Form\FormEvents; final class SectionType extends AbstractResourceType { + public const PAGE = 'page'; + + public const BLOCK = 'block'; + + public const MEDIA = 'media'; + public function buildForm(FormBuilderInterface $builder, array $options): void { $builder @@ -25,9 +35,46 @@ public function buildForm(FormBuilderInterface $builder, array $options): void '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' => SectionTranslationType::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); + }) ; } diff --git a/src/Repository/BlockRepository.php b/src/Repository/BlockRepository.php index 143e8066f..72151a208 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') @@ -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..682d8d0b7 100755 --- a/src/Repository/BlockRepositoryInterface.php +++ b/src/Repository/BlockRepositoryInterface.php @@ -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/PageRepository.php b/src/Repository/PageRepository.php index ebfa26e1a..f299ea497 100755 --- a/src/Repository/PageRepository.php +++ b/src/Repository/PageRepository.php @@ -17,6 +17,8 @@ class PageRepository extends EntityRepository implements PageRepositoryInterface { + use TranslationBasedAwareTrait; + public function createListQueryBuilder(string $localeCode): QueryBuilder { return $this->createQueryBuilder('o') @@ -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..5092aad61 100755 --- a/src/Repository/PageRepositoryInterface.php +++ b/src/Repository/PageRepositoryInterface.php @@ -45,4 +45,6 @@ public function findByProductAndSectionCode( string $channelCode, ?\DateTimeInterface $date, ): array; + + public function findByNamePart(string $phrase, ?string $locale = null): array; } diff --git a/src/Repository/SectionRepository.php b/src/Repository/SectionRepository.php index 2c1791279..99fb0998c 100755 --- a/src/Repository/SectionRepository.php +++ b/src/Repository/SectionRepository.php @@ -16,6 +16,8 @@ class SectionRepository extends EntityRepository implements SectionRepositoryInterface { + use TranslationBasedAwareTrait; + public function createListQueryBuilder(string $localeCode): QueryBuilder { return $this->createQueryBuilder('o') @@ -35,23 +37,6 @@ 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 { return $this->createQueryBuilder('o') 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/Resources/config/doctrine/Section.orm.xml b/src/Resources/config/doctrine/Section.orm.xml index 29f59fff5..5cf05687d 100644 --- a/src/Resources/config/doctrine/Section.orm.xml +++ b/src/Resources/config/doctrine/Section.orm.xml @@ -13,5 +13,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Resources/config/grids/admin/section.yml b/src/Resources/config/grids/admin/section.yml index 293b6f460..25dbf6b2b 100755 --- a/src/Resources/config/grids/admin/section.yml +++ b/src/Resources/config/grids/admin/section.yml @@ -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/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/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/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.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/views/Form/theme.html.twig b/src/Resources/views/Form/theme.html.twig index 1693acf61..849a0f047 100755 --- a/src/Resources/views/Form/theme.html.twig +++ b/src/Resources/views/Form/theme.html.twig @@ -4,8 +4,16 @@ {{ 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')}) }} {% 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 %} -
diff --git a/src/Resources/views/Section/Crud/_form.html.twig b/src/Resources/views/Section/Crud/_form.html.twig index 401fc20c0..1c8934e8e 100755 --- a/src/Resources/views/Section/Crud/_form.html.twig +++ b/src/Resources/views/Section/Crud/_form.html.twig @@ -1,4 +1,5 @@ {% from '@SyliusAdmin/Macro/translationForm.html.twig' import translationForm %} +{% form_theme form '@BitBagSyliusCmsPlugin/Form/theme.html.twig' %} {{ form_errors(form) }} @@ -6,6 +7,18 @@
{{ form_row(form.code) }} + {{ form_row(form.type) }} +
+
+
+ {{ form_row(form.pages) }} +
+
+ {{ form_row(form.blocks) }} +
+
+ {{ form_row(form.media) }} +
From 1013f0f00e513352cd265ca7eff09398a90f66e5 Mon Sep 17 00:00:00 2001 From: jkindly Date: Tue, 18 Jun 2024 11:41:17 +0200 Subject: [PATCH 02/25] OP-320: Migration --- src/Migrations/Version20240618091634.php | 52 ++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 src/Migrations/Version20240618091634.php 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'); + } +} From a2d38be7eb60492951f66be09c03b559dcce4cbe Mon Sep 17 00:00:00 2001 From: jkindly Date: Tue, 18 Jun 2024 11:41:29 +0200 Subject: [PATCH 03/25] OP-320: JavaScript part --- .../js/bitbag/bitbag-choose-section-type.js | 35 +++++++++++++++++++ src/Resources/assets/admin/js/bitbag/index.js | 1 + src/Resources/assets/admin/js/index.js | 6 +++- 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 src/Resources/assets/admin/js/bitbag/bitbag-choose-section-type.js diff --git a/src/Resources/assets/admin/js/bitbag/bitbag-choose-section-type.js b/src/Resources/assets/admin/js/bitbag/bitbag-choose-section-type.js new file mode 100644 index 000000000..3aa53a35c --- /dev/null +++ b/src/Resources/assets/admin/js/bitbag/bitbag-choose-section-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 HandleChooseSectionType { + init() { + window.addEventListener('DOMContentLoaded', () => { + const typeField = document.getElementById('bitbag_sylius_cms_plugin_section_type'); + const fields = { + page: document.getElementById('section-type-pages'), + block: document.getElementById('section-type-blocks'), + media: document.getElementById('section-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..f40f8ce46 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 {HandleChooseSectionType} from './bitbag-choose-section-type'; diff --git a/src/Resources/assets/admin/js/index.js b/src/Resources/assets/admin/js/index.js index 3f4948984..2efd774d1 100644 --- a/src/Resources/assets/admin/js/index.js +++ b/src/Resources/assets/admin/js/index.js @@ -1,4 +1,4 @@ -import {HandleCsvUpload, HandleSlugUpdate, HandlePreview, HandleAutoComplete} from './bitbag'; +import {HandleCsvUpload, HandleSlugUpdate, HandlePreview, HandleAutoComplete, HandleChooseSectionType} from './bitbag'; if (document.querySelector('[data-bb-target="cms-import"]')) { new HandleCsvUpload().init(); @@ -15,3 +15,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('.section-type-items')) { + new HandleChooseSectionType().init(); +} From 483e26d5122055db75c08cd2281ee0a89da99ea9 Mon Sep 17 00:00:00 2001 From: jkindly Date: Tue, 18 Jun 2024 11:47:17 +0200 Subject: [PATCH 04/25] OP-320: Translations --- src/Resources/translations/messages.cs.yml | 2 ++ src/Resources/translations/messages.cs_CZ.yml | 2 ++ src/Resources/translations/messages.de.yml | 2 ++ src/Resources/translations/messages.en.yml | 2 ++ src/Resources/translations/messages.es.yml | 2 ++ src/Resources/translations/messages.fr.yml | 2 ++ src/Resources/translations/messages.hr.yml | 2 ++ src/Resources/translations/messages.lt.yml | 2 ++ src/Resources/translations/messages.nl.yml | 2 ++ src/Resources/translations/messages.pl.yml | 2 ++ src/Resources/translations/messages.ru.yml | 2 ++ src/Resources/translations/messages.sk.yml | 2 ++ src/Resources/translations/messages.uk.yml | 2 ++ 13 files changed, 26 insertions(+) diff --git a/src/Resources/translations/messages.cs.yml b/src/Resources/translations/messages.cs.yml index 75b576807..17daaf77a 100755 --- a/src/Resources/translations/messages.cs.yml +++ b/src/Resources/translations/messages.cs.yml @@ -1,7 +1,9 @@ bitbag_sylius_cms_plugin: ui: 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..17daaf77a 100755 --- a/src/Resources/translations/messages.cs_CZ.yml +++ b/src/Resources/translations/messages.cs_CZ.yml @@ -1,7 +1,9 @@ bitbag_sylius_cms_plugin: ui: 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..b5849dbf3 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 diff --git a/src/Resources/translations/messages.en.yml b/src/Resources/translations/messages.en.yml index 55eb6b00e..b353653eb 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 diff --git a/src/Resources/translations/messages.es.yml b/src/Resources/translations/messages.es.yml index 158a2025f..2b3671f37 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 diff --git a/src/Resources/translations/messages.fr.yml b/src/Resources/translations/messages.fr.yml index d0a2eeb9d..abd43b695 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 diff --git a/src/Resources/translations/messages.hr.yml b/src/Resources/translations/messages.hr.yml index c062cb7d0..0c7a6a811 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 diff --git a/src/Resources/translations/messages.lt.yml b/src/Resources/translations/messages.lt.yml index b25ebe8f5..df481408b 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 diff --git a/src/Resources/translations/messages.nl.yml b/src/Resources/translations/messages.nl.yml index ddb8f49a9..1fbea9e20 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 diff --git a/src/Resources/translations/messages.pl.yml b/src/Resources/translations/messages.pl.yml index 9c3f34761..52b199710 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 diff --git a/src/Resources/translations/messages.ru.yml b/src/Resources/translations/messages.ru.yml index 3459c5620..ca26eb30c 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: Вкл diff --git a/src/Resources/translations/messages.sk.yml b/src/Resources/translations/messages.sk.yml index 3d6de1ee8..837ad3c93 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 diff --git a/src/Resources/translations/messages.uk.yml b/src/Resources/translations/messages.uk.yml index 89fb0c878..9149c4f3b 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: Вкл From 6b2e345982cb737f0c40d71c93c66c99fd8810f5 Mon Sep 17 00:00:00 2001 From: jkindly Date: Tue, 18 Jun 2024 14:49:03 +0200 Subject: [PATCH 05/25] OP-320: Changed everything related to section into collection --- spec/Assigner/SectionsAssignerSpec.php | 28 ++++----- spec/Entity/BlockSpec.php | 14 ++--- spec/Entity/MediaSpec.php | 14 ++--- spec/Entity/PageSpec.php | 14 ++--- spec/Entity/SectionSpec.php | 8 +-- spec/Entity/SectionTranslationSpec.php | 8 +-- spec/Importer/BlockImporterSpec.php | 32 +++++------ spec/Importer/MediaImporterSpec.php | 28 ++++----- spec/Importer/PageImporterSpec.php | 38 ++++++------- .../Resolver/ImporterSectionsResolverSpec.php | 18 +++--- spec/Sorter/SectionsSorterSpec.php | 44 +++++++------- .../Runtime/RenderProductPagesRuntimeSpec.php | 44 +++++++------- src/Assigner/CollectionsAssigner.php | 34 +++++++++++ ...e.php => CollectionsAssignerInterface.php} | 6 +- src/Assigner/SectionsAssigner.php | 34 ----------- src/Entity/Block.php | 4 +- src/Entity/BlockInterface.php | 2 +- src/Entity/{Section.php => Collection.php} | 20 +++---- ...nInterface.php => CollectionInterface.php} | 2 +- ...nslation.php => CollectionTranslation.php} | 2 +- ...php => CollectionTranslationInterface.php} | 2 +- ...erface.php => CollectionableInterface.php} | 14 ++--- src/Entity/CollectionableTrait.php | 49 ++++++++++++++++ src/Entity/Media.php | 4 +- src/Entity/MediaInterface.php | 2 +- src/Entity/Page.php | 4 +- src/Entity/PageInterface.php | 2 +- src/Entity/SectionableTrait.php | 49 ---------------- src/Fixture/BlockFixture.php | 2 +- ...ctionFixture.php => CollectionFixture.php} | 8 +-- src/Fixture/Factory/BlockFixtureFactory.php | 24 ++++---- .../Factory/CollectionFixtureFactory.php | 57 +++++++++++++++++++ src/Fixture/Factory/MediaFixtureFactory.php | 16 +++--- src/Fixture/Factory/PageFixtureFactory.php | 22 +++---- src/Fixture/Factory/SectionFixtureFactory.php | 57 ------------------- src/Fixture/MediaFixture.php | 2 +- src/Fixture/PageFixture.php | 2 +- src/Form/Type/BlockType.php | 2 +- ...p => CollectionAutocompleteChoiceType.php} | 6 +- .../{SectionType.php => CollectionType.php} | 8 +-- src/Form/Type/MediaType.php | 2 +- src/Form/Type/PageType.php | 2 +- ...Type.php => CollectionTranslationType.php} | 4 +- src/Importer/BlockImporter.php | 18 +++--- src/Importer/BlockImporterInterface.php | 2 +- src/Importer/MediaImporter.php | 16 +++--- src/Importer/MediaImporterInterface.php | 2 +- src/Importer/PageImporter.php | 24 ++++---- src/Importer/PageImporterInterface.php | 2 +- src/Menu/ContentManagementMenuBuilder.php | 4 +- src/Repository/BlockRepository.php | 10 ++-- src/Repository/BlockRepositoryInterface.php | 4 +- ...epository.php => CollectionRepository.php} | 6 +- ....php => CollectionRepositoryInterface.php} | 6 +- src/Repository/MediaRepository.php | 10 ++-- src/Repository/MediaRepositoryInterface.php | 4 +- src/Repository/PageRepository.php | 32 +++++------ src/Repository/PageRepositoryInterface.php | 12 ++-- src/Resolver/ImporterCollectionsResolver.php | 35 ++++++++++++ ... ImporterCollectionsResolverInterface.php} | 6 +- src/Resolver/ImporterSectionsResolver.php | 35 ------------ ...pe.js => bitbag-choose-collection-type.js} | 10 ++-- src/Resources/assets/admin/js/bitbag/index.js | 2 +- src/Resources/assets/admin/js/index.js | 12 +++- src/Resources/config/api_resources/Block.xml | 2 +- .../{Section.xml => Collection.xml} | 10 ++-- src/Resources/config/api_resources/Media.xml | 2 +- src/Resources/config/api_resources/Page.xml | 2 +- src/Resources/config/config.yml | 4 +- src/Resources/config/doctrine/Block.orm.xml | 6 +- .../{Section.orm.xml => Collection.orm.xml} | 14 ++--- ....orm.xml => CollectionTranslation.orm.xml} | 2 +- src/Resources/config/doctrine/Media.orm.xml | 6 +- src/Resources/config/doctrine/Page.orm.xml | 6 +- src/Resources/config/grids/admin.yml | 2 +- src/Resources/config/grids/admin/block.yml | 4 +- .../admin/{section.yml => collection.yml} | 4 +- src/Resources/config/grids/admin/page.yml | 10 ++-- src/Resources/config/grids/shop/page.yml | 2 +- src/Resources/config/resources.yml | 2 +- src/Resources/config/resources/collection.yml | 14 +++++ src/Resources/config/resources/section.yml | 14 ----- src/Resources/config/routing/admin.yml | 4 +- .../admin/{section.yml => collection.yml} | 20 +++---- src/Resources/config/routing/shop.yml | 4 +- src/Resources/config/routing/shop/block.yml | 8 +-- .../shop/{section.yml => collection.yml} | 12 ++-- src/Resources/config/routing/shop/media.yml | 8 +-- src/Resources/config/routing/shop/page.yml | 24 ++++---- src/Resources/config/serialization/Block.xml | 2 +- .../{Section.xml => Collection.xml} | 2 +- ...nslation.xml => CollectionTranslation.xml} | 2 +- src/Resources/config/serialization/Media.xml | 2 +- ...tity.Section.yml => Entity.Collection.yml} | 4 +- src/Resources/config/services.xml | 2 +- src/Resources/config/services/assigner.xml | 4 +- src/Resources/config/services/fixture.xml | 18 +++--- src/Resources/config/services/form.xml | 12 ++-- src/Resources/config/services/importer.xml | 6 +- src/Resources/config/services/resolver.xml | 10 ++-- src/Resources/config/services/twig.xml | 2 +- .../{Section.xml => Collection.xml} | 12 ++-- ...nslation.xml => CollectionTranslation.xml} | 8 +-- .../views/Block/Crud/_form.html.twig | 8 +-- .../Crud/_form.html.twig | 8 +-- src/Resources/views/Form/theme.html.twig | 4 +- .../views/Grid/Field/collections.html.twig | 3 + .../views/Grid/Field/sections.html.twig | 3 - .../views/Media/Crud/_form.html.twig | 2 +- src/Resources/views/Page/Crud/_form.html.twig | 2 +- ...ection.html.twig => _collection.html.twig} | 2 +- .../Shop/Page/Show/_collections.html.twig | 6 ++ .../views/Shop/Page/Show/_sections.html.twig | 6 -- src/Resources/views/Shop/Page/index.html.twig | 2 +- src/Resources/views/Shop/Page/show.html.twig | 2 +- ...html.twig => _pagesByCollection.html.twig} | 2 +- src/Sorter/CollectionsSorter.php | 46 +++++++++++++++ ...ace.php => CollectionsSorterInterface.php} | 4 +- src/Sorter/SectionsSorter.php | 46 --------------- .../Runtime/RenderProductPagesRuntime.php | 20 +++---- .../RenderProductPagesRuntimeInterface.php | 2 +- .../packages/bitbag_sylius_cms_plugin.yaml | 12 ++-- tests/Behat/Context/Api/SectionContext.php | 6 +- tests/Behat/Context/Setup/PageContext.php | 18 +++--- tests/Behat/Context/Setup/SectionContext.php | 16 +++--- .../Context/Transform/SectionContext.php | 10 ++-- .../Behat/Context/Ui/Admin/SectionContext.php | 4 +- tests/Functional/Api/SectionTest.php | 14 ++--- .../Functional/Fixture/SectionFixtureTest.php | 6 +- .../Repository/BlockRepositoryTest.php | 4 +- .../Repository/MediaRepositoryTest.php | 4 +- .../Repository/PageRepositoryTest.php | 8 +-- .../Repository/SectionRepositoryTest.php | 12 ++-- 133 files changed, 773 insertions(+), 767 deletions(-) create mode 100644 src/Assigner/CollectionsAssigner.php rename src/Assigner/{SectionsAssignerInterface.php => CollectionsAssignerInterface.php} (65%) delete mode 100644 src/Assigner/SectionsAssigner.php rename src/Entity/{Section.php => Collection.php} (71%) rename src/Entity/{SectionInterface.php => CollectionInterface.php} (95%) rename src/Entity/{SectionTranslation.php => CollectionTranslation.php} (88%) rename src/Entity/{SectionTranslationInterface.php => CollectionTranslationInterface.php} (86%) rename src/Entity/{SectionableInterface.php => CollectionableInterface.php} (51%) create mode 100755 src/Entity/CollectionableTrait.php delete mode 100755 src/Entity/SectionableTrait.php rename src/Fixture/{SectionFixture.php => CollectionFixture.php} (89%) create mode 100755 src/Fixture/Factory/CollectionFixtureFactory.php delete mode 100755 src/Fixture/Factory/SectionFixtureFactory.php rename src/Form/Type/{SectionAutocompleteChoiceType.php => CollectionAutocompleteChoiceType.php} (86%) rename src/Form/Type/{SectionType.php => CollectionType.php} (92%) rename src/Form/Type/Translation/{SectionTranslationType.php => CollectionTranslationType.php} (86%) rename src/Repository/{SectionRepository.php => CollectionRepository.php} (92%) rename src/Repository/{SectionRepositoryInterface.php => CollectionRepositoryInterface.php} (84%) create mode 100644 src/Resolver/ImporterCollectionsResolver.php rename src/Resolver/{ImporterSectionsResolverInterface.php => ImporterCollectionsResolverInterface.php} (65%) delete mode 100644 src/Resolver/ImporterSectionsResolver.php rename src/Resources/assets/admin/js/bitbag/{bitbag-choose-section-type.js => bitbag-choose-collection-type.js} (77%) rename src/Resources/config/api_resources/{Section.xml => Collection.xml} (75%) rename src/Resources/config/doctrine/{Section.orm.xml => Collection.orm.xml} (75%) rename src/Resources/config/doctrine/{SectionTranslation.orm.xml => CollectionTranslation.orm.xml} (83%) rename src/Resources/config/grids/admin/{section.yml => collection.yml} (91%) create mode 100755 src/Resources/config/resources/collection.yml delete mode 100755 src/Resources/config/resources/section.yml rename src/Resources/config/routing/admin/{section.yml => collection.yml} (63%) rename src/Resources/config/routing/shop/{section.yml => collection.yml} (63%) rename src/Resources/config/serialization/{Section.xml => Collection.xml} (89%) rename src/Resources/config/serialization/{SectionTranslation.xml => CollectionTranslation.xml} (86%) rename src/Resources/config/serializer/{Entity.Section.yml => Entity.Collection.yml} (84%) rename src/Resources/config/validation/{Section.xml => Collection.xml} (85%) rename src/Resources/config/validation/{SectionTranslation.xml => CollectionTranslation.xml} (84%) rename src/Resources/views/{Section => Collection}/Crud/_form.html.twig (79%) create mode 100755 src/Resources/views/Grid/Field/collections.html.twig delete mode 100755 src/Resources/views/Grid/Field/sections.html.twig rename src/Resources/views/Shop/Page/Index/{_section.html.twig => _collection.html.twig} (52%) create mode 100755 src/Resources/views/Shop/Page/Show/_collections.html.twig delete mode 100755 src/Resources/views/Shop/Page/Show/_sections.html.twig rename src/Resources/views/Shop/Product/{_pagesBySection.html.twig => _pagesByCollection.html.twig} (96%) create mode 100644 src/Sorter/CollectionsSorter.php rename src/Sorter/{SectionsSorterInterface.php => CollectionsSorterInterface.php} (79%) delete mode 100644 src/Sorter/SectionsSorter.php diff --git a/spec/Assigner/SectionsAssignerSpec.php b/spec/Assigner/SectionsAssignerSpec.php index 1f26784cd..9fe971c09 100644 --- a/spec/Assigner/SectionsAssignerSpec.php +++ b/spec/Assigner/SectionsAssignerSpec.php @@ -4,41 +4,41 @@ namespace spec\BitBag\SyliusCmsPlugin\Assigner; -use BitBag\SyliusCmsPlugin\Assigner\SectionsAssigner; -use BitBag\SyliusCmsPlugin\Assigner\SectionsAssignerInterface; -use BitBag\SyliusCmsPlugin\Entity\SectionableInterface; -use BitBag\SyliusCmsPlugin\Entity\SectionInterface; -use BitBag\SyliusCmsPlugin\Repository\SectionRepositoryInterface; +use BitBag\SyliusCmsPlugin\Assigner\CollectionsAssigner; +use BitBag\SyliusCmsPlugin\Assigner\CollectionsAssignerInterface; +use BitBag\SyliusCmsPlugin\Entity\CollectionableInterface; +use BitBag\SyliusCmsPlugin\Entity\CollectionInterface; +use BitBag\SyliusCmsPlugin\Repository\CollectionRepositoryInterface; use PhpSpec\ObjectBehavior; final class SectionsAssignerSpec extends ObjectBehavior { - public function let(SectionRepositoryInterface $sectionRepository): void + public function let(CollectionRepositoryInterface $sectionRepository): void { $this->beConstructedWith($sectionRepository); } public function it_is_initializable(): void { - $this->shouldHaveType(SectionsAssigner::class); + $this->shouldHaveType(CollectionsAssigner::class); } public function it_implements_sections_assigner_interface(): void { - $this->shouldHaveType(SectionsAssignerInterface::class); + $this->shouldHaveType(CollectionsAssignerInterface::class); } public function it_assigns_sections( - SectionRepositoryInterface $sectionRepository, - SectionInterface $aboutSection, - SectionInterface $blogSection, - SectionableInterface $sectionsAware + CollectionRepositoryInterface $sectionRepository, + CollectionInterface $aboutSection, + CollectionInterface $blogSection, + CollectionableInterface $sectionsAware ): void { $sectionRepository->findOneBy(['code' => 'about'])->willReturn($aboutSection); $sectionRepository->findOneBy(['code' => 'blog'])->willReturn($blogSection); - $sectionsAware->addSection($aboutSection)->shouldBeCalled(); - $sectionsAware->addSection($blogSection)->shouldBeCalled(); + $sectionsAware->addCollection($aboutSection)->shouldBeCalled(); + $sectionsAware->addCollection($blogSection)->shouldBeCalled(); $this->assign($sectionsAware, ['about', 'blog']); } diff --git a/spec/Entity/BlockSpec.php b/spec/Entity/BlockSpec.php index 782b9f5e0..412f7feca 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_sections(CollectionInterface $firstSection, CollectionInterface $secondSection): void { - $this->addSection($firstSection); - $this->hasSection($firstSection)->shouldReturn(true); + $this->addCollection($firstSection); + $this->hasCollection($firstSection)->shouldReturn(true); - $this->hasSection($secondSection)->shouldReturn(false); + $this->hasCollection($secondSection)->shouldReturn(false); - $this->removeSection($firstSection); + $this->removeCollection($firstSection); - $this->hasSection($firstSection)->shouldReturn(false); + $this->hasCollection($firstSection)->shouldReturn(false); } public function it_associates_channels(ChannelInterface $firstChannel, ChannelInterface $secondChannel): void diff --git a/spec/Entity/MediaSpec.php b/spec/Entity/MediaSpec.php index 7ff608c2d..33299ef03 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_sections(CollectionInterface $firstSection, CollectionInterface $secondSection): void { - $this->addSection($firstSection); - $this->hasSection($firstSection)->shouldReturn(true); + $this->addCollection($firstSection); + $this->hasCollection($firstSection)->shouldReturn(true); - $this->hasSection($secondSection)->shouldReturn(false); + $this->hasCollection($secondSection)->shouldReturn(false); - $this->removeSection($firstSection); + $this->removeCollection($firstSection); - $this->hasSection($firstSection)->shouldReturn(false); + $this->hasCollection($firstSection)->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..29e06ea20 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_sections(CollectionInterface $firstSection, CollectionInterface $secondSection): void { - $this->addSection($firstSection); - $this->hasSection($firstSection)->shouldReturn(true); + $this->addCollection($firstSection); + $this->hasCollection($firstSection)->shouldReturn(true); - $this->hasSection($secondSection)->shouldReturn(false); + $this->hasCollection($secondSection)->shouldReturn(false); - $this->removeSection($firstSection); + $this->removeCollection($firstSection); - $this->hasSection($firstSection)->shouldReturn(false); + $this->hasCollection($firstSection)->shouldReturn(false); } public function it_associates_channels(ChannelInterface $firstChannel, ChannelInterface $secondChannel): void diff --git a/spec/Entity/SectionSpec.php b/spec/Entity/SectionSpec.php index 99930c980..60b711421 100755 --- a/spec/Entity/SectionSpec.php +++ b/spec/Entity/SectionSpec.php @@ -10,8 +10,8 @@ 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; @@ -19,7 +19,7 @@ final class SectionSpec extends ObjectBehavior { public function it_is_initializable(): void { - $this->shouldHaveType(Section::class); + $this->shouldHaveType(Collection::class); } public function it_is_a_resource(): void @@ -29,7 +29,7 @@ public function it_is_a_resource(): void public function it_implements_section_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/SectionTranslationSpec.php index ea503732c..178a640b7 100755 --- a/spec/Entity/SectionTranslationSpec.php +++ b/spec/Entity/SectionTranslationSpec.php @@ -10,8 +10,8 @@ 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; @@ -20,7 +20,7 @@ final class SectionTranslationSpec 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/Importer/BlockImporterSpec.php b/spec/Importer/BlockImporterSpec.php index 8801d74c7..712db845f 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; @@ -24,13 +24,13 @@ final class BlockImporterSpec extends ObjectBehavior { public function let( - ResourceResolverInterface $blockResourceResolver, - LocaleContextInterface $localeContext, - ImporterSectionsResolverInterface $importerSectionsResolver, - ImporterChannelsResolverInterface $importerChannelsResolver, - ImporterProductsResolverInterface $importerProductsResolver, - ValidatorInterface $validator, - BlockRepositoryInterface $blockRepository + ResourceResolverInterface $blockResourceResolver, + LocaleContextInterface $localeContext, + ImporterCollectionsResolverInterface $importerSectionsResolver, + ImporterChannelsResolverInterface $importerChannelsResolver, + ImporterProductsResolverInterface $importerProductsResolver, + ValidatorInterface $validator, + BlockRepositoryInterface $blockRepository ) { $this->beConstructedWith( $blockResourceResolver, @@ -50,14 +50,14 @@ public function it_is_initializable() } public function it_imports_block( - ResourceResolverInterface $blockResourceResolver, - LocaleContextInterface $localeContext, - ImporterSectionsResolverInterface $importerSectionsResolver, - ImporterChannelsResolverInterface $importerChannelsResolver, - ImporterProductsResolverInterface $importerProductsResolver, - ValidatorInterface $validator, - BlockRepositoryInterface $blockRepository, - BlockInterface $block + ResourceResolverInterface $blockResourceResolver, + LocaleContextInterface $localeContext, + ImporterCollectionsResolverInterface $importerSectionsResolver, + ImporterChannelsResolverInterface $importerChannelsResolver, + ImporterProductsResolverInterface $importerProductsResolver, + ValidatorInterface $validator, + BlockRepositoryInterface $blockRepository, + BlockInterface $block ) { $row = ['name_pl' => 'name', 'content_pl' => 'content', 'link_pl' => 'link', 'code' => 'block_code']; diff --git a/spec/Importer/MediaImporterSpec.php b/spec/Importer/MediaImporterSpec.php index 2b8171d85..44ec25e92 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; @@ -23,12 +23,12 @@ final class MediaImporterSpec extends ObjectBehavior { public function let( - ResourceResolverInterface $mediaResourceResolver, - LocaleContextInterface $localeContext, - ImporterSectionsResolverInterface $importerSectionsResolver, - ImporterProductsResolverInterface $importerProductsResolver, - ValidatorInterface $validator, - MediaRepositoryInterface $mediaRepository + ResourceResolverInterface $mediaResourceResolver, + LocaleContextInterface $localeContext, + ImporterCollectionsResolverInterface $importerSectionsResolver, + ImporterProductsResolverInterface $importerProductsResolver, + ValidatorInterface $validator, + MediaRepositoryInterface $mediaRepository ) { $this->beConstructedWith( $mediaResourceResolver, @@ -47,13 +47,13 @@ public function it_is_initializable() } public function it_imports_media( - ResourceResolverInterface $mediaResourceResolver, - LocaleContextInterface $localeContext, - ImporterSectionsResolverInterface $importerSectionsResolver, - ImporterProductsResolverInterface $importerProductsResolver, - ValidatorInterface $validator, - MediaRepositoryInterface $mediaRepository, - MediaInterface $media + ResourceResolverInterface $mediaResourceResolver, + LocaleContextInterface $localeContext, + ImporterCollectionsResolverInterface $importerSectionsResolver, + ImporterProductsResolverInterface $importerProductsResolver, + ValidatorInterface $validator, + MediaRepositoryInterface $mediaRepository, + MediaInterface $media ) { $row = ['name_pl' => 'name', 'content_pl' => 'content', 'alt_pl' => 'alt', 'code' => 'media_code']; diff --git a/spec/Importer/PageImporterSpec.php b/spec/Importer/PageImporterSpec.php index 2a014971d..2ae33422c 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; @@ -27,16 +27,16 @@ final class PageImporterSpec extends ObjectBehavior { public function let( - ResourceResolverInterface $pageResourceResolver, - LocaleContextInterface $localeContext, - ImageDownloaderInterface $imageDownloader, - FactoryInterface $mediaFactory, - MediaProviderResolverInterface $mediaProviderResolver, - ImporterSectionsResolverInterface $importerSectionsResolver, - ImporterChannelsResolverInterface $importerChannelsResolver, - ImporterProductsResolverInterface $importerProductsResolver, - ValidatorInterface $validator, - EntityManagerInterface $entityManager + ResourceResolverInterface $pageResourceResolver, + LocaleContextInterface $localeContext, + ImageDownloaderInterface $imageDownloader, + FactoryInterface $mediaFactory, + MediaProviderResolverInterface $mediaProviderResolver, + ImporterCollectionsResolverInterface $importerSectionsResolver, + ImporterChannelsResolverInterface $importerChannelsResolver, + ImporterProductsResolverInterface $importerProductsResolver, + ValidatorInterface $validator, + EntityManagerInterface $entityManager ) { $this->beConstructedWith( $pageResourceResolver, @@ -59,14 +59,14 @@ public function it_is_initializable() } public function it_imports_page_no_url( - ResourceResolverInterface $pageResourceResolver, - LocaleContextInterface $localeContext, - ImporterSectionsResolverInterface $importerSectionsResolver, - ImporterChannelsResolverInterface $importerChannelsResolver, - ImporterProductsResolverInterface $importerProductsResolver, - ValidatorInterface $validator, - EntityManagerInterface $entityManager, - PageInterface $page, + ResourceResolverInterface $pageResourceResolver, + LocaleContextInterface $localeContext, + ImporterCollectionsResolverInterface $importerSectionsResolver, + ImporterChannelsResolverInterface $importerChannelsResolver, + ImporterProductsResolverInterface $importerProductsResolver, + ValidatorInterface $validator, + EntityManagerInterface $entityManager, + PageInterface $page, ) { $row = [ 'code' => 'page_code', diff --git a/spec/Resolver/ImporterSectionsResolverSpec.php b/spec/Resolver/ImporterSectionsResolverSpec.php index 83cc8dd11..73c6ba4af 100644 --- a/spec/Resolver/ImporterSectionsResolverSpec.php +++ b/spec/Resolver/ImporterSectionsResolverSpec.php @@ -10,27 +10,27 @@ namespace spec\BitBag\SyliusCmsPlugin\Resolver; -use BitBag\SyliusCmsPlugin\Assigner\SectionsAssignerInterface; -use BitBag\SyliusCmsPlugin\Entity\SectionableInterface; -use BitBag\SyliusCmsPlugin\Resolver\ImporterSectionsResolver; +use BitBag\SyliusCmsPlugin\Assigner\CollectionsAssignerInterface; +use BitBag\SyliusCmsPlugin\Entity\CollectionableInterface; +use BitBag\SyliusCmsPlugin\Resolver\ImporterCollectionsResolver; use PhpSpec\ObjectBehavior; use Prophecy\Argument; final class ImporterSectionsResolverSpec extends ObjectBehavior { - public function let(SectionsAssignerInterface $sectionsAssigner) + public function let(CollectionsAssignerInterface $sectionsAssigner) { $this->beConstructedWith($sectionsAssigner); } public function it_is_initializable() { - $this->shouldHaveType(ImporterSectionsResolver::class); + $this->shouldHaveType(ImporterCollectionsResolver::class); } public function it_resolves_sections_for_sectionable_entity( - SectionsAssignerInterface $sectionsAssigner, - SectionableInterface $sectionable + CollectionsAssignerInterface $sectionsAssigner, + CollectionableInterface $sectionable ) { $sectionsRow = 'section1, section2, section3'; $sectionCodes = ['section1', 'section2', 'section3']; @@ -41,8 +41,8 @@ public function it_resolves_sections_for_sectionable_entity( } public function it_skips_resolution_when_sections_row_is_null( - SectionsAssignerInterface $sectionsAssigner, - SectionableInterface $sectionable + CollectionsAssignerInterface $sectionsAssigner, + CollectionableInterface $sectionable ) { $sectionsRow = null; diff --git a/spec/Sorter/SectionsSorterSpec.php b/spec/Sorter/SectionsSorterSpec.php index 3b20091dd..3357f0cf3 100644 --- a/spec/Sorter/SectionsSorterSpec.php +++ b/spec/Sorter/SectionsSorterSpec.php @@ -13,9 +13,9 @@ namespace spec\BitBag\SyliusCmsPlugin\Sorter; use BitBag\SyliusCmsPlugin\Entity\PageInterface; -use BitBag\SyliusCmsPlugin\Entity\SectionInterface; -use BitBag\SyliusCmsPlugin\Sorter\SectionsSorter; -use BitBag\SyliusCmsPlugin\Sorter\SectionsSorterInterface; +use BitBag\SyliusCmsPlugin\Entity\CollectionInterface; +use BitBag\SyliusCmsPlugin\Sorter\CollectionsSorter; +use BitBag\SyliusCmsPlugin\Sorter\CollectionsSorterInterface; use Doctrine\Common\Collections\ArrayCollection; use PhpSpec\ObjectBehavior; @@ -23,20 +23,20 @@ final class SectionsSorterSpec extends ObjectBehavior { public function it_is_initializable(): void { - $this->shouldHaveType(SectionsSorter::class); + $this->shouldHaveType(CollectionsSorter::class); } public function it_implements_sections_sorter_interface(): void { - $this->shouldHaveType(SectionsSorterInterface::class); + $this->shouldHaveType(CollectionsSorterInterface::class); } public function it_sorts_sections_with_one_element( PageInterface $page, - SectionInterface $section + CollectionInterface $section ): void { $section->getCode()->willReturn('SECTION_CODE'); - $page->getSections()->willReturn(new ArrayCollection([$section->getWrappedObject()])); + $page->getCollections()->willReturn(new ArrayCollection([$section->getWrappedObject()])); $this->sortBySections([$page])->shouldReturn( [ @@ -46,22 +46,22 @@ public function it_sorts_sections_with_one_element( } public function it_sorts_sections_with_more_elements( - PageInterface $page1, - PageInterface $page2, - PageInterface $page3, - SectionInterface $section1, - SectionInterface $section2, - SectionInterface $section3 + PageInterface $page1, + PageInterface $page2, + PageInterface $page3, + CollectionInterface $section1, + CollectionInterface $section2, + CollectionInterface $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( + $page1->getCollections()->willReturn(new ArrayCollection( [$section1->getWrappedObject(), $section3->getWrappedObject()] )); - $page2->getSections()->willReturn(new ArrayCollection([$section3->getWrappedObject()])); - $page3->getSections()->willReturn(new ArrayCollection( + $page2->getCollections()->willReturn(new ArrayCollection([$section3->getWrappedObject()])); + $page3->getCollections()->willReturn(new ArrayCollection( [$section2->getWrappedObject(), $section1->getWrappedObject()] )); @@ -75,16 +75,16 @@ public function it_sorts_sections_with_more_elements( } public function it_sorts_sections_with_less_elements( - PageInterface $page1, - PageInterface $page2, - SectionInterface $section1, - SectionInterface $section2 + PageInterface $page1, + PageInterface $page2, + CollectionInterface $section1, + CollectionInterface $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()])); + $page1->getCollections()->willReturn(new ArrayCollection([$section1->getWrappedObject()])); + $page2->getCollections()->willReturn(new ArrayCollection([$section2->getWrappedObject()])); $this->sortBySections([$page1, $page2])->shouldReturn( [ diff --git a/spec/Twig/Runtime/RenderProductPagesRuntimeSpec.php b/spec/Twig/Runtime/RenderProductPagesRuntimeSpec.php index 1406b14a2..d56d1bf5d 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,7 +31,7 @@ public function let( PageRepositoryInterface $pageRepository, ChannelContextInterface $channelContext, Environment $templatingEngine, - SectionsSorterInterface $sectionsSorter + CollectionsSorterInterface $sectionsSorter ): void { $this->beConstructedWith($pageRepository, $channelContext, $templatingEngine, $sectionsSorter); } @@ -48,42 +48,42 @@ public function it_implements_render_product_pages_runtime_interface(): void public function it_renders_product_pages( ChannelContextInterface $channelContext, - ProductInterface $product, - ChannelInterface $channel, + ProductInterface $product, + ChannelInterface $channel, PageRepositoryInterface $pageRepository, - PageInterface $page, - SectionInterface $section, - Environment $templatingEngine, - SectionsSorterInterface $sectionsSorter + PageInterface $page, + CollectionInterface $section, + Environment $templatingEngine, + CollectionsSorterInterface $sectionsSorter ): void { $channel->getCode()->willReturn('WEB'); $channelContext->getChannel()->willReturn($channel); - $page->getSections()->willReturn(new ArrayCollection([$section])); + $page->getCollections()->willReturn(new ArrayCollection([$section])); $section->getCode()->willReturn('SECTION_CODE'); $pageRepository->findByProduct($product, 'WEB', null)->willReturn([])->shouldBeCalled(); - $sectionsSorter->sortBySections([])->willReturn([]); - $templatingEngine->render('@BitBagSyliusCmsPlugin/Shop/Product/_pagesBySection.html.twig', ['data' => []])->willReturn('content'); + $sectionsSorter->sortByCollections([])->willReturn([]); + $templatingEngine->render('_pagesByCollection.html.twig', ['data' => []])->willReturn('content'); $this->renderProductPages($product)->shouldReturn('content'); } public function it_renders_product_pages_with_sections( ChannelContextInterface $channelContext, - ProductInterface $product, - ChannelInterface $channel, + ProductInterface $product, + ChannelInterface $channel, PageRepositoryInterface $pageRepository, - PageInterface $page, - SectionInterface $section, - Environment $templatingEngine, - SectionsSorterInterface $sectionsSorter + PageInterface $page, + CollectionInterface $section, + Environment $templatingEngine, + CollectionsSorterInterface $sectionsSorter ): void { $channel->getCode()->willReturn('WEB'); $channelContext->getChannel()->willReturn($channel); - $page->getSections()->willReturn(new ArrayCollection([$section])); + $page->getCollections()->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'); + $pageRepository->findByProductAndCollectionCode($product, 'SECTION_CODE', 'WEB', null)->willReturn([])->shouldBeCalled(); + $sectionsSorter->sortByCollections([])->willReturn([]); + $templatingEngine->render('_pagesByCollection.html.twig', ['data' => []])->willReturn('content'); $this->renderProductPages($product, 'SECTION_CODE')->shouldReturn('content'); } diff --git a/src/Assigner/CollectionsAssigner.php b/src/Assigner/CollectionsAssigner.php new file mode 100644 index 000000000..4cb237ecd --- /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 65% rename from src/Assigner/SectionsAssignerInterface.php rename to src/Assigner/CollectionsAssignerInterface.php index ef30f7542..860b3b8d0 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\CollectionableInterface; -interface SectionsAssignerInterface +interface CollectionsAssignerInterface { - public function assign(SectionableInterface $sectionsAware, array $sectionsCodes): void; + public function assign(CollectionableInterface $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..277940816 100755 --- a/src/Entity/Block.php +++ b/src/Entity/Block.php @@ -17,7 +17,7 @@ class Block implements BlockInterface { use ToggleableTrait; - use SectionableTrait; + use CollectionableTrait; 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..e8a9d313e 100755 --- a/src/Entity/BlockInterface.php +++ b/src/Entity/BlockInterface.php @@ -21,7 +21,7 @@ interface BlockInterface extends ToggleableInterface, ProductsAwareInterface, TaxonAwareInterface, - SectionableInterface, + CollectionableInterface, ChannelsAwareInterface, ContentableInterface { diff --git a/src/Entity/Section.php b/src/Entity/Collection.php similarity index 71% rename from src/Entity/Section.php rename to src/Entity/Collection.php index 6a92ad284..bb75d9219 100755 --- a/src/Entity/Section.php +++ b/src/Entity/Collection.php @@ -13,7 +13,7 @@ use Sylius\Component\Resource\Model\TranslatableTrait; use Sylius\Component\Resource\Model\TranslationInterface; -class Section implements SectionInterface +class Collection implements CollectionInterface { use PageableTrait; use BlockableTrait; @@ -63,29 +63,29 @@ public function setType(?string $type): void 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 95% rename from src/Entity/SectionInterface.php rename to src/Entity/CollectionInterface.php index 677c9c6f2..31aa7e5ce 100755 --- a/src/Entity/SectionInterface.php +++ b/src/Entity/CollectionInterface.php @@ -13,7 +13,7 @@ use Sylius\Component\Resource\Model\ResourceInterface; use Sylius\Component\Resource\Model\TranslatableInterface; -interface SectionInterface extends +interface CollectionInterface extends ResourceInterface, TranslatableInterface, PageableInterface, 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/SectionableInterface.php b/src/Entity/CollectionableInterface.php similarity index 51% rename from src/Entity/SectionableInterface.php rename to src/Entity/CollectionableInterface.php index 11ebf7e8d..2fec26479 100755 --- a/src/Entity/SectionableInterface.php +++ b/src/Entity/CollectionableInterface.php @@ -12,18 +12,18 @@ use Doctrine\Common\Collections\Collection; -interface SectionableInterface +interface CollectionableInterface { - public function initializeSectionsCollection(): void; + public function initializeCollectionsCollection(): void; /** - * @return Collection|SectionInterface[] + * @return Collection|CollectionInterface[] */ - public function getSections(): ?Collection; + public function getCollections(): ?Collection; - public function hasSection(SectionInterface $section): bool; + public function hasCollection(CollectionInterface $collection): bool; - public function addSection(SectionInterface $section): void; + public function addCollection(CollectionInterface $collection): void; - public function removeSection(SectionInterface $section): void; + public function removeCollection(CollectionInterface $collection): void; } diff --git a/src/Entity/CollectionableTrait.php b/src/Entity/CollectionableTrait.php new file mode 100755 index 000000000..6bfc8fda5 --- /dev/null +++ b/src/Entity/CollectionableTrait.php @@ -0,0 +1,49 @@ +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/Media.php b/src/Entity/Media.php index afa9b832c..4cdc28aaa 100644 --- a/src/Entity/Media.php +++ b/src/Entity/Media.php @@ -20,7 +20,7 @@ class Media implements MediaInterface { use ToggleableTrait; - use SectionableTrait; + use CollectionableTrait; 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/MediaInterface.php b/src/Entity/MediaInterface.php index 7e93c7b78..c189a95d8 100644 --- a/src/Entity/MediaInterface.php +++ b/src/Entity/MediaInterface.php @@ -21,7 +21,7 @@ interface MediaInterface extends TranslatableInterface, ToggleableInterface, ProductsAwareInterface, - SectionableInterface, + CollectionableInterface, ChannelsAwareInterface, ContentableInterface { diff --git a/src/Entity/Page.php b/src/Entity/Page.php index 0e6a3a76e..e23180d22 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 CollectionableTrait; 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..23e7b38d4 100755 --- a/src/Entity/PageInterface.php +++ b/src/Entity/PageInterface.php @@ -22,7 +22,7 @@ interface PageInterface extends TranslatableInterface, ToggleableInterface, ProductsAwareInterface, - SectionableInterface, + CollectionableInterface, TimestampableInterface, ChannelsAwareInterface, ContentableInterface, 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..9506f18e5 100755 --- a/src/Fixture/Factory/BlockFixtureFactory.php +++ b/src/Fixture/Factory/BlockFixtureFactory.php @@ -12,7 +12,7 @@ use BitBag\SyliusCmsPlugin\Assigner\ChannelsAssignerInterface; use BitBag\SyliusCmsPlugin\Assigner\ProductsAssignerInterface; -use BitBag\SyliusCmsPlugin\Assigner\SectionsAssignerInterface; +use BitBag\SyliusCmsPlugin\Assigner\CollectionsAssignerInterface; use BitBag\SyliusCmsPlugin\Assigner\TaxonsAssignerInterface; use BitBag\SyliusCmsPlugin\Entity\BlockInterface; use BitBag\SyliusCmsPlugin\Entity\BlockTranslationInterface; @@ -26,16 +26,16 @@ final class BlockFixtureFactory implements FixtureFactoryInterface { public function __construct( - private FactoryInterface $blockFactory, - private FactoryInterface $blockTranslationFactory, - private BlockRepositoryInterface $blockRepository, - private ProductRepositoryInterface $productRepository, - private ChannelContextInterface $channelContext, - private LocaleContextInterface $localeContext, - private ProductsAssignerInterface $productsAssigner, - private TaxonsAssignerInterface $taxonsAssigner, - private SectionsAssignerInterface $sectionsAssigner, - private ChannelsAssignerInterface $channelAssigner, + private FactoryInterface $blockFactory, + private FactoryInterface $blockTranslationFactory, + private BlockRepositoryInterface $blockRepository, + private ProductRepositoryInterface $productRepository, + private ChannelContextInterface $channelContext, + private LocaleContextInterface $localeContext, + private ProductsAssignerInterface $productsAssigner, + private TaxonsAssignerInterface $taxonsAssigner, + 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..f5f7ce2bc --- /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..f25953964 100644 --- a/src/Fixture/Factory/MediaFixtureFactory.php +++ b/src/Fixture/Factory/MediaFixtureFactory.php @@ -12,7 +12,7 @@ use BitBag\SyliusCmsPlugin\Assigner\ChannelsAssignerInterface; use BitBag\SyliusCmsPlugin\Assigner\ProductsAssignerInterface; -use BitBag\SyliusCmsPlugin\Assigner\SectionsAssignerInterface; +use BitBag\SyliusCmsPlugin\Assigner\CollectionsAssignerInterface; use BitBag\SyliusCmsPlugin\Entity\MediaInterface; use BitBag\SyliusCmsPlugin\Entity\MediaTranslationInterface; use BitBag\SyliusCmsPlugin\Repository\MediaRepositoryInterface; @@ -23,13 +23,13 @@ final class MediaFixtureFactory implements FixtureFactoryInterface { public function __construct( - private FactoryInterface $mediaFactory, - private FactoryInterface $mediaTranslationFactory, + private FactoryInterface $mediaFactory, + private FactoryInterface $mediaTranslationFactory, private MediaProviderResolverInterface $mediaProviderResolver, - private MediaRepositoryInterface $mediaRepository, - private ProductsAssignerInterface $productsAssigner, - private SectionsAssignerInterface $sectionsAssigner, - private ChannelsAssignerInterface $channelAssigner, + private MediaRepositoryInterface $mediaRepository, + private ProductsAssignerInterface $productsAssigner, + 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..85db20720 100755 --- a/src/Fixture/Factory/PageFixtureFactory.php +++ b/src/Fixture/Factory/PageFixtureFactory.php @@ -12,7 +12,7 @@ use BitBag\SyliusCmsPlugin\Assigner\ChannelsAssignerInterface; use BitBag\SyliusCmsPlugin\Assigner\ProductsAssignerInterface; -use BitBag\SyliusCmsPlugin\Assigner\SectionsAssignerInterface; +use BitBag\SyliusCmsPlugin\Assigner\CollectionsAssignerInterface; use BitBag\SyliusCmsPlugin\Entity\Media; use BitBag\SyliusCmsPlugin\Entity\MediaInterface; use BitBag\SyliusCmsPlugin\Entity\PageInterface; @@ -32,16 +32,16 @@ final class PageFixtureFactory implements FixtureFactoryInterface public const CHANNEL_WITH_CODE_NOT_FOUND_MESSAGE = 'Channel with code "%s" not found'; public function __construct( - private FactoryInterface $pageFactory, - private FactoryInterface $pageTranslationFactory, - private PageRepositoryInterface $pageRepository, + private FactoryInterface $pageFactory, + private FactoryInterface $pageTranslationFactory, + private PageRepositoryInterface $pageRepository, private MediaProviderResolverInterface $mediaProviderResolver, - private ProductsAssignerInterface $productsAssigner, - private SectionsAssignerInterface $sectionsAssigner, - private ChannelsAssignerInterface $channelAssigner, - private ProductRepositoryInterface $productRepository, - private LocaleContextInterface $localeContext, - private ChannelRepositoryInterface $channelRepository, + private ProductsAssignerInterface $productsAssigner, + private CollectionsAssignerInterface $collectionsAssigner, + private ChannelsAssignerInterface $channelAssigner, + private ProductRepositoryInterface $productRepository, + private LocaleContextInterface $localeContext, + private ChannelRepositoryInterface $channelRepository, ) { } @@ -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/BlockType.php b/src/Form/Type/BlockType.php index 843e62156..ed65f8b9d 100755 --- a/src/Form/Type/BlockType.php +++ b/src/Form/Type/BlockType.php @@ -34,7 +34,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void 'label' => 'bitbag_sylius_cms_plugin.ui.code', 'disabled' => null !== $block->getCode(), ]) - ->add('sections', SectionAutocompleteChoiceType::class, [ + ->add('collections', CollectionAutocompleteChoiceType::class, [ 'label' => 'bitbag_sylius_cms_plugin.ui.sections', 'multiple' => true, ]) diff --git a/src/Form/Type/SectionAutocompleteChoiceType.php b/src/Form/Type/CollectionAutocompleteChoiceType.php similarity index 86% rename from src/Form/Type/SectionAutocompleteChoiceType.php rename to src/Form/Type/CollectionAutocompleteChoiceType.php index ec57d6918..1ac306653 100755 --- a/src/Form/Type/SectionAutocompleteChoiceType.php +++ b/src/Form/Type/CollectionAutocompleteChoiceType.php @@ -16,12 +16,12 @@ use Symfony\Component\Form\FormView; use Symfony\Component\OptionsResolver\OptionsResolver; -final class SectionAutocompleteChoiceType extends AbstractType +final class CollectionAutocompleteChoiceType extends AbstractType { public function configureOptions(OptionsResolver $resolver): void { $resolver->setDefaults([ - 'resource' => 'bitbag_sylius_cms_plugin.section', + 'resource' => 'bitbag_sylius_cms_plugin.collection', 'choice_name' => 'name', 'choice_value' => 'code', ]); @@ -38,7 +38,7 @@ public function buildView( public function getBlockPrefix(): string { - return 'bitbag_section_autocomplete_choice'; + return 'bitbag_collection_autocomplete_choice'; } public function getParent(): string diff --git a/src/Form/Type/SectionType.php b/src/Form/Type/CollectionType.php similarity index 92% rename from src/Form/Type/SectionType.php rename to src/Form/Type/CollectionType.php index e3c886ab8..92ab25c87 100755 --- a/src/Form/Type/SectionType.php +++ b/src/Form/Type/CollectionType.php @@ -11,7 +11,7 @@ namespace BitBag\SyliusCmsPlugin\Form\Type; use BitBag\SyliusCmsPlugin\Entity\MediaInterface; -use BitBag\SyliusCmsPlugin\Form\Type\Translation\SectionTranslationType; +use BitBag\SyliusCmsPlugin\Form\Type\Translation\CollectionTranslationType; use Sylius\Bundle\ResourceBundle\Form\Type\AbstractResourceType; use Sylius\Bundle\ResourceBundle\Form\Type\ResourceTranslationsType; use Symfony\Component\Form\Event\PreSubmitEvent; @@ -20,7 +20,7 @@ use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormEvents; -final class SectionType extends AbstractResourceType +final class CollectionType extends AbstractResourceType { public const PAGE = 'page'; @@ -57,7 +57,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void 'media_type' => MediaInterface::IMAGE_TYPE, ]) ->add('translations', ResourceTranslationsType::class, [ - 'entry_type' => SectionTranslationType::class, + 'entry_type' => CollectionTranslationType::class, ]) ->addEventListener(FormEvents::PRE_SUBMIT, function (PreSubmitEvent $event): void { $formData = $event->getData(); @@ -80,6 +80,6 @@ public function buildForm(FormBuilderInterface $builder, array $options): void public function getBlockPrefix(): string { - return 'bitbag_sylius_cms_plugin_section'; + return 'bitbag_sylius_cms_plugin_collection'; } } diff --git a/src/Form/Type/MediaType.php b/src/Form/Type/MediaType.php index 7671a17d9..935086973 100644 --- a/src/Form/Type/MediaType.php +++ b/src/Form/Type/MediaType.php @@ -52,7 +52,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void ->add('file', FileType::class, [ 'label' => 'bitbag_sylius_cms_plugin.ui.file', ]) - ->add('sections', SectionAutocompleteChoiceType::class, [ + ->add('collections', CollectionAutocompleteChoiceType::class, [ 'label' => 'bitbag_sylius_cms_plugin.ui.sections', 'multiple' => true, ]) diff --git a/src/Form/Type/PageType.php b/src/Form/Type/PageType.php index a16f092e1..a9afcd8a5 100755 --- a/src/Form/Type/PageType.php +++ b/src/Form/Type/PageType.php @@ -40,7 +40,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void 'label' => 'bitbag_sylius_cms_plugin.ui.images', 'entry_type' => PageTranslationType::class, ]) - ->add('sections', SectionAutocompleteChoiceType::class, [ + ->add('collections', CollectionAutocompleteChoiceType::class, [ 'label' => 'bitbag_sylius_cms_plugin.ui.sections', 'multiple' => true, ]) 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..8b4a96d0a 100644 --- a/src/Importer/BlockImporter.php +++ b/src/Importer/BlockImporter.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 Sylius\Component\Locale\Context\LocaleContextInterface; use Symfony\Component\Validator\Validator\ValidatorInterface; @@ -23,13 +23,13 @@ final class BlockImporter extends AbstractImporter implements BlockImporterInterface { public function __construct( - private ResourceResolverInterface $blockResourceResolver, - private LocaleContextInterface $localeContext, - private ImporterSectionsResolverInterface $importerSectionsResolver, - private ImporterChannelsResolverInterface $importerChannelsResolver, - private ImporterProductsResolverInterface $importerProductsResolver, - ValidatorInterface $validator, - private BlockRepositoryInterface $blockRepository, + private ResourceResolverInterface $blockResourceResolver, + private LocaleContextInterface $localeContext, + private ImporterCollectionsResolverInterface $importerCollectionsResolver, + private ImporterChannelsResolverInterface $importerChannelsResolver, + private ImporterProductsResolverInterface $importerProductsResolver, + ValidatorInterface $validator, + private BlockRepositoryInterface $blockRepository, ) { parent::__construct($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..b1703a1eb 100644 --- a/src/Importer/MediaImporter.php +++ b/src/Importer/MediaImporter.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 Sylius\Component\Locale\Context\LocaleContextInterface; use Symfony\Component\Validator\Validator\ValidatorInterface; @@ -22,12 +22,12 @@ final class MediaImporter extends AbstractImporter implements MediaImporterInterface { public function __construct( - private ResourceResolverInterface $mediaResourceResolver, - private LocaleContextInterface $localeContext, - private ImporterSectionsResolverInterface $importerSectionsResolver, - private ImporterProductsResolverInterface $importerProductsResolver, - ValidatorInterface $validator, - private MediaRepositoryInterface $mediaRepository, + private ResourceResolverInterface $mediaResourceResolver, + private LocaleContextInterface $localeContext, + private ImporterCollectionsResolverInterface $importerCollectionsResolver, + private ImporterProductsResolverInterface $importerProductsResolver, + ValidatorInterface $validator, + private MediaRepositoryInterface $mediaRepository, ) { parent::__construct($validator); } @@ -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..0209f729f 100644 --- a/src/Importer/PageImporter.php +++ b/src/Importer/PageImporter.php @@ -16,7 +16,7 @@ use BitBag\SyliusCmsPlugin\Entity\PageTranslationInterface; 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; @@ -29,16 +29,16 @@ final class PageImporter extends AbstractImporter implements PageImporterInterface { public function __construct( - private ResourceResolverInterface $pageResourceResolver, - private LocaleContextInterface $localeContext, - private ImageDownloaderInterface $imageDownloader, - private FactoryInterface $mediaFactory, - private MediaProviderResolverInterface $mediaProviderResolver, - private ImporterSectionsResolverInterface $importerSectionsResolver, - private ImporterChannelsResolverInterface $importerChannelsResolver, - private ImporterProductsResolverInterface $importerProductsResolver, - ValidatorInterface $validator, - private EntityManagerInterface $entityManager, + private ResourceResolverInterface $pageResourceResolver, + private LocaleContextInterface $localeContext, + private ImageDownloaderInterface $imageDownloader, + private FactoryInterface $mediaFactory, + private MediaProviderResolverInterface $mediaProviderResolver, + private ImporterCollectionsResolverInterface $importerCollectionsResolver, + private ImporterChannelsResolverInterface $importerChannelsResolver, + private ImporterProductsResolverInterface $importerProductsResolver, + ValidatorInterface $validator, + private EntityManagerInterface $entityManager, ) { parent::__construct($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..4d82662ee 100755 --- a/src/Menu/ContentManagementMenuBuilder.php +++ b/src/Menu/ContentManagementMenuBuilder.php @@ -56,8 +56,8 @@ 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') ->setLabelAttribute('icon', 'grid layout') diff --git a/src/Repository/BlockRepository.php b/src/Repository/BlockRepository.php index 72151a208..4d32cc427 100755 --- a/src/Repository/BlockRepository.php +++ b/src/Repository/BlockRepository.php @@ -41,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() diff --git a/src/Repository/BlockRepositoryInterface.php b/src/Repository/BlockRepositoryInterface.php index 682d8d0b7..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; diff --git a/src/Repository/SectionRepository.php b/src/Repository/CollectionRepository.php similarity index 92% rename from src/Repository/SectionRepository.php rename to src/Repository/CollectionRepository.php index 99fb0998c..65dca814c 100755 --- a/src/Repository/SectionRepository.php +++ b/src/Repository/CollectionRepository.php @@ -10,11 +10,11 @@ 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; @@ -37,7 +37,7 @@ 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 { 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 f299ea497..04a40d531 100755 --- a/src/Repository/PageRepository.php +++ b/src/Repository/PageRepository.php @@ -24,7 +24,7 @@ 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) ; } @@ -75,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() @@ -128,22 +128,22 @@ public function findByProduct( ; } - public function findByProductAndSectionCode( - ProductInterface $product, - string $sectionCode, - string $channelCode, + public function findByProductAndCollectionCode( + ProductInterface $product, + 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) ; diff --git a/src/Repository/PageRepositoryInterface.php b/src/Repository/PageRepositoryInterface.php index 5092aad61..9b6d3058f 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,10 @@ public function findByProduct( ?\DateTimeInterface $date, ): array; - public function findByProductAndSectionCode( - ProductInterface $product, - string $sectionCode, - string $channelCode, + public function findByProductAndCollectionCode( + ProductInterface $product, + string $collectionCode, + string $channelCode, ?\DateTimeInterface $date, ): array; diff --git a/src/Resolver/ImporterCollectionsResolver.php b/src/Resolver/ImporterCollectionsResolver.php new file mode 100644 index 000000000..3f90be302 --- /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..6484167aa 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\CollectionableInterface; -interface ImporterSectionsResolverInterface +interface ImporterCollectionsResolverInterface { - public function resolve(SectionableInterface $sectionable, ?string $sectionsRow): void; + public function resolve(CollectionableInterface $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-section-type.js b/src/Resources/assets/admin/js/bitbag/bitbag-choose-collection-type.js similarity index 77% rename from src/Resources/assets/admin/js/bitbag/bitbag-choose-section-type.js rename to src/Resources/assets/admin/js/bitbag/bitbag-choose-collection-type.js index 3aa53a35c..f2b39f95c 100644 --- a/src/Resources/assets/admin/js/bitbag/bitbag-choose-section-type.js +++ b/src/Resources/assets/admin/js/bitbag/bitbag-choose-collection-type.js @@ -4,14 +4,14 @@ * 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 HandleChooseSectionType { +export class HandleChooseCollectionType { init() { window.addEventListener('DOMContentLoaded', () => { - const typeField = document.getElementById('bitbag_sylius_cms_plugin_section_type'); + const typeField = document.getElementById('bitbag_sylius_cms_plugin_collection_type'); const fields = { - page: document.getElementById('section-type-pages'), - block: document.getElementById('section-type-blocks'), - media: document.getElementById('section-type-media') + page: document.getElementById('collection-type-pages'), + block: document.getElementById('collection-type-blocks'), + media: document.getElementById('collection-type-media') }; const hideAllFields = () => { diff --git a/src/Resources/assets/admin/js/bitbag/index.js b/src/Resources/assets/admin/js/bitbag/index.js index f40f8ce46..5d48e0b92 100644 --- a/src/Resources/assets/admin/js/bitbag/index.js +++ b/src/Resources/assets/admin/js/bitbag/index.js @@ -2,4 +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 {HandleChooseSectionType} from './bitbag-choose-section-type'; +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 2efd774d1..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, HandleChooseSectionType} from './bitbag'; +import { + HandleCsvUpload, + HandleSlugUpdate, + HandlePreview, + HandleAutoComplete, + HandleChooseCollectionType +} from './bitbag'; if (document.querySelector('[data-bb-target="cms-import"]')) { new HandleCsvUpload().init(); @@ -16,6 +22,6 @@ if (document.querySelector('[data-bb-target="cms-handle-autocomplete"]')) { new HandleAutoComplete().init(); } -if (document.querySelector('.section-type-items')) { - new HandleChooseSectionType().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..651000fcf 100644 --- a/src/Resources/config/doctrine/Block.orm.xml +++ b/src/Resources/config/doctrine/Block.orm.xml @@ -14,13 +14,13 @@ - - + + - + diff --git a/src/Resources/config/doctrine/Section.orm.xml b/src/Resources/config/doctrine/Collection.orm.xml similarity index 75% rename from src/Resources/config/doctrine/Section.orm.xml rename to src/Resources/config/doctrine/Collection.orm.xml index 5cf05687d..765310c74 100644 --- a/src/Resources/config/doctrine/Section.orm.xml +++ b/src/Resources/config/doctrine/Collection.orm.xml @@ -6,7 +6,7 @@ xsi:schemaLocation="https://doctrine-project.org/schemas/orm/doctrine-mapping https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> - + @@ -16,9 +16,9 @@ - + - + @@ -27,9 +27,9 @@ - + - + @@ -38,9 +38,9 @@ - + - + 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..ef3af419b 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..79f2e3fc5 100644 --- a/src/Resources/config/doctrine/Media.orm.xml +++ b/src/Resources/config/doctrine/Media.orm.xml @@ -24,13 +24,13 @@ - - + + - + diff --git a/src/Resources/config/doctrine/Page.orm.xml b/src/Resources/config/doctrine/Page.orm.xml index 44e28cb8c..fcfb09d69 100644 --- a/src/Resources/config/doctrine/Page.orm.xml +++ b/src/Resources/config/doctrine/Page.orm.xml @@ -25,13 +25,13 @@ - - + + - + 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..7a58e3425 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 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 91% rename from src/Resources/config/grids/admin/section.yml rename to src/Resources/config/grids/admin/collection.yml index 25dbf6b2b..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%"] diff --git a/src/Resources/config/grids/admin/page.yml b/src/Resources/config/grids/admin/page.yml index 16c700ab5..f5d042ba0 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 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 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/section.yml b/src/Resources/config/routing/admin/collection.yml similarity index 63% rename from src/Resources/config/routing/admin/section.yml rename to src/Resources/config/routing/admin/collection.yml index 18af15ec5..bc4c3b102 100755 --- a/src/Resources/config/routing/admin/section.yml +++ b/src/Resources/config/routing/admin/collection.yml @@ -1,10 +1,10 @@ -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: @@ -12,17 +12,17 @@ bitbag_sylius_cms_plugin_admin_section: header: bitbag_sylius_cms_plugin.ui.sections_header subheader: bitbag_sylius_cms_plugin.ui.sections_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/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.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/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/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/Section/Crud/_form.html.twig b/src/Resources/views/Collection/Crud/_form.html.twig similarity index 79% rename from src/Resources/views/Section/Crud/_form.html.twig rename to src/Resources/views/Collection/Crud/_form.html.twig index 1c8934e8e..dbdd2f157 100755 --- a/src/Resources/views/Section/Crud/_form.html.twig +++ b/src/Resources/views/Collection/Crud/_form.html.twig @@ -9,14 +9,14 @@ {{ form_row(form.code) }} {{ form_row(form.type) }} -
-
+
+
{{ form_row(form.pages) }}
-
+
{{ form_row(form.blocks) }}
-
+
{{ form_row(form.media) }}
diff --git a/src/Resources/views/Form/theme.html.twig b/src/Resources/views/Form/theme.html.twig index 849a0f047..6df30e724 100755 --- a/src/Resources/views/Form/theme.html.twig +++ b/src/Resources/views/Form/theme.html.twig @@ -1,7 +1,7 @@ {% 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 %} diff --git a/src/Resources/views/Grid/Field/collections.html.twig b/src/Resources/views/Grid/Field/collections.html.twig new file mode 100755 index 000000000..2c6f8283a --- /dev/null +++ b/src/Resources/views/Grid/Field/collections.html.twig @@ -0,0 +1,3 @@ +{% for collection in data.collections %} + {{ collection.code }} +{% endfor %} diff --git a/src/Resources/views/Grid/Field/sections.html.twig b/src/Resources/views/Grid/Field/sections.html.twig deleted file mode 100755 index f665cec2e..000000000 --- a/src/Resources/views/Grid/Field/sections.html.twig +++ /dev/null @@ -1,3 +0,0 @@ -{% for section in data.sections %} - {{ section.code }} -{% endfor %} diff --git a/src/Resources/views/Media/Crud/_form.html.twig b/src/Resources/views/Media/Crud/_form.html.twig index 2e072fdb9..d9728c73d 100755 --- a/src/Resources/views/Media/Crud/_form.html.twig +++ b/src/Resources/views/Media/Crud/_form.html.twig @@ -14,7 +14,7 @@ {{ form_row(form.enabled) }} {{ form_row(form.saveWithOriginalName) }} {{ form_row(form.products) }} - {{ form_row(form.sections) }} + {{ form_row(form.collections) }} {{ form_row(form.channels) }}
- {{ 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..4a15b0b01 --- /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.sections'|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..1aff33deb 100755 --- a/src/Resources/views/Shop/Page/show.html.twig +++ b/src/Resources/views/Shop/Page/show.html.twig @@ -43,7 +43,7 @@
{{ 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..be2daedbf 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; @@ -20,26 +20,26 @@ final class RenderProductPagesRuntime implements RenderProductPagesRuntimeInterface { public function __construct( - private PageRepositoryInterface $pageRepository, - private ChannelContextInterface $channelContext, - private Environment $templatingEngine, - private SectionsSorterInterface $sectionsSorter, + private PageRepositoryInterface $pageRepository, + private ChannelContextInterface $channelContext, + private Environment $templatingEngine, + 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..8765231c1 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: @@ -49,7 +49,7 @@ sylius_fixtures: section_info_block: channels: - "FASHION_WEB" - sections: + collections: - "products" translations: en_US: @@ -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/Behat/Context/Api/SectionContext.php b/tests/Behat/Context/Api/SectionContext.php index 076874ab0..aac01d37a 100644 --- a/tests/Behat/Context/Api/SectionContext.php +++ b/tests/Behat/Context/Api/SectionContext.php @@ -11,7 +11,7 @@ namespace Tests\BitBag\SyliusCmsPlugin\Behat\Context\Api; use Behat\Behat\Context\Context; -use BitBag\SyliusCmsPlugin\Entity\SectionInterface; +use BitBag\SyliusCmsPlugin\Entity\CollectionInterface; use Sylius\Behat\Client\ApiClientInterface; use Sylius\Behat\Client\ResponseCheckerInterface; use Tests\BitBag\SyliusCmsPlugin\Behat\Resources; @@ -50,7 +50,7 @@ public function iShouldSeeSectionsInTheList(int $count): void * @Given I view section with code :section * @Then I should see section with code :section */ - public function iShouldSeeSectionWithCode(SectionInterface $section): void + public function iShouldSeeSectionWithCode(CollectionInterface $section): void { $this->apiClient->show(Resources::SECTIONS, (string) $section->getId()); } @@ -67,7 +67,7 @@ public function iShouldSeeSectionName(): void 'name', "That shouldn't exist", ), - 'Section has missing name', + 'Collection has missing name', ); } } diff --git a/tests/Behat/Context/Setup/PageContext.php b/tests/Behat/Context/Setup/PageContext.php index d0314dffd..cde9f6b89 100755 --- a/tests/Behat/Context/Setup/PageContext.php +++ b/tests/Behat/Context/Setup/PageContext.php @@ -16,7 +16,7 @@ use BitBag\SyliusCmsPlugin\Entity\PageInterface; use BitBag\SyliusCmsPlugin\MediaProvider\ProviderInterface; use BitBag\SyliusCmsPlugin\Repository\PageRepositoryInterface; -use BitBag\SyliusCmsPlugin\Repository\SectionRepositoryInterface; +use BitBag\SyliusCmsPlugin\Repository\CollectionRepositoryInterface; use Doctrine\ORM\EntityManagerInterface; use Sylius\Behat\Service\SharedStorageInterface; use Sylius\Component\Core\Formatter\StringInflector; @@ -29,14 +29,14 @@ final class PageContext implements Context { public function __construct( - private SharedStorageInterface $sharedStorage, + private SharedStorageInterface $sharedStorage, private RandomStringGeneratorInterface $randomStringGenerator, - private FactoryInterface $pageFactory, - private PageRepositoryInterface $pageRepository, - private EntityManagerInterface $entityManager, - private ProductRepositoryInterface $productRepository, - private SectionRepositoryInterface $sectionRepository, - private ProviderInterface $imageProvider, + private FactoryInterface $pageFactory, + private PageRepositoryInterface $pageRepository, + private EntityManagerInterface $entityManager, + private ProductRepositoryInterface $productRepository, + private CollectionRepositoryInterface $sectionRepository, + private ProviderInterface $imageProvider, ) { } @@ -182,7 +182,7 @@ public function thesePagesHaveThisSectionAssociatedWithIt(): void /** @var PageInterface $page */ foreach ($pages as $page) { - $page->addSection($section); + $page->addCollection($section); } $this->entityManager->flush(); diff --git a/tests/Behat/Context/Setup/SectionContext.php b/tests/Behat/Context/Setup/SectionContext.php index 3721813e5..6ac31202e 100755 --- a/tests/Behat/Context/Setup/SectionContext.php +++ b/tests/Behat/Context/Setup/SectionContext.php @@ -11,8 +11,8 @@ namespace Tests\BitBag\SyliusCmsPlugin\Behat\Context\Setup; use Behat\Behat\Context\Context; -use BitBag\SyliusCmsPlugin\Entity\SectionInterface; -use BitBag\SyliusCmsPlugin\Repository\SectionRepositoryInterface; +use BitBag\SyliusCmsPlugin\Entity\CollectionInterface; +use BitBag\SyliusCmsPlugin\Repository\CollectionRepositoryInterface; use Sylius\Behat\Service\SharedStorageInterface; use Sylius\Component\Core\Formatter\StringInflector; use Sylius\Component\Resource\Factory\FactoryInterface; @@ -21,10 +21,10 @@ final class SectionContext implements Context { public function __construct( - private SharedStorageInterface $sharedStorage, + private SharedStorageInterface $sharedStorage, private RandomStringGeneratorInterface $randomStringGenerator, - private FactoryInterface $sectionFactory, - private SectionRepositoryInterface $sectionRepository, + private FactoryInterface $sectionFactory, + private CollectionRepositoryInterface $sectionRepository, ) { } @@ -70,9 +70,9 @@ public function thereIsASectionInTheStore(string $sectionName): void $this->saveSection($section); } - private function createSection(?string $code = null, string $name = null): SectionInterface + private function createSection(?string $code = null, string $name = null): CollectionInterface { - /** @var SectionInterface $section */ + /** @var CollectionInterface $section */ $section = $this->sectionFactory->createNew(); if (null === $code) { @@ -90,7 +90,7 @@ private function createSection(?string $code = null, string $name = null): Secti return $section; } - private function saveSection(SectionInterface $section): void + private function saveSection(CollectionInterface $section): void { $this->sectionRepository->add($section); $this->sharedStorage->set('section', $section); diff --git a/tests/Behat/Context/Transform/SectionContext.php b/tests/Behat/Context/Transform/SectionContext.php index 461cad274..5877b295d 100644 --- a/tests/Behat/Context/Transform/SectionContext.php +++ b/tests/Behat/Context/Transform/SectionContext.php @@ -11,15 +11,15 @@ namespace Tests\BitBag\SyliusCmsPlugin\Behat\Context\Transform; use Behat\Behat\Context\Context; -use BitBag\SyliusCmsPlugin\Entity\SectionInterface; -use BitBag\SyliusCmsPlugin\Repository\SectionRepositoryInterface; +use BitBag\SyliusCmsPlugin\Entity\CollectionInterface; +use BitBag\SyliusCmsPlugin\Repository\CollectionRepositoryInterface; use Webmozart\Assert\Assert; final class SectionContext implements Context { public function __construct( - private SectionRepositoryInterface $sectionRepository, - private string $locale = 'en_US', + private CollectionRepositoryInterface $sectionRepository, + private string $locale = 'en_US', ) { } @@ -29,7 +29,7 @@ public function __construct( * @Transform /^(?:a|an) "([^"]+)"$/ * @Transform :section */ - public function getSectionByCode(string $sectionCode): SectionInterface + public function getSectionByCode(string $sectionCode): CollectionInterface { $section = $this->sectionRepository->findOneByCode($sectionCode, $this->locale); diff --git a/tests/Behat/Context/Ui/Admin/SectionContext.php b/tests/Behat/Context/Ui/Admin/SectionContext.php index 1c80d1ceb..f214ca1b1 100755 --- a/tests/Behat/Context/Ui/Admin/SectionContext.php +++ b/tests/Behat/Context/Ui/Admin/SectionContext.php @@ -172,7 +172,7 @@ public function iShouldBeNotifiedThatThereIsAlreadyAnExistingSectionWithCode(): public function iShouldBeNotifiedThatNewSectionHasBeenCreated(): void { $this->notificationChecker->checkNotification( - 'Section has been successfully created.', + 'Collection has been successfully created.', NotificationType::success(), ); } @@ -183,7 +183,7 @@ public function iShouldBeNotifiedThatNewSectionHasBeenCreated(): void public function iShouldBeNotifiedThatTheSectionHasBeenDeleted(): void { $this->notificationChecker->checkNotification( - 'Section has been successfully deleted.', + 'Collection has been successfully deleted.', NotificationType::success(), ); } diff --git a/tests/Functional/Api/SectionTest.php b/tests/Functional/Api/SectionTest.php index f68e6677d..3e0a85661 100644 --- a/tests/Functional/Api/SectionTest.php +++ b/tests/Functional/Api/SectionTest.php @@ -11,8 +11,8 @@ namespace Tests\BitBag\SyliusCmsPlugin\Functional\Api; -use BitBag\SyliusCmsPlugin\Entity\SectionInterface; -use BitBag\SyliusCmsPlugin\Repository\SectionRepositoryInterface; +use BitBag\SyliusCmsPlugin\Entity\CollectionInterface; +use BitBag\SyliusCmsPlugin\Repository\CollectionRepositoryInterface; use Symfony\Component\HttpFoundation\Response; use Tests\BitBag\SyliusCmsPlugin\Functional\FunctionalTestCase; @@ -22,12 +22,12 @@ class SectionTest extends FunctionalTestCase public function setUp(): void { - $this->loadFixturesFromFile('Api/SectionTest/section.yml'); + $this->loadFixturesFromFile('Api/SectionTest/collection.yml'); } public function test_section_response(): void { - /** @var SectionInterface $section */ + /** @var CollectionInterface $section */ $section = $this->getRepository()->findOneByCode('section1-code', 'en_US'); $this->client->request('GET', '/api/v2/shop/cms-plugin/sections/' . $section->getId(), [], [], self::CONTENT_TYPE_HEADER); $response = $this->client->getResponse(); @@ -43,10 +43,10 @@ public function test_sections_response(): void $this->assertResponse($response, 'Api/SectionTest/test_it_get_sections', Response::HTTP_OK); } - private function getRepository(): SectionRepositoryInterface + private function getRepository(): CollectionRepositoryInterface { - /** @var SectionRepositoryInterface $repository */ - $repository = $this->getEntityManager()->getRepository(SectionInterface::class); + /** @var CollectionRepositoryInterface $repository */ + $repository = $this->getEntityManager()->getRepository(CollectionInterface::class); return $repository; } diff --git a/tests/Functional/Fixture/SectionFixtureTest.php b/tests/Functional/Fixture/SectionFixtureTest.php index d4cd3d19d..a1704272e 100644 --- a/tests/Functional/Fixture/SectionFixtureTest.php +++ b/tests/Functional/Fixture/SectionFixtureTest.php @@ -11,7 +11,7 @@ namespace Tests\BitBag\SyliusCmsPlugin\Functional\Fixture; use BitBag\SyliusCmsPlugin\Fixture\Factory\FixtureFactoryInterface; -use BitBag\SyliusCmsPlugin\Fixture\SectionFixture; +use BitBag\SyliusCmsPlugin\Fixture\CollectionFixture; use Matthias\SymfonyConfigTest\PhpUnit\ConfigurationTestCaseTrait; use PHPUnit\Framework\TestCase; @@ -113,11 +113,11 @@ public function custom_remove_existing_is_optional_but_must_be_boolean(): void ], 'custom.*.remove_existing'); } - protected function getConfiguration(): SectionFixture + protected function getConfiguration(): CollectionFixture { /** @var FixtureFactoryInterface $sectionFixtureFactory */ $sectionFixtureFactory = $this->getMockBuilder(FixtureFactoryInterface::class)->getMock(); - return new SectionFixture($sectionFixtureFactory); + return new CollectionFixture($sectionFixtureFactory); } } diff --git a/tests/Integration/Repository/BlockRepositoryTest.php b/tests/Integration/Repository/BlockRepositoryTest.php index fb6c10718..b91e15cd2 100644 --- a/tests/Integration/Repository/BlockRepositoryTest.php +++ b/tests/Integration/Repository/BlockRepositoryTest.php @@ -41,8 +41,8 @@ public function test_it_finds_enabled_block_by_section_code(): void $blockRepository = $this->getRepository(); - $block_array1 = $blockRepository->findBySectionCode('section1-code', 'en_US', 'code'); - $block_array3 = $blockRepository->findBySectionCode('section3-code', 'en_US', 'code'); + $block_array1 = $blockRepository->findByCollectionCode('section1-code', 'en_US', 'code'); + $block_array3 = $blockRepository->findByCollectionCode('section3-code', 'en_US', 'code'); self::assertNotEmpty($block_array1); self::assertEmpty($block_array3); diff --git a/tests/Integration/Repository/MediaRepositoryTest.php b/tests/Integration/Repository/MediaRepositoryTest.php index 1e1e31498..d5092c4d6 100644 --- a/tests/Integration/Repository/MediaRepositoryTest.php +++ b/tests/Integration/Repository/MediaRepositoryTest.php @@ -41,8 +41,8 @@ public function test_it_finds_enabled_media_by_section_code(): void $mediaRepository = $this->getRepository(); - $media1 = $mediaRepository->findBySectionCode('section1-code', 'en_US', 'code'); - $media3 = $mediaRepository->findBySectionCode('section3-code', 'en_US', 'code'); + $media1 = $mediaRepository->findByCollectionCode('section1-code', 'en_US', 'code'); + $media3 = $mediaRepository->findByCollectionCode('section3-code', 'en_US', 'code'); self::assertNotEmpty($media1); self::assertEmpty($media3); diff --git a/tests/Integration/Repository/PageRepositoryTest.php b/tests/Integration/Repository/PageRepositoryTest.php index 2a18ed8ff..9e2f285e8 100644 --- a/tests/Integration/Repository/PageRepositoryTest.php +++ b/tests/Integration/Repository/PageRepositoryTest.php @@ -56,8 +56,8 @@ public function test_it_finds_enabled_page_by_section_code(): void $pageRepository = $this->getRepository(); - $page1_array = $pageRepository->findBySectionCode('section1-code', 'en_US'); - $page3_array = $pageRepository->findBySectionCode('section3-code', 'en_US'); + $page1_array = $pageRepository->findByCollectionCode('section1-code', 'en_US'); + $page3_array = $pageRepository->findByCollectionCode('section3-code', 'en_US'); self::assertNotEmpty($page1_array); self::assertEmpty($page3_array); @@ -98,8 +98,8 @@ public function test_it_finds_enabled_page_by_product_and_section_code(): void /** @var Product $product3 */ $product3 = $productRepository->findOneByCode('MUG_SW3'); - $page1_array = $pageRepository->findByProductAndSectionCode($product1, 'section1-code', 'code', null); - $page3_array = $pageRepository->findByProductAndSectionCode($product3, 'section3-code', 'code', null); + $page1_array = $pageRepository->findByProductAndCollectionCode($product1, 'section1-code', 'code', null); + $page3_array = $pageRepository->findByProductAndCollectionCode($product3, 'section3-code', 'code', null); self::assertNotEmpty($page1_array); self::assertEmpty($page3_array); diff --git a/tests/Integration/Repository/SectionRepositoryTest.php b/tests/Integration/Repository/SectionRepositoryTest.php index 446290dd4..247f4ff7f 100644 --- a/tests/Integration/Repository/SectionRepositoryTest.php +++ b/tests/Integration/Repository/SectionRepositoryTest.php @@ -12,8 +12,8 @@ namespace Tests\BitBag\SyliusCmsPlugin\Integration\Repository; use ApiTestCase\JsonApiTestCase; -use BitBag\SyliusCmsPlugin\Entity\SectionInterface; -use BitBag\SyliusCmsPlugin\Repository\SectionRepositoryInterface; +use BitBag\SyliusCmsPlugin\Entity\CollectionInterface; +use BitBag\SyliusCmsPlugin\Repository\CollectionRepositoryInterface; use Doctrine\ORM\QueryBuilder; class SectionRepositoryTest extends JsonApiTestCase @@ -58,7 +58,7 @@ public function test_it_finds_one_by_code(): void $localeCode = 'en_US'; $section = $repository->findOneByCode($code, $localeCode); - self::assertInstanceOf(SectionInterface::class, $section); + self::assertInstanceOf(CollectionInterface::class, $section); } public function test_it_finds_by_codes_and_locale(): void @@ -75,10 +75,10 @@ public function test_it_finds_by_codes_and_locale(): void self::assertCount(2, $sections); } - private function getRepository(): SectionRepositoryInterface + private function getRepository(): CollectionRepositoryInterface { - /** @var SectionRepositoryInterface $repository */ - $repository = $this->getEntityManager()->getRepository(SectionInterface::class); + /** @var CollectionRepositoryInterface $repository */ + $repository = $this->getEntityManager()->getRepository(CollectionInterface::class); return $repository; } From 4f1d1ebcead1e62c9e9d9f31eadeb1dc6223cf37 Mon Sep 17 00:00:00 2001 From: jkindly Date: Wed, 19 Jun 2024 08:15:57 +0200 Subject: [PATCH 06/25] OP-320: Translations --- src/Form/Type/BlockType.php | 2 +- src/Form/Type/MediaType.php | 2 +- src/Form/Type/PageType.php | 2 +- src/Menu/ContentManagementMenuBuilder.php | 2 +- src/Resources/config/grids/admin/block.yml | 2 +- src/Resources/config/grids/admin/page.yml | 4 ++-- src/Resources/config/routing/admin/collection.yml | 4 ++-- src/Resources/translations/messages.cs.yml | 1 + src/Resources/translations/messages.cs_CZ.yml | 1 + src/Resources/translations/messages.de.yml | 6 +++--- src/Resources/translations/messages.en.yml | 6 +++--- src/Resources/translations/messages.es.yml | 6 +++--- src/Resources/translations/messages.fr.yml | 6 +++--- src/Resources/translations/messages.hr.yml | 6 +++--- src/Resources/translations/messages.lt.yml | 6 +++--- src/Resources/translations/messages.nl.yml | 6 +++--- src/Resources/translations/messages.pl.yml | 6 +++--- src/Resources/translations/messages.ru.yml | 6 +++--- src/Resources/translations/messages.sk.yml | 6 +++--- src/Resources/translations/messages.uk.yml | 6 +++--- src/Resources/translations/validators.cs.yml | 4 ++-- src/Resources/translations/validators.en.yml | 6 +++--- src/Resources/translations/validators.es.yml | 4 ++-- src/Resources/translations/validators.fr.yml | 4 ++-- src/Resources/translations/validators.hr.yml | 4 ++-- src/Resources/translations/validators.lt.yml | 4 ++-- src/Resources/translations/validators.nl.yml | 4 ++-- src/Resources/translations/validators.pl.yml | 2 +- src/Resources/translations/validators.ru.yml | 4 ++-- src/Resources/translations/validators.sk.yml | 4 ++-- src/Resources/translations/validators.uk.yml | 4 ++-- src/Resources/views/Shop/Page/Show/_collections.html.twig | 2 +- 32 files changed, 67 insertions(+), 65 deletions(-) diff --git a/src/Form/Type/BlockType.php b/src/Form/Type/BlockType.php index ed65f8b9d..5463527cd 100755 --- a/src/Form/Type/BlockType.php +++ b/src/Form/Type/BlockType.php @@ -35,7 +35,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void 'disabled' => null !== $block->getCode(), ]) ->add('collections', CollectionAutocompleteChoiceType::class, [ - 'label' => 'bitbag_sylius_cms_plugin.ui.sections', + 'label' => 'bitbag_sylius_cms_plugin.ui.collections', 'multiple' => true, ]) ->add('enabled', CheckboxType::class, [ diff --git a/src/Form/Type/MediaType.php b/src/Form/Type/MediaType.php index 935086973..47ecf8dc7 100644 --- a/src/Form/Type/MediaType.php +++ b/src/Form/Type/MediaType.php @@ -53,7 +53,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void 'label' => 'bitbag_sylius_cms_plugin.ui.file', ]) ->add('collections', CollectionAutocompleteChoiceType::class, [ - 'label' => 'bitbag_sylius_cms_plugin.ui.sections', + 'label' => 'bitbag_sylius_cms_plugin.ui.collections', 'multiple' => true, ]) ->add('enabled', CheckboxType::class, [ diff --git a/src/Form/Type/PageType.php b/src/Form/Type/PageType.php index a9afcd8a5..592218d97 100755 --- a/src/Form/Type/PageType.php +++ b/src/Form/Type/PageType.php @@ -41,7 +41,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void 'entry_type' => PageTranslationType::class, ]) ->add('collections', CollectionAutocompleteChoiceType::class, [ - 'label' => 'bitbag_sylius_cms_plugin.ui.sections', + 'label' => 'bitbag_sylius_cms_plugin.ui.collections', 'multiple' => true, ]) ->add('channels', ChannelChoiceType::class, [ diff --git a/src/Menu/ContentManagementMenuBuilder.php b/src/Menu/ContentManagementMenuBuilder.php index 4d82662ee..555d7118b 100755 --- a/src/Menu/ContentManagementMenuBuilder.php +++ b/src/Menu/ContentManagementMenuBuilder.php @@ -59,7 +59,7 @@ public function buildMenu(MenuBuilderEvent $menuBuilderEvent): void ->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/Resources/config/grids/admin/block.yml b/src/Resources/config/grids/admin/block.yml index 7a58e3425..759bb4af8 100755 --- a/src/Resources/config/grids/admin/block.yml +++ b/src/Resources/config/grids/admin/block.yml @@ -25,7 +25,7 @@ sylius_grid: template: "@SyliusUi/Grid/Field/enabled.html.twig" collections: type: twig - label: bitbag_sylius_cms_plugin.ui.sections + label: bitbag_sylius_cms_plugin.ui.collections path: . options: template: "@BitBagSyliusCmsPlugin/Grid/Field/collections.html.twig" diff --git a/src/Resources/config/grids/admin/page.yml b/src/Resources/config/grids/admin/page.yml index f5d042ba0..93d1c3efc 100755 --- a/src/Resources/config/grids/admin/page.yml +++ b/src/Resources/config/grids/admin/page.yml @@ -32,7 +32,7 @@ sylius_grid: sortable: translation.slug collections: type: twig - label: bitbag_sylius_cms_plugin.ui.sections + label: bitbag_sylius_cms_plugin.ui.collections path: . options: template: "@BitBagSyliusCmsPlugin/Grid/Field/collections.html.twig" @@ -44,7 +44,7 @@ sylius_grid: fields: [code] 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.collection.class%" choice_label: name diff --git a/src/Resources/config/routing/admin/collection.yml b/src/Resources/config/routing/admin/collection.yml index bc4c3b102..df6142861 100755 --- a/src/Resources/config/routing/admin/collection.yml +++ b/src/Resources/config/routing/admin/collection.yml @@ -9,8 +9,8 @@ bitbag_sylius_cms_plugin_admin_collection: 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/Collection/Crud/_form.html.twig" index: diff --git a/src/Resources/translations/messages.cs.yml b/src/Resources/translations/messages.cs.yml index 17daaf77a..ba4cbd5c1 100755 --- a/src/Resources/translations/messages.cs.yml +++ b/src/Resources/translations/messages.cs.yml @@ -1,5 +1,6 @@ bitbag_sylius_cms_plugin: ui: + collections: Kolekce blocks: Bloky block: Blok pages: Stránky diff --git a/src/Resources/translations/messages.cs_CZ.yml b/src/Resources/translations/messages.cs_CZ.yml index 17daaf77a..ba4cbd5c1 100755 --- a/src/Resources/translations/messages.cs_CZ.yml +++ b/src/Resources/translations/messages.cs_CZ.yml @@ -1,5 +1,6 @@ bitbag_sylius_cms_plugin: ui: + collections: Kolekce blocks: Bloky block: Blok pages: Stránky diff --git a/src/Resources/translations/messages.de.yml b/src/Resources/translations/messages.de.yml index b5849dbf3..3d16cb13c 100755 --- a/src/Resources/translations/messages.de.yml +++ b/src/Resources/translations/messages.de.yml @@ -32,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 b353653eb..377eefe4b 100755 --- a/src/Resources/translations/messages.en.yml +++ b/src/Resources/translations/messages.en.yml @@ -31,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 2b3671f37..cc481724e 100755 --- a/src/Resources/translations/messages.es.yml +++ b/src/Resources/translations/messages.es.yml @@ -32,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 abd43b695..904e9b1e9 100755 --- a/src/Resources/translations/messages.fr.yml +++ b/src/Resources/translations/messages.fr.yml @@ -29,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 0c7a6a811..c19fddac3 100755 --- a/src/Resources/translations/messages.hr.yml +++ b/src/Resources/translations/messages.hr.yml @@ -32,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 df481408b..055fa1245 100644 --- a/src/Resources/translations/messages.lt.yml +++ b/src/Resources/translations/messages.lt.yml @@ -29,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 1fbea9e20..59c94b119 100755 --- a/src/Resources/translations/messages.nl.yml +++ b/src/Resources/translations/messages.nl.yml @@ -31,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 52b199710..f469d53bc 100755 --- a/src/Resources/translations/messages.pl.yml +++ b/src/Resources/translations/messages.pl.yml @@ -32,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 ca26eb30c..f3b82f082 100755 --- a/src/Resources/translations/messages.ru.yml +++ b/src/Resources/translations/messages.ru.yml @@ -29,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 837ad3c93..1185b5b14 100644 --- a/src/Resources/translations/messages.sk.yml +++ b/src/Resources/translations/messages.sk.yml @@ -29,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 9149c4f3b..b2a528276 100755 --- a/src/Resources/translations/messages.uk.yml +++ b/src/Resources/translations/messages.uk.yml @@ -29,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/Shop/Page/Show/_collections.html.twig b/src/Resources/views/Shop/Page/Show/_collections.html.twig index 4a15b0b01..0dd9e995d 100755 --- a/src/Resources/views/Shop/Page/Show/_collections.html.twig +++ b/src/Resources/views/Shop/Page/Show/_collections.html.twig @@ -1,5 +1,5 @@ {% if page.collections|length > 0 %} - {{ 'bitbag_sylius_cms_plugin.ui.sections'|trans }}: + {{ 'bitbag_sylius_cms_plugin.ui.collections'|trans }}: {% for collection in page.collections %} {{ collection.name }} {% endfor %} From 8c27ec0f3d93d546adb55f839c6964fd4d1ca2c4 Mon Sep 17 00:00:00 2001 From: jkindly Date: Wed, 19 Jun 2024 08:17:53 +0200 Subject: [PATCH 07/25] OP-320: Migration - renames tables and preserves data --- src/Migrations/Version20240618120258.php | 164 +++++++++++++++++++++++ 1 file changed, 164 insertions(+) create mode 100644 src/Migrations/Version20240618120258.php diff --git a/src/Migrations/Version20240618120258.php b/src/Migrations/Version20240618120258.php new file mode 100644 index 000000000..e7060ad17 --- /dev/null +++ b/src/Migrations/Version20240618120258.php @@ -0,0 +1,164 @@ +addSql('CREATE TABLE bitbag_cms_page_sections_backup AS SELECT * FROM bitbag_cms_page_sections'); + $this->addSql('CREATE TABLE bitbag_cms_block_sections_backup AS SELECT * FROM bitbag_cms_block_sections'); + $this->addSql('CREATE TABLE bitbag_cms_media_sections_backup AS SELECT * FROM bitbag_cms_media_sections'); + $this->addSql('CREATE TABLE bitbag_cms_section_translation_backup AS SELECT * FROM bitbag_cms_section_translation'); + $this->addSql('CREATE TABLE bitbag_cms_section_pages_backup AS SELECT * FROM bitbag_cms_section_pages'); + $this->addSql('CREATE TABLE bitbag_cms_section_blocks_backup AS SELECT * FROM bitbag_cms_section_blocks'); + $this->addSql('CREATE TABLE bitbag_cms_section_media_backup AS SELECT * FROM bitbag_cms_section_media'); + $this->addSql('CREATE TABLE bitbag_cms_section_backup AS SELECT * FROM bitbag_cms_section'); + + // Perform the schema changes + $this->addSql('CREATE TABLE bitbag_cms_block_collections (block_id INT NOT NULL, collection_id INT NOT NULL, INDEX IDX_55C5E95EE9ED820C (block_id), INDEX IDX_55C5E95E514956FD (collection_id), PRIMARY KEY(block_id, collection_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE bitbag_cms_collection (id INT AUTO_INCREMENT NOT NULL, code VARCHAR(250) NOT NULL, type VARCHAR(250) DEFAULT NULL, UNIQUE INDEX UNIQ_9634175177153098 (code), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE bitbag_cms_collection_pages (collection_id INT NOT NULL, page_id INT NOT NULL, INDEX IDX_3989329D514956FD (collection_id), INDEX IDX_3989329DC4663E4 (page_id), PRIMARY KEY(collection_id, page_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE bitbag_cms_collection_blocks (collection_id INT NOT NULL, block_id INT NOT NULL, INDEX IDX_602502E5514956FD (collection_id), INDEX IDX_602502E5E9ED820C (block_id), PRIMARY KEY(collection_id, block_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE bitbag_cms_collection_media (collection_id INT NOT NULL, media_id INT NOT NULL, INDEX IDX_73D176E4514956FD (collection_id), INDEX IDX_73D176E4EA9FDD75 (media_id), PRIMARY KEY(collection_id, media_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE bitbag_cms_collection_translation (id INT AUTO_INCREMENT NOT NULL, translatable_id INT NOT NULL, name VARCHAR(255) DEFAULT NULL, locale VARCHAR(255) NOT NULL, INDEX IDX_1250294C2C2AC5D3 (translatable_id), UNIQUE INDEX bitbag_cms_collection_translation_uniq_trans (translatable_id, locale), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE bitbag_cms_media_collections (media_id INT NOT NULL, collection_id INT NOT NULL, INDEX IDX_78A0CE16EA9FDD75 (media_id), INDEX IDX_78A0CE16514956FD (collection_id), PRIMARY KEY(media_id, collection_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE bitbag_cms_page_collections (block_id INT NOT NULL, collection_id INT NOT NULL, INDEX IDX_9A9CE227E9ED820C (block_id), INDEX IDX_9A9CE227514956FD (collection_id), PRIMARY KEY(block_id, collection_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + + $this->addSql('ALTER TABLE bitbag_cms_block_collections ADD CONSTRAINT FK_55C5E95EE9ED820C FOREIGN KEY (block_id) REFERENCES bitbag_cms_block (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE bitbag_cms_block_collections ADD CONSTRAINT FK_55C5E95E514956FD FOREIGN KEY (collection_id) REFERENCES bitbag_cms_collection (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE bitbag_cms_collection_pages ADD CONSTRAINT FK_3989329D514956FD FOREIGN KEY (collection_id) REFERENCES bitbag_cms_collection (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE bitbag_cms_collection_pages ADD CONSTRAINT FK_3989329DC4663E4 FOREIGN KEY (page_id) REFERENCES bitbag_cms_page (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE bitbag_cms_collection_blocks ADD CONSTRAINT FK_602502E5514956FD FOREIGN KEY (collection_id) REFERENCES bitbag_cms_collection (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE bitbag_cms_collection_blocks ADD CONSTRAINT FK_602502E5E9ED820C FOREIGN KEY (block_id) REFERENCES bitbag_cms_block (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE bitbag_cms_collection_media ADD CONSTRAINT FK_73D176E4514956FD FOREIGN KEY (collection_id) REFERENCES bitbag_cms_collection (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE bitbag_cms_collection_media ADD CONSTRAINT FK_73D176E4EA9FDD75 FOREIGN KEY (media_id) REFERENCES bitbag_cms_media (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE bitbag_cms_collection_translation ADD CONSTRAINT FK_1250294C2C2AC5D3 FOREIGN KEY (translatable_id) REFERENCES bitbag_cms_collection (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE bitbag_cms_media_collections ADD CONSTRAINT FK_78A0CE16EA9FDD75 FOREIGN KEY (media_id) REFERENCES bitbag_cms_media (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE bitbag_cms_media_collections ADD CONSTRAINT FK_78A0CE16514956FD FOREIGN KEY (collection_id) REFERENCES bitbag_cms_collection (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE bitbag_cms_page_collections ADD CONSTRAINT FK_9A9CE227E9ED820C FOREIGN KEY (block_id) REFERENCES bitbag_cms_page (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE bitbag_cms_page_collections ADD CONSTRAINT FK_9A9CE227514956FD FOREIGN KEY (collection_id) REFERENCES bitbag_cms_collection (id) ON DELETE CASCADE'); + + // Drop old tables + $this->addSql('ALTER TABLE bitbag_cms_page_sections DROP FOREIGN KEY FK_D548E347E9ED820C'); + $this->addSql('ALTER TABLE bitbag_cms_page_sections DROP FOREIGN KEY FK_D548E347D823E37A'); + $this->addSql('ALTER TABLE bitbag_cms_block_sections DROP FOREIGN KEY FK_5C95115DE9ED820C'); + $this->addSql('ALTER TABLE bitbag_cms_block_sections DROP FOREIGN KEY FK_5C95115DD823E37A'); + $this->addSql('ALTER TABLE bitbag_cms_media_sections DROP FOREIGN KEY FK_98BC300D823E37A'); + $this->addSql('ALTER TABLE bitbag_cms_media_sections DROP FOREIGN KEY FK_98BC300EA9FDD75'); + $this->addSql('ALTER TABLE bitbag_cms_section_translation DROP FOREIGN KEY FK_F99CA8582C2AC5D3'); + $this->addSql('ALTER TABLE bitbag_cms_section_pages DROP FOREIGN KEY FK_C96225EEC4663E4'); + $this->addSql('ALTER TABLE bitbag_cms_section_pages DROP FOREIGN KEY FK_C96225EED823E37A'); + $this->addSql('ALTER TABLE bitbag_cms_section_blocks DROP FOREIGN KEY FK_A9D9C974E9ED820C'); + $this->addSql('ALTER TABLE bitbag_cms_section_blocks DROP FOREIGN KEY FK_A9D9C974D823E37A'); + $this->addSql('ALTER TABLE bitbag_cms_section_media DROP FOREIGN KEY FK_98406A0D823E37A'); + $this->addSql('ALTER TABLE bitbag_cms_section_media DROP FOREIGN KEY FK_98406A0EA9FDD75'); + + $this->addSql('DROP TABLE bitbag_cms_page_sections'); + $this->addSql('DROP TABLE bitbag_cms_block_sections'); + $this->addSql('DROP TABLE bitbag_cms_media_sections'); + $this->addSql('DROP TABLE bitbag_cms_section_translation'); + $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('DROP TABLE bitbag_cms_section'); + + // Restore data to the new tables + $this->addSql('INSERT INTO bitbag_cms_collection (id, code, type) SELECT id, code, type FROM bitbag_cms_section_backup'); + $this->addSql('INSERT INTO bitbag_cms_collection_translation (id, translatable_id, name, locale) SELECT id, translatable_id, name, locale FROM bitbag_cms_section_translation_backup'); + $this->addSql('INSERT INTO bitbag_cms_collection_pages (collection_id, page_id) SELECT section_id, page_id FROM bitbag_cms_section_pages_backup'); + $this->addSql('INSERT INTO bitbag_cms_collection_blocks (collection_id, block_id) SELECT section_id, block_id FROM bitbag_cms_section_blocks_backup'); + $this->addSql('INSERT INTO bitbag_cms_collection_media (collection_id, media_id) SELECT section_id, media_id FROM bitbag_cms_section_media_backup'); + $this->addSql('INSERT INTO bitbag_cms_page_collections (block_id, collection_id) SELECT page_id, section_id FROM bitbag_cms_page_sections_backup'); + $this->addSql('INSERT INTO bitbag_cms_block_collections (block_id, collection_id) SELECT block_id, section_id FROM bitbag_cms_block_sections_backup'); + $this->addSql('INSERT INTO bitbag_cms_media_collections (media_id, collection_id) SELECT media_id, section_id FROM bitbag_cms_media_sections_backup'); + + // Drop the backup tables + $this->addSql('DROP TABLE bitbag_cms_page_sections_backup'); + $this->addSql('DROP TABLE bitbag_cms_block_sections_backup'); + $this->addSql('DROP TABLE bitbag_cms_media_sections_backup'); + $this->addSql('DROP TABLE bitbag_cms_section_translation_backup'); + $this->addSql('DROP TABLE bitbag_cms_section_pages_backup'); + $this->addSql('DROP TABLE bitbag_cms_section_blocks_backup'); + $this->addSql('DROP TABLE bitbag_cms_section_media_backup'); + $this->addSql('DROP TABLE bitbag_cms_section_backup'); + } + + public function down(Schema $schema): void + { + // Back up data from the new tables + $this->addSql('CREATE TABLE bitbag_cms_page_collections_backup AS SELECT * FROM bitbag_cms_page_collections'); + $this->addSql('CREATE TABLE bitbag_cms_block_collections_backup AS SELECT * FROM bitbag_cms_block_collections'); + $this->addSql('CREATE TABLE bitbag_cms_media_collections_backup AS SELECT * FROM bitbag_cms_media_collections'); + $this->addSql('CREATE TABLE bitbag_cms_collection_translation_backup AS SELECT * FROM bitbag_cms_collection_translation'); + $this->addSql('CREATE TABLE bitbag_cms_collection_pages_backup AS SELECT * FROM bitbag_cms_collection_pages'); + $this->addSql('CREATE TABLE bitbag_cms_collection_blocks_backup AS SELECT * FROM bitbag_cms_collection_blocks'); + $this->addSql('CREATE TABLE bitbag_cms_collection_media_backup AS SELECT * FROM bitbag_cms_collection_media'); + $this->addSql('CREATE TABLE bitbag_cms_collection_backup AS SELECT * FROM bitbag_cms_collection'); + + // Restore the original table structures + $this->addSql('CREATE TABLE bitbag_cms_page_sections (page_id INT NOT NULL, section_id INT NOT NULL, INDEX IDX_D548E347C4663E4 (page_id), INDEX IDX_D548E347D823E37A (section_id), PRIMARY KEY(page_id, section_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE bitbag_cms_block_sections (block_id INT NOT NULL, section_id INT NOT NULL, INDEX IDX_5C95115DE9ED820C (block_id), INDEX IDX_5C95115DD823E37A (section_id), PRIMARY KEY(block_id, section_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE bitbag_cms_media_sections (media_id INT NOT NULL, section_id INT NOT NULL, INDEX IDX_98BC300EA9FDD75 (media_id), INDEX IDX_98BC300D823E37A (section_id), PRIMARY KEY(media_id, section_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE bitbag_cms_section_translation (id INT AUTO_INCREMENT NOT NULL, translatable_id INT NOT NULL, name VARCHAR(255) DEFAULT NULL, locale VARCHAR(255) NOT NULL, INDEX IDX_F99CA8582C2AC5D3 (translatable_id), UNIQUE INDEX bitbag_cms_section_translation_uniq_trans (translatable_id, locale), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE bitbag_cms_section_pages (section_id INT NOT NULL, page_id INT NOT NULL, INDEX IDX_C96225EEC4663E4 (page_id), INDEX IDX_C96225EED823E37A (section_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_A9D9C974E9ED820C (block_id), INDEX IDX_A9D9C974D823E37A (section_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_98406A0EA9FDD75 (media_id), INDEX IDX_98406A0D823E37A (section_id), PRIMARY KEY(section_id, media_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE bitbag_cms_section (id INT AUTO_INCREMENT NOT NULL, code VARCHAR(250) NOT NULL, type VARCHAR(250) DEFAULT NULL, UNIQUE INDEX UNIQ_D7D8598F77153098 (code), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + + $this->addSql('ALTER TABLE bitbag_cms_page_sections ADD CONSTRAINT FK_D548E347E9ED820C FOREIGN KEY (page_id) REFERENCES bitbag_cms_page (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE bitbag_cms_page_sections ADD CONSTRAINT FK_D548E347D823E37A FOREIGN KEY (section_id) REFERENCES bitbag_cms_section (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE bitbag_cms_block_sections ADD CONSTRAINT FK_5C95115DE9ED820C FOREIGN KEY (block_id) REFERENCES bitbag_cms_block (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE bitbag_cms_block_sections ADD CONSTRAINT FK_5C95115DD823E37A FOREIGN KEY (section_id) REFERENCES bitbag_cms_section (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE bitbag_cms_media_sections ADD CONSTRAINT FK_98BC300D823E37A FOREIGN KEY (section_id) REFERENCES bitbag_cms_section (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE bitbag_cms_media_sections ADD CONSTRAINT FK_98BC300EA9FDD75 FOREIGN KEY (media_id) REFERENCES bitbag_cms_media (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE bitbag_cms_section_translation ADD CONSTRAINT FK_F99CA8582C2AC5D3 FOREIGN KEY (translatable_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_pages ADD CONSTRAINT FK_C96225EED823E37A 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_blocks ADD CONSTRAINT FK_A9D9C974D823E37A FOREIGN KEY (section_id) REFERENCES bitbag_cms_section (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE bitbag_cms_section_media ADD CONSTRAINT FK_98406A0D823E37A FOREIGN KEY (section_id) REFERENCES bitbag_cms_section (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE bitbag_cms_section_media ADD CONSTRAINT FK_98406A0EA9FDD75 FOREIGN KEY (media_id) REFERENCES bitbag_cms_media (id) ON DELETE CASCADE'); + + // Restore data to the original tables + $this->addSql('INSERT INTO bitbag_cms_section (id, code, type) SELECT id, code, type FROM bitbag_cms_collection_backup'); + $this->addSql('INSERT INTO bitbag_cms_section_translation (id, translatable_id, name, locale) SELECT id, translatable_id, name, locale FROM bitbag_cms_collection_translation_backup'); + $this->addSql('INSERT INTO bitbag_cms_section_pages (section_id, page_id) SELECT collection_id, page_id FROM bitbag_cms_collection_pages_backup'); + $this->addSql('INSERT INTO bitbag_cms_section_blocks (section_id, block_id) SELECT collection_id, block_id FROM bitbag_cms_collection_blocks_backup'); + $this->addSql('INSERT INTO bitbag_cms_section_media (section_id, media_id) SELECT collection_id, media_id FROM bitbag_cms_collection_media_backup'); + $this->addSql('INSERT INTO bitbag_cms_page_sections (page_id, section_id) SELECT block_id, collection_id FROM bitbag_cms_page_collections_backup'); + $this->addSql('INSERT INTO bitbag_cms_block_sections (block_id, section_id) SELECT block_id, collection_id FROM bitbag_cms_block_collections_backup'); + $this->addSql('INSERT INTO bitbag_cms_media_sections (media_id, section_id) SELECT media_id, collection_id FROM bitbag_cms_media_collections_backup'); + + // Drop the new tables + $this->addSql('DROP TABLE bitbag_cms_block_collections'); + $this->addSql('DROP TABLE bitbag_cms_collection'); + $this->addSql('DROP TABLE bitbag_cms_collection_pages'); + $this->addSql('DROP TABLE bitbag_cms_collection_blocks'); + $this->addSql('DROP TABLE bitbag_cms_collection_media'); + $this->addSql('DROP TABLE bitbag_cms_collection_translation'); + $this->addSql('DROP TABLE bitbag_cms_media_collections'); + $this->addSql('DROP TABLE bitbag_cms_page_collections'); + + // Drop the backup tables + $this->addSql('DROP TABLE bitbag_cms_page_collections_backup'); + $this->addSql('DROP TABLE bitbag_cms_block_collections_backup'); + $this->addSql('DROP TABLE bitbag_cms_media_collections_backup'); + $this->addSql('DROP TABLE bitbag_cms_collection_translation_backup'); + $this->addSql('DROP TABLE bitbag_cms_collection_pages_backup'); + $this->addSql('DROP TABLE bitbag_cms_collection_blocks_backup'); + $this->addSql('DROP TABLE bitbag_cms_collection_media_backup'); + $this->addSql('DROP TABLE bitbag_cms_collection_backup'); + } +} From 3ac135ab71fab876026a9f7a79c8659aebea1395 Mon Sep 17 00:00:00 2001 From: jkindly Date: Wed, 19 Jun 2024 08:37:13 +0200 Subject: [PATCH 08/25] OP-320: spec --- spec/Assigner/CollectionsAssignerSpec.php | 46 +++++++++ spec/Assigner/SectionsAssignerSpec.php | 45 --------- spec/Entity/BlockSpec.php | 12 +-- .../{SectionSpec.php => CollectionSpec.php} | 4 +- ...Spec.php => CollectionTranslationSpec.php} | 2 +- spec/Entity/MediaSpec.php | 12 +-- spec/Entity/PageSpec.php | 12 +-- spec/Importer/BlockImporterSpec.php | 8 +- spec/Importer/MediaImporterSpec.php | 8 +- spec/Importer/PageImporterSpec.php | 10 +- .../Menu/ContentManagementMenuBuilderSpec.php | 4 +- .../ImporterCollectionsResolverSpec.php | 55 +++++++++++ .../Resolver/ImporterSectionsResolverSpec.php | 53 ---------- spec/Sorter/CollectionsSorterSpec.php | 96 +++++++++++++++++++ spec/Sorter/SectionsSorterSpec.php | 96 ------------------- .../Runtime/RenderProductPagesRuntimeSpec.php | 54 +++++------ 16 files changed, 260 insertions(+), 257 deletions(-) create mode 100644 spec/Assigner/CollectionsAssignerSpec.php delete mode 100644 spec/Assigner/SectionsAssignerSpec.php rename spec/Entity/{SectionSpec.php => CollectionSpec.php} (90%) rename spec/Entity/{SectionTranslationSpec.php => CollectionTranslationSpec.php} (95%) create mode 100644 spec/Resolver/ImporterCollectionsResolverSpec.php delete mode 100644 spec/Resolver/ImporterSectionsResolverSpec.php create mode 100644 spec/Sorter/CollectionsSorterSpec.php delete mode 100644 spec/Sorter/SectionsSorterSpec.php diff --git a/spec/Assigner/CollectionsAssignerSpec.php b/spec/Assigner/CollectionsAssignerSpec.php new file mode 100644 index 000000000..ff777b4a5 --- /dev/null +++ b/spec/Assigner/CollectionsAssignerSpec.php @@ -0,0 +1,46 @@ +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, + CollectionableInterface $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 9fe971c09..000000000 --- a/spec/Assigner/SectionsAssignerSpec.php +++ /dev/null @@ -1,45 +0,0 @@ -beConstructedWith($sectionRepository); - } - - public function it_is_initializable(): void - { - $this->shouldHaveType(CollectionsAssigner::class); - } - - public function it_implements_sections_assigner_interface(): void - { - $this->shouldHaveType(CollectionsAssignerInterface::class); - } - - public function it_assigns_sections( - CollectionRepositoryInterface $sectionRepository, - CollectionInterface $aboutSection, - CollectionInterface $blogSection, - CollectionableInterface $sectionsAware - ): void { - $sectionRepository->findOneBy(['code' => 'about'])->willReturn($aboutSection); - $sectionRepository->findOneBy(['code' => 'blog'])->willReturn($blogSection); - - $sectionsAware->addCollection($aboutSection)->shouldBeCalled(); - $sectionsAware->addCollection($blogSection)->shouldBeCalled(); - - $this->assign($sectionsAware, ['about', 'blog']); - } -} diff --git a/spec/Entity/BlockSpec.php b/spec/Entity/BlockSpec.php index 412f7feca..988f87756 100755 --- a/spec/Entity/BlockSpec.php +++ b/spec/Entity/BlockSpec.php @@ -57,16 +57,16 @@ public function it_associates_products(ProductInterface $firstProduct, ProductIn $this->hasProduct($firstProduct)->shouldReturn(false); } - public function it_associates_sections(CollectionInterface $firstSection, CollectionInterface $secondSection): void + public function it_associates_collections(CollectionInterface $firstCollection, CollectionInterface $secondCollection): void { - $this->addCollection($firstSection); - $this->hasCollection($firstSection)->shouldReturn(true); + $this->addCollection($firstCollection); + $this->hasCollection($firstCollection)->shouldReturn(true); - $this->hasCollection($secondSection)->shouldReturn(false); + $this->hasCollection($secondCollection)->shouldReturn(false); - $this->removeCollection($firstSection); + $this->removeCollection($firstCollection); - $this->hasCollection($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 90% rename from spec/Entity/SectionSpec.php rename to spec/Entity/CollectionSpec.php index 60b711421..fff615fe4 100755 --- a/spec/Entity/SectionSpec.php +++ b/spec/Entity/CollectionSpec.php @@ -15,7 +15,7 @@ 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 { @@ -27,7 +27,7 @@ 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(CollectionInterface::class); } diff --git a/spec/Entity/SectionTranslationSpec.php b/spec/Entity/CollectionTranslationSpec.php similarity index 95% rename from spec/Entity/SectionTranslationSpec.php rename to spec/Entity/CollectionTranslationSpec.php index 178a640b7..ff6d3af63 100755 --- a/spec/Entity/SectionTranslationSpec.php +++ b/spec/Entity/CollectionTranslationSpec.php @@ -16,7 +16,7 @@ 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() { diff --git a/spec/Entity/MediaSpec.php b/spec/Entity/MediaSpec.php index 33299ef03..1383fe8e3 100755 --- a/spec/Entity/MediaSpec.php +++ b/spec/Entity/MediaSpec.php @@ -77,16 +77,16 @@ public function it_associates_products(ProductInterface $firstProduct, ProductIn $this->hasProduct($firstProduct)->shouldReturn(false); } - public function it_associates_sections(CollectionInterface $firstSection, CollectionInterface $secondSection): void + public function it_associates_collections(CollectionInterface $firstCollection, CollectionInterface $secondCollection): void { - $this->addCollection($firstSection); - $this->hasCollection($firstSection)->shouldReturn(true); + $this->addCollection($firstCollection); + $this->hasCollection($firstCollection)->shouldReturn(true); - $this->hasCollection($secondSection)->shouldReturn(false); + $this->hasCollection($secondCollection)->shouldReturn(false); - $this->removeCollection($firstSection); + $this->removeCollection($firstCollection); - $this->hasCollection($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 29e06ea20..967d19c53 100755 --- a/spec/Entity/PageSpec.php +++ b/spec/Entity/PageSpec.php @@ -62,16 +62,16 @@ public function it_associates_products(ProductInterface $firstProduct, ProductIn $this->hasProduct($firstProduct)->shouldReturn(false); } - public function it_associates_sections(CollectionInterface $firstSection, CollectionInterface $secondSection): void + public function it_associates_collections(CollectionInterface $firstCollection, CollectionInterface $secondCollection): void { - $this->addCollection($firstSection); - $this->hasCollection($firstSection)->shouldReturn(true); + $this->addCollection($firstCollection); + $this->hasCollection($firstCollection)->shouldReturn(true); - $this->hasCollection($secondSection)->shouldReturn(false); + $this->hasCollection($secondCollection)->shouldReturn(false); - $this->removeCollection($firstSection); + $this->removeCollection($firstCollection); - $this->hasCollection($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 712db845f..c7a5cd00b 100644 --- a/spec/Importer/BlockImporterSpec.php +++ b/spec/Importer/BlockImporterSpec.php @@ -26,7 +26,7 @@ final class BlockImporterSpec extends ObjectBehavior public function let( ResourceResolverInterface $blockResourceResolver, LocaleContextInterface $localeContext, - ImporterCollectionsResolverInterface $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,7 +52,7 @@ public function it_is_initializable() public function it_imports_block( ResourceResolverInterface $blockResourceResolver, LocaleContextInterface $localeContext, - ImporterCollectionsResolverInterface $importerSectionsResolver, + ImporterCollectionsResolverInterface $importerCollectionsResolver, ImporterChannelsResolverInterface $importerChannelsResolver, ImporterProductsResolverInterface $importerProductsResolver, ValidatorInterface $validator, @@ -72,7 +72,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 44ec25e92..427d48871 100644 --- a/spec/Importer/MediaImporterSpec.php +++ b/spec/Importer/MediaImporterSpec.php @@ -25,7 +25,7 @@ final class MediaImporterSpec extends ObjectBehavior public function let( ResourceResolverInterface $mediaResourceResolver, LocaleContextInterface $localeContext, - ImporterCollectionsResolverInterface $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,7 +49,7 @@ public function it_is_initializable() public function it_imports_media( ResourceResolverInterface $mediaResourceResolver, LocaleContextInterface $localeContext, - ImporterCollectionsResolverInterface $importerSectionsResolver, + ImporterCollectionsResolverInterface $importerCollectionsResolver, ImporterProductsResolverInterface $importerProductsResolver, ValidatorInterface $validator, MediaRepositoryInterface $mediaRepository, @@ -68,7 +68,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 2ae33422c..73b3efc8e 100644 --- a/spec/Importer/PageImporterSpec.php +++ b/spec/Importer/PageImporterSpec.php @@ -32,7 +32,7 @@ public function let( ImageDownloaderInterface $imageDownloader, FactoryInterface $mediaFactory, MediaProviderResolverInterface $mediaProviderResolver, - ImporterCollectionsResolverInterface $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,7 +61,7 @@ public function it_is_initializable() public function it_imports_page_no_url( ResourceResolverInterface $pageResourceResolver, LocaleContextInterface $localeContext, - ImporterCollectionsResolverInterface $importerSectionsResolver, + ImporterCollectionsResolverInterface $importerCollectionsResolver, ImporterChannelsResolverInterface $importerChannelsResolver, ImporterProductsResolverInterface $importerProductsResolver, ValidatorInterface $validator, @@ -80,7 +80,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 +103,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..b96642a7d --- /dev/null +++ b/spec/Resolver/ImporterCollectionsResolverSpec.php @@ -0,0 +1,55 @@ +beConstructedWith($collectionsAssigner); + } + + public function it_is_initializable() + { + $this->shouldHaveType(ImporterCollectionsResolver::class); + } + + public function it_resolves_collections_for_collectionable_entity( + CollectionsAssignerInterface $collectionsAssigner, + CollectionableInterface $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, + CollectionableInterface $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 73c6ba4af..000000000 --- a/spec/Resolver/ImporterSectionsResolverSpec.php +++ /dev/null @@ -1,53 +0,0 @@ -beConstructedWith($sectionsAssigner); - } - - public function it_is_initializable() - { - $this->shouldHaveType(ImporterCollectionsResolver::class); - } - - public function it_resolves_sections_for_sectionable_entity( - CollectionsAssignerInterface $sectionsAssigner, - CollectionableInterface $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( - CollectionsAssignerInterface $sectionsAssigner, - CollectionableInterface $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 3357f0cf3..000000000 --- a/spec/Sorter/SectionsSorterSpec.php +++ /dev/null @@ -1,96 +0,0 @@ -shouldHaveType(CollectionsSorter::class); - } - - public function it_implements_sections_sorter_interface(): void - { - $this->shouldHaveType(CollectionsSorterInterface::class); - } - - public function it_sorts_sections_with_one_element( - PageInterface $page, - CollectionInterface $section - ): void { - $section->getCode()->willReturn('SECTION_CODE'); - $page->getCollections()->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, - CollectionInterface $section1, - CollectionInterface $section2, - CollectionInterface $section3 - ): void { - $section1->getCode()->willReturn('SECTION_1_CODE'); - $section2->getCode()->willReturn('SECTION_2_CODE'); - $section3->getCode()->willReturn('SECTION_3_CODE'); - - $page1->getCollections()->willReturn(new ArrayCollection( - [$section1->getWrappedObject(), $section3->getWrappedObject()] - )); - $page2->getCollections()->willReturn(new ArrayCollection([$section3->getWrappedObject()])); - $page3->getCollections()->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, - CollectionInterface $section1, - CollectionInterface $section2 - ): void { - $section1->getCode()->willReturn('SECTION_1_CODE'); - $section2->getCode()->willReturn('SECTION_2_CODE'); - - $page1->getCollections()->willReturn(new ArrayCollection([$section1->getWrappedObject()])); - $page2->getCollections()->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 d56d1bf5d..e9c31808b 100644 --- a/spec/Twig/Runtime/RenderProductPagesRuntimeSpec.php +++ b/spec/Twig/Runtime/RenderProductPagesRuntimeSpec.php @@ -31,9 +31,9 @@ public function let( PageRepositoryInterface $pageRepository, ChannelContextInterface $channelContext, Environment $templatingEngine, - CollectionsSorterInterface $sectionsSorter + CollectionsSorterInterface $collectionsSorter ): void { - $this->beConstructedWith($pageRepository, $channelContext, $templatingEngine, $sectionsSorter); + $this->beConstructedWith($pageRepository, $channelContext, $templatingEngine, $collectionsSorter); } public function it_is_initializable(): void @@ -47,44 +47,44 @@ public function it_implements_render_product_pages_runtime_interface(): void } public function it_renders_product_pages( - ChannelContextInterface $channelContext, - ProductInterface $product, - ChannelInterface $channel, - PageRepositoryInterface $pageRepository, - PageInterface $page, - CollectionInterface $section, - Environment $templatingEngine, - CollectionsSorterInterface $sectionsSorter + ChannelContextInterface $channelContext, + ProductInterface $product, + ChannelInterface $channel, + PageRepositoryInterface $pageRepository, + PageInterface $page, + CollectionInterface $collection, + Environment $templatingEngine, + CollectionsSorterInterface $collectionsSorter ): void { $channel->getCode()->willReturn('WEB'); $channelContext->getChannel()->willReturn($channel); - $page->getCollections()->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->sortByCollections([])->willReturn([]); + $collectionsSorter->sortByCollections([])->willReturn([]); $templatingEngine->render('_pagesByCollection.html.twig', ['data' => []])->willReturn('content'); $this->renderProductPages($product)->shouldReturn('content'); } - public function it_renders_product_pages_with_sections( - ChannelContextInterface $channelContext, - ProductInterface $product, - ChannelInterface $channel, - PageRepositoryInterface $pageRepository, - PageInterface $page, - CollectionInterface $section, - Environment $templatingEngine, - CollectionsSorterInterface $sectionsSorter + public function it_renders_product_pages_with_collections( + ChannelContextInterface $channelContext, + ProductInterface $product, + ChannelInterface $channel, + PageRepositoryInterface $pageRepository, + PageInterface $page, + CollectionInterface $collection, + Environment $templatingEngine, + CollectionsSorterInterface $collectionsSorter ): void { $channel->getCode()->willReturn('WEB'); $channelContext->getChannel()->willReturn($channel); - $page->getCollections()->willReturn(new ArrayCollection([$section])); - $section->getCode()->willReturn('SECTION_CODE'); - $pageRepository->findByProductAndCollectionCode($product, 'SECTION_CODE', 'WEB', null)->willReturn([])->shouldBeCalled(); - $sectionsSorter->sortByCollections([])->willReturn([]); + $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('_pagesByCollection.html.twig', ['data' => []])->willReturn('content'); - $this->renderProductPages($product, 'SECTION_CODE')->shouldReturn('content'); + $this->renderProductPages($product, 'COLLECTION_CODE')->shouldReturn('content'); } } From e41761dc5a3fbf6b7a68429fccdca28b7bdc2fde Mon Sep 17 00:00:00 2001 From: jkindly Date: Wed, 19 Jun 2024 11:38:56 +0200 Subject: [PATCH 09/25] OP-320: tests --- .../packages/bitbag_sylius_cms_plugin.yaml | 6 +- ...ctionContext.php => CollectionContext.php} | 24 ++--- .../Behat/Context/Setup/CollectionContext.php | 98 +++++++++++++++++++ tests/Behat/Context/Setup/PageContext.php | 20 ++-- tests/Behat/Context/Setup/SectionContext.php | 98 ------------------- ...ctionContext.php => CollectionContext.php} | 20 ++-- tests/Behat/Context/Ui/Admin/BlockContext.php | 6 +- ...ctionContext.php => CollectionContext.php} | 50 +++++----- tests/Behat/Context/Ui/Admin/PageContext.php | 6 +- tests/Behat/Context/Ui/Shop/PageContext.php | 12 +-- tests/Behat/Page/Admin/Block/CreatePage.php | 20 ++-- .../Page/Admin/Block/CreatePageInterface.php | 2 +- .../{Section => Collection}/CreatePage.php | 2 +- .../CreatePageInterface.php | 2 +- .../{Section => Collection}/IndexPage.php | 4 +- .../IndexPageInterface.php | 4 +- .../{Section => Collection}/UpdatePage.php | 2 +- .../UpdatePageInterface.php | 2 +- tests/Behat/Page/Admin/Media/CreatePage.php | 20 ++-- .../Page/Admin/Media/CreatePageInterface.php | 2 +- tests/Behat/Page/Admin/Page/CreatePage.php | 20 ++-- .../Page/Admin/Page/CreatePageInterface.php | 2 +- tests/Behat/Page/Shop/Page/IndexPage.php | 8 +- .../Page/Shop/Page/IndexPageInterface.php | 2 +- tests/Behat/Page/Shop/Page/ShowPage.php | 12 +-- .../Page/Shop/Page/ShowPageInterface.php | 2 +- tests/Behat/Resources.php | 2 +- tests/Behat/Resources/services/api.xml | 2 +- .../Behat/Resources/services/contexts/api.xml | 4 +- .../Resources/services/contexts/setup.xml | 8 +- .../Resources/services/contexts/transform.xml | 4 +- .../Behat/Resources/services/contexts/ui.xml | 8 +- .../Behat/Resources/services/pages/admin.xml | 2 +- .../services/pages/admin/collection.xml | 19 ++++ .../services/pages/admin/section.xml | 19 ---- tests/Behat/Resources/suites.yml | 4 +- .../Resources/suites/api/shop_blocks.yml | 2 +- ...shop_sections.yml => shop_collections.yml} | 10 +- .../Behat/Resources/suites/api/shop_media.yml | 2 +- .../Behat/Resources/suites/api/shop_pages.yml | 2 +- .../Resources/suites/ui/managing_blocks.yml | 2 +- ..._sections.yml => managing_collections.yml} | 8 +- .../Resources/suites/ui/managing_media.yml | 2 +- .../Resources/suites/ui/managing_pages.yml | 2 +- .../Behat/Resources/suites/ui/shop_pages.yml | 2 +- .../{SectionTest.php => CollectionTest.php} | 20 ++-- .../DataFixtures/ORM/Api/BlockTest/block.yml | 26 ++--- .../ORM/Api/CollectionTest/collection.yml} | 28 +++--- .../DataFixtures/ORM/Api/MediaTest/media.yml | 26 ++--- .../DataFixtures/ORM/Api/PageTest/page.yml | 26 ++--- tests/Functional/Fixture/BlockFixtureTest.php | 18 ++-- ...tureTest.php => CollectionFixtureTest.php} | 8 +- tests/Functional/Fixture/MediaFixtureTest.php | 18 ++-- tests/Functional/Fixture/PageFixtureTest.php | 18 ++-- .../BlockTest/test_it_get_block_by_id.json | 8 +- .../Api/BlockTest/test_it_get_blocks.json | 24 ++--- .../test_it_get_collection_by_id.json | 7 ++ .../test_it_get_collections.json | 26 +++++ .../Api/MediaTest/test_it_get_media.json | 24 ++--- .../MediaTest/test_it_get_media_by_id.json | 8 +- .../test_it_get_section_by_id.json | 7 -- .../Api/SectionTest/test_it_get_sections.json | 26 ----- ...est_it_finds_block_by_collection_code.yml} | 26 ++--- .../test_it_finds_block_by_product_code.yml | 26 ++--- .../test_it_finds_collection_by_code.yml} | 28 +++--- ..._finds_collection_by_codes_and_locale.yml} | 28 +++--- .../test_it_finds_collection_by_name.yml} | 28 +++--- ...est_it_finds_media_by_collection_code.yml} | 26 ++--- .../test_it_finds_media_by_product_code.yml | 26 ++--- ...test_it_finds_page_by_collection_code.yml} | 26 ++--- ...s_page_by_product_and_collection_code.yml} | 26 ++--- .../Repository/BlockRepositoryTest.php | 8 +- ...yTest.php => CollectionRepositoryTest.php} | 30 +++--- .../Repository/MediaRepositoryTest.php | 8 +- .../Repository/PageRepositoryTest.php | 16 +-- 75 files changed, 585 insertions(+), 585 deletions(-) rename tests/Behat/Context/Api/{SectionContext.php => CollectionContext.php} (65%) create mode 100755 tests/Behat/Context/Setup/CollectionContext.php delete mode 100755 tests/Behat/Context/Setup/SectionContext.php rename tests/Behat/Context/Transform/{SectionContext.php => CollectionContext.php} (58%) rename tests/Behat/Context/Ui/Admin/{SectionContext.php => CollectionContext.php} (77%) rename tests/Behat/Page/Admin/{Section => Collection}/CreatePage.php (93%) rename tests/Behat/Page/Admin/{Section => Collection}/CreatePageInterface.php (91%) rename tests/Behat/Page/Admin/{Section => Collection}/IndexPage.php (83%) rename tests/Behat/Page/Admin/{Section => Collection}/IndexPageInterface.php (82%) rename tests/Behat/Page/Admin/{Section => Collection}/UpdatePage.php (89%) rename tests/Behat/Page/Admin/{Section => Collection}/UpdatePageInterface.php (89%) create mode 100644 tests/Behat/Resources/services/pages/admin/collection.xml delete mode 100644 tests/Behat/Resources/services/pages/admin/section.xml rename tests/Behat/Resources/suites/api/{shop_sections.yml => shop_collections.yml} (55%) rename tests/Behat/Resources/suites/ui/{managing_sections.yml => managing_collections.yml} (63%) rename tests/Functional/Api/{SectionTest.php => CollectionTest.php} (57%) rename tests/{Integration/DataFixtures/ORM/SectionRepositoryTest/test_it_finds_section_by_name.yml => Functional/DataFixtures/ORM/Api/CollectionTest/collection.yml} (62%) rename tests/Functional/Fixture/{SectionFixtureTest.php => CollectionFixtureTest.php} (91%) create mode 100644 tests/Functional/Responses/Expected/Api/CollectionTest/test_it_get_collection_by_id.json create mode 100644 tests/Functional/Responses/Expected/Api/CollectionTest/test_it_get_collections.json delete mode 100644 tests/Functional/Responses/Expected/Api/SectionTest/test_it_get_section_by_id.json delete mode 100644 tests/Functional/Responses/Expected/Api/SectionTest/test_it_get_sections.json rename tests/Integration/DataFixtures/ORM/BlockRepositoryTest/{test_it_finds_block_by_section_code.yml => test_it_finds_block_by_collection_code.yml} (82%) rename tests/{Functional/DataFixtures/ORM/Api/SectionTest/section.yml => Integration/DataFixtures/ORM/CollectionRepositoryTest/test_it_finds_collection_by_code.yml} (62%) rename tests/Integration/DataFixtures/ORM/{SectionRepositoryTest/test_it_finds_section_by_codes_and_locale.yml => CollectionRepositoryTest/test_it_finds_collection_by_codes_and_locale.yml} (62%) rename tests/Integration/DataFixtures/ORM/{SectionRepositoryTest/test_it_finds_section_by_code.yml => CollectionRepositoryTest/test_it_finds_collection_by_name.yml} (62%) rename tests/Integration/DataFixtures/ORM/MediaRepositoryTest/{test_it_finds_media_by_section_code.yml => test_it_finds_media_by_collection_code.yml} (84%) rename tests/Integration/DataFixtures/ORM/PageRepositoryTest/{test_it_finds_page_by_section_code.yml => test_it_finds_page_by_collection_code.yml} (81%) rename tests/Integration/DataFixtures/ORM/PageRepositoryTest/{test_it_finds_page_by_product_and_section_code.yml => test_it_finds_page_by_product_and_collection_code.yml} (90%) rename tests/Integration/Repository/{SectionRepositoryTest.php => CollectionRepositoryTest.php} (62%) diff --git a/tests/Application/config/packages/bitbag_sylius_cms_plugin.yaml b/tests/Application/config/packages/bitbag_sylius_cms_plugin.yaml index 8765231c1..e3f397167 100644 --- a/tests/Application/config/packages/bitbag_sylius_cms_plugin.yaml +++ b/tests/Application/config/packages/bitbag_sylius_cms_plugin.yaml @@ -46,7 +46,7 @@ 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" collections: @@ -55,11 +55,11 @@ sylius_fixtures: 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" diff --git a/tests/Behat/Context/Api/SectionContext.php b/tests/Behat/Context/Api/CollectionContext.php similarity index 65% rename from tests/Behat/Context/Api/SectionContext.php rename to tests/Behat/Context/Api/CollectionContext.php index aac01d37a..ecba6d539 100644 --- a/tests/Behat/Context/Api/SectionContext.php +++ b/tests/Behat/Context/Api/CollectionContext.php @@ -17,7 +17,7 @@ use Tests\BitBag\SyliusCmsPlugin\Behat\Resources; use Webmozart\Assert\Assert; -final class SectionContext implements Context +final class CollectionContext implements Context { public function __construct( private ApiClientInterface $apiClient, @@ -26,17 +26,17 @@ public function __construct( } /** - * @Given /^I want to browse sections$/ + * @Given /^I want to browse collections$/ */ - public function iWantToBrowseSections(): void + public function iWantToBrowseCollections(): void { - $this->apiClient->index(Resources::SECTIONS); + $this->apiClient->index(Resources::COLLECTIONS); } /** - * @Then /^I should see (\d+) sections in the list$/ + * @Then /^I should see (\d+) collections in the list$/ */ - public function iShouldSeeSectionsInTheList(int $count): void + public function iShouldSeeCollectionsInTheList(int $count): void { Assert::count( $this->responseChecker->getCollection( @@ -47,18 +47,18 @@ public function iShouldSeeSectionsInTheList(int $count): void } /** - * @Given I view section with code :section - * @Then I should see section with code :section + * @Given I view collection with code :collection + * @Then I should see collection with code :collection */ - public function iShouldSeeSectionWithCode(CollectionInterface $section): void + public function iShouldSeeCollectionWithCode(CollectionInterface $collection): void { - $this->apiClient->show(Resources::SECTIONS, (string) $section->getId()); + $this->apiClient->show(Resources::COLLECTIONS, (string) $collection->getId()); } /** - * @Then /^I should see section name$/ + * @Then /^I should see collection name$/ */ - public function iShouldSeeSectionName(): void + public function iShouldSeeCollectionName(): void { Assert::false( $this->responseChecker->hasTranslation( diff --git a/tests/Behat/Context/Setup/CollectionContext.php b/tests/Behat/Context/Setup/CollectionContext.php new file mode 100755 index 000000000..b74ffb0cd --- /dev/null +++ b/tests/Behat/Context/Setup/CollectionContext.php @@ -0,0 +1,98 @@ +createCollection(); + + $this->saveCollection($collection); + } + + /** + * @Given there are existing collections named :firstNameCollection and :secondNameCollection + */ + public function thereAreExistingCollections(string ...$collectionsNames): void + { + foreach ($collectionsNames as $collectionName) { + $collection = $this->createCollection(null, $collectionName); + + $this->saveCollection($collection); + } + } + + /** + * @Given there is an existing collection with :code code + */ + public function thereIsAnExistingCollectionWithCode(string $code): void + { + $collection = $this->createCollection($code); + + $this->saveCollection($collection); + } + + /** + * @Given there is a :collectionName collection in the store + */ + public function thereIsACollectionInTheStore(string $collectionName): void + { + $collection = $this->createCollection(strtolower(StringInflector::nameToCode($collectionName)), $collectionName); + + $this->saveCollection($collection); + } + + private function createCollection(?string $code = null, string $name = null): CollectionInterface + { + /** @var CollectionInterface $collection */ + $collection = $this->collectionFactory->createNew(); + + if (null === $code) { + $code = $this->randomStringGenerator->generate(); + } + + if (null === $name) { + $name = $this->randomStringGenerator->generate(); + } + + $collection->setCode($code); + $collection->setCurrentLocale('en_US'); + $collection->setName($name); + + return $collection; + } + + private function saveCollection(CollectionInterface $collection): void + { + $this->collectionRepository->add($collection); + $this->sharedStorage->set('collection', $collection); + } +} diff --git a/tests/Behat/Context/Setup/PageContext.php b/tests/Behat/Context/Setup/PageContext.php index cde9f6b89..4aa9f0d93 100755 --- a/tests/Behat/Context/Setup/PageContext.php +++ b/tests/Behat/Context/Setup/PageContext.php @@ -35,7 +35,7 @@ public function __construct( private PageRepositoryInterface $pageRepository, private EntityManagerInterface $entityManager, private ProductRepositoryInterface $productRepository, - private CollectionRepositoryInterface $sectionRepository, + private CollectionRepositoryInterface $collectionRepository, private ProviderInterface $imageProvider, ) { } @@ -159,30 +159,30 @@ public function thisPageHasTheseProductsAssociatedWithIt(): void } /** - * @Given this page has these sections associated with it + * @Given this page has these collections associated with it */ - public function thisPageHasTheseSectionsAssociatedWithIt(): void + public function thisPageHasTheseCollectionsAssociatedWithIt(): void { - $sections = $this->sectionRepository->findAll(); + $collections = $this->collectionRepository->findAll(); - foreach ($sections as $section) { - $this->sharedStorage->get('page')->addSection($section); + foreach ($collections as $collection) { + $this->sharedStorage->get('page')->addCollection($collection); } $this->entityManager->flush(); } /** - * @Given these pages have this section associated with it + * @Given these pages have this collection associated with it */ - public function thesePagesHaveThisSectionAssociatedWithIt(): void + public function thesePagesHaveThisCollectionAssociatedWithIt(): void { - $section = $this->sharedStorage->get('section'); + $collection = $this->sharedStorage->get('collection'); $pages = $this->pageRepository->findAll(); /** @var PageInterface $page */ foreach ($pages as $page) { - $page->addCollection($section); + $page->addCollection($collection); } $this->entityManager->flush(); diff --git a/tests/Behat/Context/Setup/SectionContext.php b/tests/Behat/Context/Setup/SectionContext.php deleted file mode 100755 index 6ac31202e..000000000 --- a/tests/Behat/Context/Setup/SectionContext.php +++ /dev/null @@ -1,98 +0,0 @@ -createSection(); - - $this->saveSection($section); - } - - /** - * @Given there are existing sections named :firstNameSection and :secondNameSection - */ - public function thereAreExistingSections(string ...$sectionsNames): void - { - foreach ($sectionsNames as $sectionName) { - $section = $this->createSection(null, $sectionName); - - $this->saveSection($section); - } - } - - /** - * @Given there is an existing section with :code code - */ - public function thereIsAnExistingSectionWithCode(string $code): void - { - $section = $this->createSection($code); - - $this->saveSection($section); - } - - /** - * @Given there is a :sectionName section in the store - */ - public function thereIsASectionInTheStore(string $sectionName): void - { - $section = $this->createSection(strtolower(StringInflector::nameToCode($sectionName)), $sectionName); - - $this->saveSection($section); - } - - private function createSection(?string $code = null, string $name = null): CollectionInterface - { - /** @var CollectionInterface $section */ - $section = $this->sectionFactory->createNew(); - - if (null === $code) { - $code = $this->randomStringGenerator->generate(); - } - - if (null === $name) { - $name = $this->randomStringGenerator->generate(); - } - - $section->setCode($code); - $section->setCurrentLocale('en_US'); - $section->setName($name); - - return $section; - } - - private function saveSection(CollectionInterface $section): void - { - $this->sectionRepository->add($section); - $this->sharedStorage->set('section', $section); - } -} diff --git a/tests/Behat/Context/Transform/SectionContext.php b/tests/Behat/Context/Transform/CollectionContext.php similarity index 58% rename from tests/Behat/Context/Transform/SectionContext.php rename to tests/Behat/Context/Transform/CollectionContext.php index 5877b295d..6b4bb0dfe 100644 --- a/tests/Behat/Context/Transform/SectionContext.php +++ b/tests/Behat/Context/Transform/CollectionContext.php @@ -15,29 +15,29 @@ use BitBag\SyliusCmsPlugin\Repository\CollectionRepositoryInterface; use Webmozart\Assert\Assert; -final class SectionContext implements Context +final class CollectionContext implements Context { public function __construct( - private CollectionRepositoryInterface $sectionRepository, + private CollectionRepositoryInterface $collectionRepository, private string $locale = 'en_US', ) { } /** - * @Transform /^section(?:|s) "([^"]+)"$/ - * @Transform /^"([^"]+)" section(?:|s)$/ + * @Transform /^collection(?:|s) "([^"]+)"$/ + * @Transform /^"([^"]+)" collection(?:|s)$/ * @Transform /^(?:a|an) "([^"]+)"$/ - * @Transform :section + * @Transform :collection */ - public function getSectionByCode(string $sectionCode): CollectionInterface + public function getCollectionByCode(string $collectionCode): CollectionInterface { - $section = $this->sectionRepository->findOneByCode($sectionCode, $this->locale); + $collection = $this->collectionRepository->findOneByCode($collectionCode, $this->locale); Assert::notNull( - $section, - sprintf('No sections has been found with code "%s".', $sectionCode), + $collection, + sprintf('No collections has been found with code "%s".', $collectionCode), ); - return $section; + return $collection; } } diff --git a/tests/Behat/Context/Ui/Admin/BlockContext.php b/tests/Behat/Context/Ui/Admin/BlockContext.php index 67959e2cf..c43b4830a 100755 --- a/tests/Behat/Context/Ui/Admin/BlockContext.php +++ b/tests/Behat/Context/Ui/Admin/BlockContext.php @@ -148,11 +148,11 @@ public function iFillTheContentWith(string $content): void } /** - * @When I add :firstSection and :secondSection sections to it + * @When I add :firstCollection and :secondCollection collections to it */ - public function iAddAndSectionsToIt(string ...$sectionsNames): void + public function iAddAndCollectionsToIt(string ...$collectionsNames): void { - $this->resolveCurrentPage()->associateSections($sectionsNames); + $this->resolveCurrentPage()->associateCollections($collectionsNames); } /** diff --git a/tests/Behat/Context/Ui/Admin/SectionContext.php b/tests/Behat/Context/Ui/Admin/CollectionContext.php similarity index 77% rename from tests/Behat/Context/Ui/Admin/SectionContext.php rename to tests/Behat/Context/Ui/Admin/CollectionContext.php index f214ca1b1..275f336f2 100755 --- a/tests/Behat/Context/Ui/Admin/SectionContext.php +++ b/tests/Behat/Context/Ui/Admin/CollectionContext.php @@ -16,13 +16,13 @@ use Sylius\Behat\Service\NotificationCheckerInterface; use Sylius\Behat\Service\Resolver\CurrentPageResolverInterface; use Sylius\Behat\Service\SharedStorageInterface; -use Tests\BitBag\SyliusCmsPlugin\Behat\Page\Admin\Section\CreatePageInterface; -use Tests\BitBag\SyliusCmsPlugin\Behat\Page\Admin\Section\IndexPageInterface; -use Tests\BitBag\SyliusCmsPlugin\Behat\Page\Admin\Section\UpdatePageInterface; +use Tests\BitBag\SyliusCmsPlugin\Behat\Page\Admin\Collection\CreatePageInterface; +use Tests\BitBag\SyliusCmsPlugin\Behat\Page\Admin\Collection\IndexPageInterface; +use Tests\BitBag\SyliusCmsPlugin\Behat\Page\Admin\Collection\UpdatePageInterface; use Tests\BitBag\SyliusCmsPlugin\Behat\Service\RandomStringGeneratorInterface; use Webmozart\Assert\Assert; -final class SectionContext implements Context +final class CollectionContext implements Context { public function __construct( private SharedStorageInterface $sharedStorage, @@ -36,39 +36,39 @@ public function __construct( } /** - * @When I go to the sections page + * @When I go to the collections page */ - public function iGoToTheSectionsPage(): void + public function iGoToTheCollectionsPage(): void { $this->indexPage->open(); } /** - * @When I go to the create section page + * @When I go to the create collection page */ - public function iGoToTheCreateSectionPage(): void + public function iGoToTheCreateCollectionPage(): void { $this->createPage->open(); } /** - * @When I delete this section + * @When I delete this collection */ - public function iDeleteThisSection(): void + public function iDeleteThisCollection(): void { - $section = $this->sharedStorage->get('section'); + $collection = $this->sharedStorage->get('collection'); - $this->indexPage->deleteSection($section->getCode()); + $this->indexPage->deleteCollection($collection->getCode()); } /** - * @When I want to edit this section + * @When I want to edit this collection */ - public function iWantToEditThisSection(): void + public function iWantToEditThisCollection(): void { - $section = $this->sharedStorage->get('section'); + $collection = $this->sharedStorage->get('collection'); - $this->updatePage->open(['id' => $section->getId()]); + $this->updatePage->open(['id' => $collection->getId()]); } /** @@ -156,20 +156,20 @@ public function iShouldBeNotifiedThatFieldsAreTooLong(string $fields): void } /** - * @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 */ - public function iShouldBeNotifiedThatThereIsAlreadyAnExistingSectionWithCode(): void + public function iShouldBeNotifiedThatThereIsAlreadyAnExistingCollectionWithCode(): void { Assert::true($this->resolveCurrentPage()->containsErrorWithMessage( - 'There is an existing section with this code.', + 'There is an existing collection with this code.', false, )); } /** - * @Then I should be notified that new section has been created + * @Then I should be notified that new collection has been created */ - public function iShouldBeNotifiedThatNewSectionHasBeenCreated(): void + public function iShouldBeNotifiedThatNewCollectionHasBeenCreated(): void { $this->notificationChecker->checkNotification( 'Collection has been successfully created.', @@ -178,9 +178,9 @@ public function iShouldBeNotifiedThatNewSectionHasBeenCreated(): void } /** - * @Then I should be notified that the section has been deleted + * @Then I should be notified that the collection has been deleted */ - public function iShouldBeNotifiedThatTheSectionHasBeenDeleted(): void + public function iShouldBeNotifiedThatTheCollectionHasBeenDeleted(): void { $this->notificationChecker->checkNotification( 'Collection has been successfully deleted.', @@ -197,9 +197,9 @@ public function theCodeFieldShouldBeDisabled(): void } /** - * @Then I should see empty list of sections + * @Then I should see empty list of collections */ - public function iShouldSeeEmptyListOfSections(): void + public function iShouldSeeEmptyListOfCollections(): void { $this->resolveCurrentPage()->isEmpty(); } diff --git a/tests/Behat/Context/Ui/Admin/PageContext.php b/tests/Behat/Context/Ui/Admin/PageContext.php index 24307a15c..ccfe8cff2 100755 --- a/tests/Behat/Context/Ui/Admin/PageContext.php +++ b/tests/Behat/Context/Ui/Admin/PageContext.php @@ -162,11 +162,11 @@ public function iFillFields(string $fields): void } /** - * @When I add :firstSection and :secondSection sections to it + * @When I add :firstCollection and :secondCollection collections to it */ - public function iAddAndSectionsToIt(string ...$sectionsNames): void + public function iAddAndCollectionsToIt(string ...$collectionsNames): void { - $this->resolveCurrentPage()->associateSections($sectionsNames); + $this->resolveCurrentPage()->associateCollections($collectionsNames); } /** diff --git a/tests/Behat/Context/Ui/Shop/PageContext.php b/tests/Behat/Context/Ui/Shop/PageContext.php index b5663034d..94e5b477e 100755 --- a/tests/Behat/Context/Ui/Shop/PageContext.php +++ b/tests/Behat/Context/Ui/Shop/PageContext.php @@ -44,11 +44,11 @@ public function iGoToThisPage(): void } /** - * @When I go to the section pages list for the :sectionCode section + * @When I go to the collection pages list for the :collectionCode collection */ - public function iGoToTheSectionPagesListForTheSection(string $sectionCode): void + public function iGoToTheCollectionPagesListForTheCollection(string $collectionCode): void { - $this->indexPage->open(['sectionCode' => $sectionCode]); + $this->indexPage->open(['collectionCode' => $collectionCode]); } /** @@ -84,11 +84,11 @@ public function iShouldAlsoSeeProductsAssociatedWithThisPage(string ...$products } /** - * @Then I should also see :firstSectionName and :secondSectionName sections associated with this page + * @Then I should also see :firstCollectionName and :secondCollectionName collections associated with this page */ - public function iShouldAlsoSeeSectionsAssociatedWithThisPage(string ...$sectionsNames): void + public function iShouldAlsoSeeCollectionsAssociatedWithThisPage(string ...$collectionsNames): void { - Assert::true($this->showPage->hasSections($sectionsNames)); + Assert::true($this->showPage->hasCollections($collectionsNames)); } /** diff --git a/tests/Behat/Page/Admin/Block/CreatePage.php b/tests/Behat/Page/Admin/Block/CreatePage.php index e655c3da9..e3f9f8de4 100755 --- a/tests/Behat/Page/Admin/Block/CreatePage.php +++ b/tests/Behat/Page/Admin/Block/CreatePage.php @@ -49,22 +49,22 @@ public function disable(): void $this->getDocument()->uncheckField('Enabled'); } - public function associateSections(array $sectionsNames): void + public function associateCollections(array $collectionsNames): void { Assert::isInstanceOf($this->getDriver(), ChromeDriver::class); - $dropdown = $this->getElement('association_dropdown_section'); + $dropdown = $this->getElement('association_dropdown_collection'); $dropdown->click(); - foreach ($sectionsNames as $sectionName) { - $dropdown->waitFor(10, function () use ($sectionName): bool { - return $this->hasElement('association_dropdown_section_item', [ - '%item%' => $sectionName, + foreach ($collectionsNames as $collectionName) { + $dropdown->waitFor(10, function () use ($collectionName): bool { + return $this->hasElement('association_dropdown_collection_item', [ + '%item%' => $collectionName, ]); }); - $item = $this->getElement('association_dropdown_section_item', [ - '%item%' => $sectionName, + $item = $this->getElement('association_dropdown_collection_item', [ + '%item%' => $collectionName, ]); $item->click(); @@ -74,8 +74,8 @@ public function associateSections(array $sectionsNames): void protected function getDefinedElements(): array { return array_merge(parent::getDefinedElements(), [ - 'association_dropdown_section' => '.field > label:contains("Sections") ~ .sylius-autocomplete', - 'association_dropdown_section_item' => '.field > label:contains("Sections") ~ .sylius-autocomplete > div.menu > div.item:contains("%item%")', + 'association_dropdown_collection' => '.field > label:contains("Collections") ~ .sylius-autocomplete', + 'association_dropdown_collection_item' => '.field > label:contains("Collections") ~ .sylius-autocomplete > div.menu > div.item:contains("%item%")', ]); } } diff --git a/tests/Behat/Page/Admin/Block/CreatePageInterface.php b/tests/Behat/Page/Admin/Block/CreatePageInterface.php index 4ebcbb4e5..418b1f81d 100755 --- a/tests/Behat/Page/Admin/Block/CreatePageInterface.php +++ b/tests/Behat/Page/Admin/Block/CreatePageInterface.php @@ -25,7 +25,7 @@ public function fillLink(string $link): void; public function fillContent(string $content): void; - public function associateSections(array $sectionsNames): void; + public function associateCollections(array $collectionsNames): void; public function disable(): void; } diff --git a/tests/Behat/Page/Admin/Section/CreatePage.php b/tests/Behat/Page/Admin/Collection/CreatePage.php similarity index 93% rename from tests/Behat/Page/Admin/Section/CreatePage.php rename to tests/Behat/Page/Admin/Collection/CreatePage.php index 21125a3a4..c475811bf 100755 --- a/tests/Behat/Page/Admin/Section/CreatePage.php +++ b/tests/Behat/Page/Admin/Collection/CreatePage.php @@ -8,7 +8,7 @@ declare(strict_types=1); -namespace Tests\BitBag\SyliusCmsPlugin\Behat\Page\Admin\Section; +namespace Tests\BitBag\SyliusCmsPlugin\Behat\Page\Admin\Collection; use Sylius\Behat\Page\Admin\Crud\CreatePage as BaseCreatePage; use Tests\BitBag\SyliusCmsPlugin\Behat\Behaviour\ContainsErrorTrait; diff --git a/tests/Behat/Page/Admin/Section/CreatePageInterface.php b/tests/Behat/Page/Admin/Collection/CreatePageInterface.php similarity index 91% rename from tests/Behat/Page/Admin/Section/CreatePageInterface.php rename to tests/Behat/Page/Admin/Collection/CreatePageInterface.php index ec0772168..228a56df7 100755 --- a/tests/Behat/Page/Admin/Section/CreatePageInterface.php +++ b/tests/Behat/Page/Admin/Collection/CreatePageInterface.php @@ -8,7 +8,7 @@ declare(strict_types=1); -namespace Tests\BitBag\SyliusCmsPlugin\Behat\Page\Admin\Section; +namespace Tests\BitBag\SyliusCmsPlugin\Behat\Page\Admin\Collection; use Sylius\Behat\Page\Admin\Crud\CreatePageInterface as BaseCreatePageInterface; use Tests\BitBag\SyliusCmsPlugin\Behat\Behaviour\ContainsErrorInterface; diff --git a/tests/Behat/Page/Admin/Section/IndexPage.php b/tests/Behat/Page/Admin/Collection/IndexPage.php similarity index 83% rename from tests/Behat/Page/Admin/Section/IndexPage.php rename to tests/Behat/Page/Admin/Collection/IndexPage.php index 794a7d9bd..52821aec7 100755 --- a/tests/Behat/Page/Admin/Section/IndexPage.php +++ b/tests/Behat/Page/Admin/Collection/IndexPage.php @@ -8,7 +8,7 @@ declare(strict_types=1); -namespace Tests\BitBag\SyliusCmsPlugin\Behat\Page\Admin\Section; +namespace Tests\BitBag\SyliusCmsPlugin\Behat\Page\Admin\Collection; use Sylius\Behat\Page\Admin\Crud\IndexPage as BaseIndexPage; use Tests\BitBag\SyliusCmsPlugin\Behat\Behaviour\ContainsEmptyListTrait; @@ -17,7 +17,7 @@ class IndexPage extends BaseIndexPage implements IndexPageInterface { use ContainsEmptyListTrait; - public function deleteSection(string $code): void + public function deleteCollection(string $code): void { $this->deleteResourceOnPage(['code' => $code]); } diff --git a/tests/Behat/Page/Admin/Section/IndexPageInterface.php b/tests/Behat/Page/Admin/Collection/IndexPageInterface.php similarity index 82% rename from tests/Behat/Page/Admin/Section/IndexPageInterface.php rename to tests/Behat/Page/Admin/Collection/IndexPageInterface.php index b8b33d587..ae6386829 100755 --- a/tests/Behat/Page/Admin/Section/IndexPageInterface.php +++ b/tests/Behat/Page/Admin/Collection/IndexPageInterface.php @@ -8,12 +8,12 @@ declare(strict_types=1); -namespace Tests\BitBag\SyliusCmsPlugin\Behat\Page\Admin\Section; +namespace Tests\BitBag\SyliusCmsPlugin\Behat\Page\Admin\Collection; use Sylius\Behat\Page\Admin\Crud\IndexPageInterface as BaseIndexPageInterface; use Tests\BitBag\SyliusCmsPlugin\Behat\Behaviour\ContainsEmptyListInterface; interface IndexPageInterface extends BaseIndexPageInterface, ContainsEmptyListInterface { - public function deleteSection(string $code): void; + public function deleteCollection(string $code): void; } diff --git a/tests/Behat/Page/Admin/Section/UpdatePage.php b/tests/Behat/Page/Admin/Collection/UpdatePage.php similarity index 89% rename from tests/Behat/Page/Admin/Section/UpdatePage.php rename to tests/Behat/Page/Admin/Collection/UpdatePage.php index 9df6bbaf2..b0513b60f 100755 --- a/tests/Behat/Page/Admin/Section/UpdatePage.php +++ b/tests/Behat/Page/Admin/Collection/UpdatePage.php @@ -8,7 +8,7 @@ declare(strict_types=1); -namespace Tests\BitBag\SyliusCmsPlugin\Behat\Page\Admin\Section; +namespace Tests\BitBag\SyliusCmsPlugin\Behat\Page\Admin\Collection; use Sylius\Behat\Page\Admin\Crud\UpdatePage as BaseUpdatePage; use Tests\BitBag\SyliusCmsPlugin\Behat\Behaviour\ChecksCodeImmutabilityTrait; diff --git a/tests/Behat/Page/Admin/Section/UpdatePageInterface.php b/tests/Behat/Page/Admin/Collection/UpdatePageInterface.php similarity index 89% rename from tests/Behat/Page/Admin/Section/UpdatePageInterface.php rename to tests/Behat/Page/Admin/Collection/UpdatePageInterface.php index 396ee58d5..199083b0c 100755 --- a/tests/Behat/Page/Admin/Section/UpdatePageInterface.php +++ b/tests/Behat/Page/Admin/Collection/UpdatePageInterface.php @@ -8,7 +8,7 @@ declare(strict_types=1); -namespace Tests\BitBag\SyliusCmsPlugin\Behat\Page\Admin\Section; +namespace Tests\BitBag\SyliusCmsPlugin\Behat\Page\Admin\Collection; use Sylius\Behat\Page\Admin\Crud\UpdatePageInterface as BaseUpdatePageInterface; use Tests\BitBag\SyliusCmsPlugin\Behat\Behaviour\ChecksCodeImmutabilityInterface; diff --git a/tests/Behat/Page/Admin/Media/CreatePage.php b/tests/Behat/Page/Admin/Media/CreatePage.php index 3876c96de..f7747bfe5 100755 --- a/tests/Behat/Page/Admin/Media/CreatePage.php +++ b/tests/Behat/Page/Admin/Media/CreatePage.php @@ -48,22 +48,22 @@ public function fillContent(string $content): void $this->getDocument()->fillField('Content', $content); } - public function associateSections(array $sectionsNames): void + public function associateCollections(array $collectionsNames): void { Assert::isInstanceOf($this->getDriver(), ChromeDriver::class); - $dropdown = $this->getElement('association_dropdown_section'); + $dropdown = $this->getElement('association_dropdown_collection'); $dropdown->click(); - foreach ($sectionsNames as $sectionName) { - $dropdown->waitFor(5, function () use ($sectionName) { - return $this->hasElement('association_dropdown_section_item', [ - '%item%' => $sectionName, + foreach ($collectionsNames as $collectionName) { + $dropdown->waitFor(5, function () use ($collectionName) { + return $this->hasElement('association_dropdown_collection_item', [ + '%item%' => $collectionName, ]); }); - $item = $this->getElement('association_dropdown_section_item', [ - '%item%' => $sectionName, + $item = $this->getElement('association_dropdown_collection_item', [ + '%item%' => $collectionName, ]); $item->click(); @@ -73,8 +73,8 @@ public function associateSections(array $sectionsNames): void protected function getDefinedElements(): array { return array_merge(parent::getDefinedElements(), [ - 'association_dropdown_section' => '.field > label:contains("Sections") ~ .sylius-autocomplete', - 'association_dropdown_section_item' => '.field > label:contains("Sections") ~ .sylius-autocomplete > div.menu > div.item:contains("%item%")', + 'association_dropdown_collection' => '.field > label:contains("Collections") ~ .sylius-autocomplete', + 'association_dropdown_collection_item' => '.field > label:contains("Collections") ~ .sylius-autocomplete > div.menu > div.item:contains("%item%")', ]); } } diff --git a/tests/Behat/Page/Admin/Media/CreatePageInterface.php b/tests/Behat/Page/Admin/Media/CreatePageInterface.php index 0e0810a25..145f0029b 100755 --- a/tests/Behat/Page/Admin/Media/CreatePageInterface.php +++ b/tests/Behat/Page/Admin/Media/CreatePageInterface.php @@ -25,5 +25,5 @@ public function fillName(string $name): void; public function fillContent(string $content): void; - public function associateSections(array $sectionsNames): void; + public function associateCollections(array $collectionsNames): void; } diff --git a/tests/Behat/Page/Admin/Page/CreatePage.php b/tests/Behat/Page/Admin/Page/CreatePage.php index 537788973..eedea8b91 100755 --- a/tests/Behat/Page/Admin/Page/CreatePage.php +++ b/tests/Behat/Page/Admin/Page/CreatePage.php @@ -65,22 +65,22 @@ public function fillContent(string $content): void $this->getDocument()->fillField('Content', $content); } - public function associateSections(array $sectionsNames): void + public function associateCollections(array $collectionsNames): void { Assert::isInstanceOf($this->getDriver(), ChromeDriver::class); - $dropdown = $this->getElement('association_dropdown_section'); + $dropdown = $this->getElement('association_dropdown_collection'); $dropdown->click(); - foreach ($sectionsNames as $sectionName) { - $dropdown->waitFor(10, function () use ($sectionName): bool { - return $this->hasElement('association_dropdown_section_item', [ - '%item%' => $sectionName, + foreach ($collectionsNames as $collectionName) { + $dropdown->waitFor(10, function () use ($collectionName): bool { + return $this->hasElement('association_dropdown_collection_item', [ + '%item%' => $collectionName, ]); }); - $item = $this->getElement('association_dropdown_section_item', [ - '%item%' => $sectionName, + $item = $this->getElement('association_dropdown_collection_item', [ + '%item%' => $collectionName, ]); $item->click(); @@ -91,8 +91,8 @@ protected function getDefinedElements(): array { return array_merge(parent::getDefinedElements(), [ 'slug' => '#bitbag_sylius_cms_plugin_page_translations_en_US_slug', - 'association_dropdown_section' => '.field > label:contains("Sections") ~ .sylius-autocomplete', - 'association_dropdown_section_item' => '.field > label:contains("Sections") ~ .sylius-autocomplete > div.menu > div.item:contains("%item%")', + 'association_dropdown_collection' => '.field > label:contains("Collections") ~ .sylius-autocomplete', + 'association_dropdown_collection_item' => '.field > label:contains("Collections") ~ .sylius-autocomplete > div.menu > div.item:contains("%item%")', ]); } } diff --git a/tests/Behat/Page/Admin/Page/CreatePageInterface.php b/tests/Behat/Page/Admin/Page/CreatePageInterface.php index 71f4390dd..f907729ae 100755 --- a/tests/Behat/Page/Admin/Page/CreatePageInterface.php +++ b/tests/Behat/Page/Admin/Page/CreatePageInterface.php @@ -33,5 +33,5 @@ public function fillMetaDescription(string $metaDescription): void; public function fillContent(string $content): void; - public function associateSections(array $sectionsNames): void; + public function associateCollections(array $collectionsNames): void; } diff --git a/tests/Behat/Page/Shop/Page/IndexPage.php b/tests/Behat/Page/Shop/Page/IndexPage.php index 2ec4e5960..526dd6334 100755 --- a/tests/Behat/Page/Shop/Page/IndexPage.php +++ b/tests/Behat/Page/Shop/Page/IndexPage.php @@ -16,12 +16,12 @@ final class IndexPage extends SymfonyPage implements IndexPageInterface { public function getRouteName(): string { - return 'bitbag_sylius_cms_plugin_shop_page_index_by_section_code'; + return 'bitbag_sylius_cms_plugin_shop_page_index_by_collection_code'; } - public function hasSectionName(string $sectionName): bool + public function hasCollectionName(string $collectionName): bool { - return $sectionName === $this->getElement('section')->getText(); + return $collectionName === $this->getElement('collection')->getText(); } public function hasPagesNumber(int $pagesNumber): bool @@ -34,7 +34,7 @@ public function hasPagesNumber(int $pagesNumber): bool protected function getDefinedElements(): array { return array_merge(parent::getDefinedElements(), [ - 'section' => '.bitbag-section-name', + 'collection' => '.bitbag-collection-name', 'pages' => '#bitbag-pages', ]); } diff --git a/tests/Behat/Page/Shop/Page/IndexPageInterface.php b/tests/Behat/Page/Shop/Page/IndexPageInterface.php index d1c33b17f..fcc486847 100755 --- a/tests/Behat/Page/Shop/Page/IndexPageInterface.php +++ b/tests/Behat/Page/Shop/Page/IndexPageInterface.php @@ -14,7 +14,7 @@ interface IndexPageInterface extends SymfonyPageInterface { - public function hasSectionName(string $sectionName): bool; + public function hasCollectionName(string $collectionName): bool; public function hasPagesNumber(int $pagesNumber): bool; } diff --git a/tests/Behat/Page/Shop/Page/ShowPage.php b/tests/Behat/Page/Shop/Page/ShowPage.php index f1d56b49a..4a983b3fa 100755 --- a/tests/Behat/Page/Shop/Page/ShowPage.php +++ b/tests/Behat/Page/Shop/Page/ShowPage.php @@ -44,13 +44,13 @@ public function hasProducts(array $productsNames): bool return true; } - public function hasSections(array $sectionNames): bool + public function hasCollections(array $collectionNames): bool { - $sectionsOnPage = $this->getElement('sections')->findAll('css', 'a'); + $collectionsOnPage = $this->getElement('collections')->findAll('css', 'a'); - /** @var NodeElement $sectionOnPage */ - foreach ($sectionsOnPage as $sectionOnPage) { - if (false === in_array($sectionOnPage->getText(), $sectionNames, true)) { + /** @var NodeElement $collectionOnPage */ + foreach ($collectionsOnPage as $collectionOnPage) { + if (false === in_array($collectionOnPage->getText(), $collectionNames, true)) { return false; } } @@ -79,7 +79,7 @@ protected function getDefinedElements(): array 'name' => '.bitbag-page-name', 'content' => '.bitbag-page-content', 'products' => '.bitbag-page-products', - 'sections' => '.bitbag-page-sections', + 'collections' => '.bitbag-page-collections', 'link' => '.bitbag-page-link', 'page-image' => '.page-image', ]); diff --git a/tests/Behat/Page/Shop/Page/ShowPageInterface.php b/tests/Behat/Page/Shop/Page/ShowPageInterface.php index 262fdf259..8d6b2bcad 100755 --- a/tests/Behat/Page/Shop/Page/ShowPageInterface.php +++ b/tests/Behat/Page/Shop/Page/ShowPageInterface.php @@ -20,7 +20,7 @@ public function hasContent(string $content): bool; public function hasProducts(array $productsNames): bool; - public function hasSections(array $sectionNames): bool; + public function hasCollections(array $collectionNames): bool; public function hasPageLink(string $linkName): bool; diff --git a/tests/Behat/Resources.php b/tests/Behat/Resources.php index 4717982b8..0c96fac05 100644 --- a/tests/Behat/Resources.php +++ b/tests/Behat/Resources.php @@ -20,5 +20,5 @@ final class Resources public const PAGES = 'pages'; - public const SECTIONS = 'sections'; + public const COLLECTIONS = 'collections'; } diff --git a/tests/Behat/Resources/services/api.xml b/tests/Behat/Resources/services/api.xml index a925620b4..8f0accc21 100644 --- a/tests/Behat/Resources/services/api.xml +++ b/tests/Behat/Resources/services/api.xml @@ -20,7 +20,7 @@ shop/cms-plugin - + shop/cms-plugin diff --git a/tests/Behat/Resources/services/contexts/api.xml b/tests/Behat/Resources/services/contexts/api.xml index 518fc0fc2..33868af8d 100644 --- a/tests/Behat/Resources/services/contexts/api.xml +++ b/tests/Behat/Resources/services/contexts/api.xml @@ -24,8 +24,8 @@ - - + + diff --git a/tests/Behat/Resources/services/contexts/setup.xml b/tests/Behat/Resources/services/contexts/setup.xml index 1d30199f2..dc47ca86d 100644 --- a/tests/Behat/Resources/services/contexts/setup.xml +++ b/tests/Behat/Resources/services/contexts/setup.xml @@ -18,7 +18,7 @@ - + @@ -29,11 +29,11 @@ - + - - + + diff --git a/tests/Behat/Resources/services/contexts/transform.xml b/tests/Behat/Resources/services/contexts/transform.xml index 57acb102b..6480d616c 100644 --- a/tests/Behat/Resources/services/contexts/transform.xml +++ b/tests/Behat/Resources/services/contexts/transform.xml @@ -23,8 +23,8 @@ %locale% - - + + %locale% diff --git a/tests/Behat/Resources/services/contexts/ui.xml b/tests/Behat/Resources/services/contexts/ui.xml index ce646296a..83901074b 100644 --- a/tests/Behat/Resources/services/contexts/ui.xml +++ b/tests/Behat/Resources/services/contexts/ui.xml @@ -36,13 +36,13 @@ - + - - - + + + diff --git a/tests/Behat/Resources/services/pages/admin.xml b/tests/Behat/Resources/services/pages/admin.xml index b7c554614..96078ff23 100644 --- a/tests/Behat/Resources/services/pages/admin.xml +++ b/tests/Behat/Resources/services/pages/admin.xml @@ -5,7 +5,7 @@ - + diff --git a/tests/Behat/Resources/services/pages/admin/collection.xml b/tests/Behat/Resources/services/pages/admin/collection.xml new file mode 100644 index 000000000..0ea46c80c --- /dev/null +++ b/tests/Behat/Resources/services/pages/admin/collection.xml @@ -0,0 +1,19 @@ + + + + + + + + bitbag_sylius_cms_plugin_admin_collection_index + + + + bitbag_sylius_cms_plugin_admin_collection_create + + + + bitbag_sylius_cms_plugin_admin_collection_update + + + diff --git a/tests/Behat/Resources/services/pages/admin/section.xml b/tests/Behat/Resources/services/pages/admin/section.xml deleted file mode 100644 index 6aeefa32a..000000000 --- a/tests/Behat/Resources/services/pages/admin/section.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - bitbag_sylius_cms_plugin_admin_section_index - - - - bitbag_sylius_cms_plugin_admin_section_create - - - - bitbag_sylius_cms_plugin_admin_section_update - - - diff --git a/tests/Behat/Resources/suites.yml b/tests/Behat/Resources/suites.yml index 773c3c0be..6ef678e58 100644 --- a/tests/Behat/Resources/suites.yml +++ b/tests/Behat/Resources/suites.yml @@ -2,7 +2,7 @@ imports: - suites/ui/managing_blocks.yml - suites/ui/managing_pages.yml - suites/ui/managing_frequently_asked_questions.yml - - suites/ui/managing_sections.yml + - suites/ui/managing_collections.yml - suites/ui/managing_media.yml - suites/ui/shop_blocks.yml - suites/ui/shop_media.yml @@ -12,5 +12,5 @@ imports: - suites/api/shop_pages.yml - suites/api/shop_frequently_asked_questions.yml - suites/api/shop_blocks.yml - - suites/api/shop_sections.yml + - suites/api/shop_collections.yml - suites/api/shop_media.yml diff --git a/tests/Behat/Resources/suites/api/shop_blocks.yml b/tests/Behat/Resources/suites/api/shop_blocks.yml index 7320a7210..f51d34a29 100755 --- a/tests/Behat/Resources/suites/api/shop_blocks.yml +++ b/tests/Behat/Resources/suites/api/shop_blocks.yml @@ -7,7 +7,7 @@ default: - sylius.behat.context.setup.channel - sylius.behat.context.setup.admin_security - bitbag_sylius_cms_plugin.behat.context.setup.block - - bitbag_sylius_cms_plugin.behat.context.setup.section + - bitbag_sylius_cms_plugin.behat.context.setup.collection - bitbag_sylius_cms_plugin.behat.context.transform.block - bitbag_sylius_cms_plugin.behat.context.api.block diff --git a/tests/Behat/Resources/suites/api/shop_sections.yml b/tests/Behat/Resources/suites/api/shop_collections.yml similarity index 55% rename from tests/Behat/Resources/suites/api/shop_sections.yml rename to tests/Behat/Resources/suites/api/shop_collections.yml index 17505ac36..ff30352d9 100755 --- a/tests/Behat/Resources/suites/api/shop_sections.yml +++ b/tests/Behat/Resources/suites/api/shop_collections.yml @@ -1,14 +1,14 @@ default: suites: - api_shop_sections: + api_shop_collections: contexts: - sylius.behat.context.hook.doctrine_orm - sylius.behat.context.setup.channel - sylius.behat.context.setup.admin_security - - bitbag_sylius_cms_plugin.behat.context.setup.section - - bitbag_sylius_cms_plugin.behat.context.transform.section + - bitbag_sylius_cms_plugin.behat.context.setup.collection + - bitbag_sylius_cms_plugin.behat.context.transform.collection - - bitbag_sylius_cms_plugin.behat.context.api.section + - bitbag_sylius_cms_plugin.behat.context.api.collection filters: - tags: "@shop_sections&&@api" + tags: "@shop_collections&&@api" diff --git a/tests/Behat/Resources/suites/api/shop_media.yml b/tests/Behat/Resources/suites/api/shop_media.yml index 0b3428f4c..642500769 100755 --- a/tests/Behat/Resources/suites/api/shop_media.yml +++ b/tests/Behat/Resources/suites/api/shop_media.yml @@ -8,7 +8,7 @@ default: - sylius.behat.context.setup.admin_security - sylius.behat.context.setup.product - bitbag_sylius_cms_plugin.behat.context.setup.media - - bitbag_sylius_cms_plugin.behat.context.setup.section + - bitbag_sylius_cms_plugin.behat.context.setup.collection - bitbag_sylius_cms_plugin.behat.context.transform.media - bitbag_sylius_cms_plugin.behat.context.api.media diff --git a/tests/Behat/Resources/suites/api/shop_pages.yml b/tests/Behat/Resources/suites/api/shop_pages.yml index f6b469ad8..ba7ea9598 100755 --- a/tests/Behat/Resources/suites/api/shop_pages.yml +++ b/tests/Behat/Resources/suites/api/shop_pages.yml @@ -9,7 +9,7 @@ default: - sylius.behat.context.setup.channel - sylius.behat.context.setup.product - bitbag_sylius_cms_plugin.behat.context.setup.page - - bitbag_sylius_cms_plugin.behat.context.setup.section + - bitbag_sylius_cms_plugin.behat.context.setup.collection - bitbag_sylius_cms_plugin.behat.context.api.page filters: diff --git a/tests/Behat/Resources/suites/ui/managing_blocks.yml b/tests/Behat/Resources/suites/ui/managing_blocks.yml index 08545077c..3a93e317d 100755 --- a/tests/Behat/Resources/suites/ui/managing_blocks.yml +++ b/tests/Behat/Resources/suites/ui/managing_blocks.yml @@ -7,7 +7,7 @@ default: - sylius.behat.context.setup.channel - sylius.behat.context.setup.admin_security - bitbag_sylius_cms_plugin.behat.context.setup.block - - bitbag_sylius_cms_plugin.behat.context.setup.section + - bitbag_sylius_cms_plugin.behat.context.setup.collection - bitbag_sylius_cms_plugin.behat.context.ui.admin.block filters: diff --git a/tests/Behat/Resources/suites/ui/managing_sections.yml b/tests/Behat/Resources/suites/ui/managing_collections.yml similarity index 63% rename from tests/Behat/Resources/suites/ui/managing_sections.yml rename to tests/Behat/Resources/suites/ui/managing_collections.yml index 3722bcd24..b81a79f0e 100755 --- a/tests/Behat/Resources/suites/ui/managing_sections.yml +++ b/tests/Behat/Resources/suites/ui/managing_collections.yml @@ -1,13 +1,13 @@ default: suites: - ui_managing_sections: + ui_managing_collections: contexts: - sylius.behat.context.hook.doctrine_orm - sylius.behat.context.setup.channel - sylius.behat.context.setup.admin_security - - bitbag_sylius_cms_plugin.behat.context.setup.section + - bitbag_sylius_cms_plugin.behat.context.setup.collection - - bitbag_sylius_cms_plugin.behat.context.ui.admin.section + - bitbag_sylius_cms_plugin.behat.context.ui.admin.collection filters: - tags: "@managing_sections&&@ui" + tags: "@managing_collections&&@ui" diff --git a/tests/Behat/Resources/suites/ui/managing_media.yml b/tests/Behat/Resources/suites/ui/managing_media.yml index 28299535d..4cab4671b 100755 --- a/tests/Behat/Resources/suites/ui/managing_media.yml +++ b/tests/Behat/Resources/suites/ui/managing_media.yml @@ -8,7 +8,7 @@ default: - sylius.behat.context.setup.admin_security - sylius.behat.context.setup.product - bitbag_sylius_cms_plugin.behat.context.setup.media - - bitbag_sylius_cms_plugin.behat.context.setup.section + - bitbag_sylius_cms_plugin.behat.context.setup.collection - bitbag_sylius_cms_plugin.behat.context.ui.admin.media filters: diff --git a/tests/Behat/Resources/suites/ui/managing_pages.yml b/tests/Behat/Resources/suites/ui/managing_pages.yml index 4f27112ef..becd2c602 100755 --- a/tests/Behat/Resources/suites/ui/managing_pages.yml +++ b/tests/Behat/Resources/suites/ui/managing_pages.yml @@ -9,7 +9,7 @@ default: - sylius.behat.context.setup.product - bitbag_sylius_cms_plugin.behat.context.setup.media - bitbag_sylius_cms_plugin.behat.context.setup.page - - bitbag_sylius_cms_plugin.behat.context.setup.section + - bitbag_sylius_cms_plugin.behat.context.setup.collection - bitbag_sylius_cms_plugin.behat.context.ui.admin.page filters: diff --git a/tests/Behat/Resources/suites/ui/shop_pages.yml b/tests/Behat/Resources/suites/ui/shop_pages.yml index a2eac7ca4..1818b8f52 100755 --- a/tests/Behat/Resources/suites/ui/shop_pages.yml +++ b/tests/Behat/Resources/suites/ui/shop_pages.yml @@ -7,7 +7,7 @@ default: - sylius.behat.context.setup.channel - sylius.behat.context.setup.product - bitbag_sylius_cms_plugin.behat.context.setup.page - - bitbag_sylius_cms_plugin.behat.context.setup.section + - bitbag_sylius_cms_plugin.behat.context.setup.collection - bitbag_sylius_cms_plugin.behat.context.ui.shop.page filters: diff --git a/tests/Functional/Api/SectionTest.php b/tests/Functional/Api/CollectionTest.php similarity index 57% rename from tests/Functional/Api/SectionTest.php rename to tests/Functional/Api/CollectionTest.php index 3e0a85661..c9d9a67ec 100644 --- a/tests/Functional/Api/SectionTest.php +++ b/tests/Functional/Api/CollectionTest.php @@ -16,31 +16,31 @@ use Symfony\Component\HttpFoundation\Response; use Tests\BitBag\SyliusCmsPlugin\Functional\FunctionalTestCase; -class SectionTest extends FunctionalTestCase +class CollectionTest extends FunctionalTestCase { public const CONTENT_TYPE_HEADER = ['CONTENT_TYPE' => 'application/ld+json', 'HTTP_ACCEPT' => 'application/ld+json']; public function setUp(): void { - $this->loadFixturesFromFile('Api/SectionTest/collection.yml'); + $this->loadFixturesFromFile('Api/CollectionTest/collection.yml'); } - public function test_section_response(): void + public function test_collection_response(): void { - /** @var CollectionInterface $section */ - $section = $this->getRepository()->findOneByCode('section1-code', 'en_US'); - $this->client->request('GET', '/api/v2/shop/cms-plugin/sections/' . $section->getId(), [], [], self::CONTENT_TYPE_HEADER); + /** @var CollectionInterface $collection */ + $collection = $this->getRepository()->findOneByCode('collection1-code', 'en_US'); + $this->client->request('GET', '/api/v2/shop/cms-plugin/collections/' . $collection->getId(), [], [], self::CONTENT_TYPE_HEADER); $response = $this->client->getResponse(); - $this->assertResponse($response, 'Api/SectionTest/test_it_get_section_by_id', Response::HTTP_OK); + $this->assertResponse($response, 'Api/CollectionTest/test_it_get_collection_by_id', Response::HTTP_OK); } - public function test_sections_response(): void + public function test_collections_response(): void { - $this->client->request('GET', '/api/v2/shop/cms-plugin/sections', [], [], self::CONTENT_TYPE_HEADER); + $this->client->request('GET', '/api/v2/shop/cms-plugin/collections', [], [], self::CONTENT_TYPE_HEADER); $response = $this->client->getResponse(); - $this->assertResponse($response, 'Api/SectionTest/test_it_get_sections', Response::HTTP_OK); + $this->assertResponse($response, 'Api/CollectionTest/test_it_get_collections', Response::HTTP_OK); } private function getRepository(): CollectionRepositoryInterface diff --git a/tests/Functional/DataFixtures/ORM/Api/BlockTest/block.yml b/tests/Functional/DataFixtures/ORM/Api/BlockTest/block.yml index 8fe7d1a68..67e66abd9 100644 --- a/tests/Functional/DataFixtures/ORM/Api/BlockTest/block.yml +++ b/tests/Functional/DataFixtures/ORM/Api/BlockTest/block.yml @@ -94,8 +94,8 @@ BitBag\SyliusCmsPlugin\Entity\Block: enabled: true products: - '@product1' - sections: - - '@section1' + collections: + - '@collection1' channels: - '@channel' translations: @@ -107,8 +107,8 @@ BitBag\SyliusCmsPlugin\Entity\Block: enabled: true products: - '@product2' - sections: - - '@section2' + collections: + - '@collection2' channels: - '@channel' translations: @@ -118,17 +118,17 @@ BitBag\SyliusCmsPlugin\Entity\Block: enabled: false products: - '@product3' - sections: - - '@section3' + collections: + - '@collection3' channels: - '@channel' translations: - '@block3_translation' -BitBag\SyliusCmsPlugin\Entity\Section: - section1: - code: 'section1-code' - section2: - code: 'section2-code' - section3: - code: 'section3-code' +BitBag\SyliusCmsPlugin\Entity\Collection: + collection1: + code: 'collection1-code' + collection2: + code: 'collection2-code' + collection3: + code: 'collection3-code' diff --git a/tests/Integration/DataFixtures/ORM/SectionRepositoryTest/test_it_finds_section_by_name.yml b/tests/Functional/DataFixtures/ORM/Api/CollectionTest/collection.yml similarity index 62% rename from tests/Integration/DataFixtures/ORM/SectionRepositoryTest/test_it_finds_section_by_name.yml rename to tests/Functional/DataFixtures/ORM/Api/CollectionTest/collection.yml index de388d554..1f2c81aa4 100644 --- a/tests/Integration/DataFixtures/ORM/SectionRepositoryTest/test_it_finds_section_by_name.yml +++ b/tests/Functional/DataFixtures/ORM/Api/CollectionTest/collection.yml @@ -17,26 +17,26 @@ Sylius\Component\Core\Model\Channel: default_locale: '@locale' tax_calculation_strategy: 'order_items_based' base_currency: '@dollar' -BitBag\SyliusCmsPlugin\Entity\SectionTranslation: - section1_translation: +BitBag\SyliusCmsPlugin\Entity\CollectionTranslation: + collection1_translation: name: 'translation1_name_en_US' locale: 'en_US' - section2_translation: + collection2_translation: name: 'translation2_name_en_US' locale: 'en_US' - section3_translation: + collection3_translation: name: 'translation3_name_en_US' locale: 'en_US' -BitBag\SyliusCmsPlugin\Entity\Section: - section1: - code: 'section1-code' +BitBag\SyliusCmsPlugin\Entity\Collection: + collection1: + code: 'collection1-code' translations: - - '@section1_translation' - section2: - code: 'section2-code' + - '@collection1_translation' + collection2: + code: 'collection2-code' translations: - - '@section2_translation' - section3: - code: 'section3-code' + - '@collection2_translation' + collection3: + code: 'collection3-code' translations: - - '@section3_translation' + - '@collection3_translation' diff --git a/tests/Functional/DataFixtures/ORM/Api/MediaTest/media.yml b/tests/Functional/DataFixtures/ORM/Api/MediaTest/media.yml index 119becddf..7c6fcadf7 100644 --- a/tests/Functional/DataFixtures/ORM/Api/MediaTest/media.yml +++ b/tests/Functional/DataFixtures/ORM/Api/MediaTest/media.yml @@ -96,8 +96,8 @@ BitBag\SyliusCmsPlugin\Entity\Media: path: '/path/to/media1' products: - '@product1' - sections: - - '@section1' + collections: + - '@collection1' channels: - '@channel' translations: @@ -109,8 +109,8 @@ BitBag\SyliusCmsPlugin\Entity\Media: path: '/path/to/media2' products: - '@product2' - sections: - - '@section2' + collections: + - '@collection2' channels: - '@channel' translations: @@ -122,17 +122,17 @@ BitBag\SyliusCmsPlugin\Entity\Media: path: '/path/to/media3' products: - '@product3' - sections: - - '@section3' + collections: + - '@collection3' channels: - '@channel' translations: - '@media3_translation' -BitBag\SyliusCmsPlugin\Entity\Section: - section1: - code: 'section1-code' - section2: - code: 'section2-code' - section3: - code: 'section3-code' +BitBag\SyliusCmsPlugin\Entity\Collection: + collection1: + code: 'collection1-code' + collection2: + code: 'collection2-code' + collection3: + code: 'collection3-code' diff --git a/tests/Functional/DataFixtures/ORM/Api/PageTest/page.yml b/tests/Functional/DataFixtures/ORM/Api/PageTest/page.yml index a2778e2a8..27ae79318 100644 --- a/tests/Functional/DataFixtures/ORM/Api/PageTest/page.yml +++ b/tests/Functional/DataFixtures/ORM/Api/PageTest/page.yml @@ -103,8 +103,8 @@ BitBag\SyliusCmsPlugin\Entity\Page: enabled: true products: - '@product1' - sections: - - '@section1' + collections: + - '@collection1' channels: - '@channel' translations: @@ -114,8 +114,8 @@ BitBag\SyliusCmsPlugin\Entity\Page: enabled: true products: - '@product2' - sections: - - '@section2' + collections: + - '@collection2' channels: - '@channel' translations: @@ -125,17 +125,17 @@ BitBag\SyliusCmsPlugin\Entity\Page: enabled: false products: - '@product3' - sections: - - '@section3' + collections: + - '@collection3' channels: - '@channel' translations: - '@page3_translation' -BitBag\SyliusCmsPlugin\Entity\Section: - section1: - code: 'section1-code' - section2: - code: 'section2-code' - section3: - code: 'section3-code' +BitBag\SyliusCmsPlugin\Entity\Collection: + collection1: + code: 'collection1-code' + collection2: + code: 'collection2-code' + collection3: + code: 'collection3-code' diff --git a/tests/Functional/Fixture/BlockFixtureTest.php b/tests/Functional/Fixture/BlockFixtureTest.php index 8f5d6454c..6916a941d 100644 --- a/tests/Functional/Fixture/BlockFixtureTest.php +++ b/tests/Functional/Fixture/BlockFixtureTest.php @@ -220,47 +220,47 @@ public function custom_translations_is_optional_but_must_be_array(): void /** * @test */ - public function custom_sections_is_optional_but_must_be_scalar_array(): void + public function custom_collections_is_optional_but_must_be_scalar_array(): void { $this->assertConfigurationIsValid([ [ 'custom' => [ 'homepage_banner' => [ - 'sections' => ['blog', 'homepage'], + 'collections' => ['blog', 'homepage'], ], ], ], - ], 'custom.*.sections'); + ], 'custom.*.collections'); $this->assertConfigurationIsValid([ [ 'custom' => [ 'homepage_banner' => [ - 'sections' => [], + 'collections' => [], ], ], ], - ], 'custom.*.sections'); + ], 'custom.*.collections'); $this->assertPartialConfigurationIsInvalid([ [ 'custom' => [ 'custom_1' => [ - 'sections' => '', + 'collections' => '', ], ], ], - ], 'custom.*.sections'); + ], 'custom.*.collections'); $this->assertPartialConfigurationIsInvalid([ [ 'custom' => [ 'custom_1' => [ - 'section_name' => 'blog', + 'collection_name' => 'blog', ], ], ], - ], 'custom.*.sections'); + ], 'custom.*.collections'); } /** diff --git a/tests/Functional/Fixture/SectionFixtureTest.php b/tests/Functional/Fixture/CollectionFixtureTest.php similarity index 91% rename from tests/Functional/Fixture/SectionFixtureTest.php rename to tests/Functional/Fixture/CollectionFixtureTest.php index a1704272e..8efa36c1c 100644 --- a/tests/Functional/Fixture/SectionFixtureTest.php +++ b/tests/Functional/Fixture/CollectionFixtureTest.php @@ -15,7 +15,7 @@ use Matthias\SymfonyConfigTest\PhpUnit\ConfigurationTestCaseTrait; use PHPUnit\Framework\TestCase; -final class SectionFixtureTest extends TestCase +final class CollectionFixtureTest extends TestCase { use ConfigurationTestCaseTrait; @@ -115,9 +115,9 @@ public function custom_remove_existing_is_optional_but_must_be_boolean(): void protected function getConfiguration(): CollectionFixture { - /** @var FixtureFactoryInterface $sectionFixtureFactory */ - $sectionFixtureFactory = $this->getMockBuilder(FixtureFactoryInterface::class)->getMock(); + /** @var FixtureFactoryInterface $collectionFixtureFactory */ + $collectionFixtureFactory = $this->getMockBuilder(FixtureFactoryInterface::class)->getMock(); - return new CollectionFixture($sectionFixtureFactory); + return new CollectionFixture($collectionFixtureFactory); } } diff --git a/tests/Functional/Fixture/MediaFixtureTest.php b/tests/Functional/Fixture/MediaFixtureTest.php index df1fbabce..5341a191b 100644 --- a/tests/Functional/Fixture/MediaFixtureTest.php +++ b/tests/Functional/Fixture/MediaFixtureTest.php @@ -236,47 +236,47 @@ public function custom_remove_existing_is_optional_but_must_be_boolean(): void /** * @test */ - public function custom_sections_is_optional_but_must_be_scalar_array(): void + public function custom_collections_is_optional_but_must_be_scalar_array(): void { $this->assertConfigurationIsValid([ [ 'custom' => [ 'media_banner' => [ - 'sections' => ['blog', 'media'], + 'collections' => ['blog', 'media'], ], ], ], - ], 'custom.*.sections'); + ], 'custom.*.collections'); $this->assertConfigurationIsValid([ [ 'custom' => [ 'media_banner' => [ - 'sections' => [], + 'collections' => [], ], ], ], - ], 'custom.*.sections'); + ], 'custom.*.collections'); $this->assertPartialConfigurationIsInvalid([ [ 'custom' => [ 'custom_1' => [ - 'sections' => '', + 'collections' => '', ], ], ], - ], 'custom.*.sections'); + ], 'custom.*.collections'); $this->assertPartialConfigurationIsInvalid([ [ 'custom' => [ 'custom_1' => [ - 'section_name' => 'blog', + 'collection_name' => 'blog', ], ], ], - ], 'custom.*.sections'); + ], 'custom.*.collections'); } /** diff --git a/tests/Functional/Fixture/PageFixtureTest.php b/tests/Functional/Fixture/PageFixtureTest.php index 01ea7e44a..b17419187 100644 --- a/tests/Functional/Fixture/PageFixtureTest.php +++ b/tests/Functional/Fixture/PageFixtureTest.php @@ -304,47 +304,47 @@ public function custom_remove_existing_is_optional_but_must_be_boolean(): void /** * @test */ - public function custom_sections_is_optional_but_must_be_scalar_array(): void + public function custom_collections_is_optional_but_must_be_scalar_array(): void { $this->assertConfigurationIsValid([ [ 'custom' => [ 'homepage_banner' => [ - 'sections' => ['blog', 'homepage'], + 'collections' => ['blog', 'homepage'], ], ], ], - ], 'custom.*.sections'); + ], 'custom.*.collections'); $this->assertConfigurationIsValid([ [ 'custom' => [ 'homepage_banner' => [ - 'sections' => [], + 'collections' => [], ], ], ], - ], 'custom.*.sections'); + ], 'custom.*.collections'); $this->assertPartialConfigurationIsInvalid([ [ 'custom' => [ 'custom_1' => [ - 'sections' => '', + 'collections' => '', ], ], ], - ], 'custom.*.sections'); + ], 'custom.*.collections'); $this->assertPartialConfigurationIsInvalid([ [ 'custom' => [ 'custom_1' => [ - 'section_name' => 'blog', + 'collection_name' => 'blog', ], ], ], - ], 'custom.*.sections'); + ], 'custom.*.collections'); } /** diff --git a/tests/Functional/Responses/Expected/Api/BlockTest/test_it_get_block_by_id.json b/tests/Functional/Responses/Expected/Api/BlockTest/test_it_get_block_by_id.json index 71e6a0e79..d4442784c 100644 --- a/tests/Functional/Responses/Expected/Api/BlockTest/test_it_get_block_by_id.json +++ b/tests/Functional/Responses/Expected/Api/BlockTest/test_it_get_block_by_id.json @@ -5,12 +5,12 @@ "id": "@integer@", "code": "block1-code", "enabled": true, - "sections": [ + "collections": [ { - "@id": "/api/v2/shop/cms-plugin/sections/@integer@", - "@type": "Section", + "@id": "/api/v2/shop/cms-plugin/collections/@integer@", + "@type": "Collection", "id": "@integer@", - "code": "section1-code" + "code": "collection1-code" } ], "products": [ diff --git a/tests/Functional/Responses/Expected/Api/BlockTest/test_it_get_blocks.json b/tests/Functional/Responses/Expected/Api/BlockTest/test_it_get_blocks.json index 12067ef32..9a8d02cfb 100644 --- a/tests/Functional/Responses/Expected/Api/BlockTest/test_it_get_blocks.json +++ b/tests/Functional/Responses/Expected/Api/BlockTest/test_it_get_blocks.json @@ -9,12 +9,12 @@ "id": "@integer@", "code": "block1-code", "enabled": true, - "sections": [ + "collections": [ { - "@id": "/api/v2/shop/cms-plugin/sections/@integer@", - "@type": "Section", + "@id": "/api/v2/shop/cms-plugin/collections/@integer@", + "@type": "Collection", "id": "@integer@", - "code": "section1-code" + "code": "collection1-code" } ], "products": [ @@ -44,12 +44,12 @@ "id": "@integer@", "code": "block2-code", "enabled": true, - "sections": [ + "collections": [ { - "@id": "/api/v2/shop/cms-plugin/sections/@integer@", - "@type": "Section", + "@id": "/api/v2/shop/cms-plugin/collections/@integer@", + "@type": "Collection", "id": "@integer@", - "code": "section2-code" + "code": "collection2-code" } ], "products": [ @@ -74,12 +74,12 @@ "id": "@integer@", "code": "block3-code", "enabled": false, - "sections": [ + "collections": [ { - "@id": "/api/v2/shop/cms-plugin/sections/@integer@", - "@type": "Section", + "@id": "/api/v2/shop/cms-plugin/collections/@integer@", + "@type": "Collection", "id": "@integer@", - "code": "section3-code" + "code": "collection3-code" } ], "products": [ diff --git a/tests/Functional/Responses/Expected/Api/CollectionTest/test_it_get_collection_by_id.json b/tests/Functional/Responses/Expected/Api/CollectionTest/test_it_get_collection_by_id.json new file mode 100644 index 000000000..314c8ffc6 --- /dev/null +++ b/tests/Functional/Responses/Expected/Api/CollectionTest/test_it_get_collection_by_id.json @@ -0,0 +1,7 @@ +{ + "@context": "/api/v2/contexts/Collection", + "@id": "/api/v2/shop/cms-plugin/collections/@integer@", + "@type": "Collection", + "id": "@integer@", + "code": "collection1-code" +} diff --git a/tests/Functional/Responses/Expected/Api/CollectionTest/test_it_get_collections.json b/tests/Functional/Responses/Expected/Api/CollectionTest/test_it_get_collections.json new file mode 100644 index 000000000..a38ad3827 --- /dev/null +++ b/tests/Functional/Responses/Expected/Api/CollectionTest/test_it_get_collections.json @@ -0,0 +1,26 @@ +{ + "@context": "/api/v2/contexts/Collection", + "@id": "/api/v2/shop/cms-plugin/collections", + "@type": "hydra:Collection", + "hydra:member": [ + { + "@id": "/api/v2/shop/cms-plugin/collections/@integer@", + "@type": "Collection", + "id": "@integer@", + "code": "collection1-code" + }, + { + "@id": "/api/v2/shop/cms-plugin/collections/@integer@", + "@type": "Collection", + "id": "@integer@", + "code": "collection2-code" + }, + { + "@id": "/api/v2/shop/cms-plugin/collections/@integer@", + "@type": "Collection", + "id": "@integer@", + "code": "collection3-code" + } + ], + "hydra:totalItems": 3 +} diff --git a/tests/Functional/Responses/Expected/Api/MediaTest/test_it_get_media.json b/tests/Functional/Responses/Expected/Api/MediaTest/test_it_get_media.json index 59ebcc373..6e651eb70 100644 --- a/tests/Functional/Responses/Expected/Api/MediaTest/test_it_get_media.json +++ b/tests/Functional/Responses/Expected/Api/MediaTest/test_it_get_media.json @@ -15,12 +15,12 @@ "height": null, "saveWithOriginalName": false, "enabled": true, - "sections": [ + "collections": [ { - "@id": "/api/v2/shop/cms-plugin/sections/@integer@", - "@type": "Section", + "@id": "/api/v2/shop/cms-plugin/collections/@integer@", + "@type": "Collection", "id": "@integer@", - "code": "section1-code" + "code": "collection1-code" } ], "products": [ @@ -51,12 +51,12 @@ "height": null, "saveWithOriginalName": false, "enabled": true, - "sections": [ + "collections": [ { - "@id": "/api/v2/shop/cms-plugin/sections/@integer@", - "@type": "Section", + "@id": "/api/v2/shop/cms-plugin/collections/@integer@", + "@type": "Collection", "id": "@integer@", - "code": "section2-code" + "code": "collection2-code" } ], "products": [ @@ -87,12 +87,12 @@ "height": null, "saveWithOriginalName": false, "enabled": false, - "sections": [ + "collections": [ { - "@id": "/api/v2/shop/cms-plugin/sections/@integer@", - "@type": "Section", + "@id": "/api/v2/shop/cms-plugin/collections/@integer@", + "@type": "Collection", "id": "@integer@", - "code": "section3-code" + "code": "collection3-code" } ], "products": [ diff --git a/tests/Functional/Responses/Expected/Api/MediaTest/test_it_get_media_by_id.json b/tests/Functional/Responses/Expected/Api/MediaTest/test_it_get_media_by_id.json index e72cc1fb6..b8c728513 100644 --- a/tests/Functional/Responses/Expected/Api/MediaTest/test_it_get_media_by_id.json +++ b/tests/Functional/Responses/Expected/Api/MediaTest/test_it_get_media_by_id.json @@ -11,12 +11,12 @@ "height": null, "saveWithOriginalName": false, "enabled": true, - "sections": [ + "collections": [ { - "@id": "/api/v2/shop/cms-plugin/sections/@integer@", - "@type": "Section", + "@id": "/api/v2/shop/cms-plugin/collections/@integer@", + "@type": "Collection", "id": "@integer@", - "code": "section1-code" + "code": "collection1-code" } ], "products": [ diff --git a/tests/Functional/Responses/Expected/Api/SectionTest/test_it_get_section_by_id.json b/tests/Functional/Responses/Expected/Api/SectionTest/test_it_get_section_by_id.json deleted file mode 100644 index ea79e6526..000000000 --- a/tests/Functional/Responses/Expected/Api/SectionTest/test_it_get_section_by_id.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "@context": "/api/v2/contexts/Section", - "@id": "/api/v2/shop/cms-plugin/sections/@integer@", - "@type": "Section", - "id": "@integer@", - "code": "section1-code" -} diff --git a/tests/Functional/Responses/Expected/Api/SectionTest/test_it_get_sections.json b/tests/Functional/Responses/Expected/Api/SectionTest/test_it_get_sections.json deleted file mode 100644 index 1e2715f58..000000000 --- a/tests/Functional/Responses/Expected/Api/SectionTest/test_it_get_sections.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "@context": "/api/v2/contexts/Section", - "@id": "/api/v2/shop/cms-plugin/sections", - "@type": "hydra:Collection", - "hydra:member": [ - { - "@id": "/api/v2/shop/cms-plugin/sections/@integer@", - "@type": "Section", - "id": "@integer@", - "code": "section1-code" - }, - { - "@id": "/api/v2/shop/cms-plugin/sections/@integer@", - "@type": "Section", - "id": "@integer@", - "code": "section2-code" - }, - { - "@id": "/api/v2/shop/cms-plugin/sections/@integer@", - "@type": "Section", - "id": "@integer@", - "code": "section3-code" - } - ], - "hydra:totalItems": 3 -} diff --git a/tests/Integration/DataFixtures/ORM/BlockRepositoryTest/test_it_finds_block_by_section_code.yml b/tests/Integration/DataFixtures/ORM/BlockRepositoryTest/test_it_finds_block_by_collection_code.yml similarity index 82% rename from tests/Integration/DataFixtures/ORM/BlockRepositoryTest/test_it_finds_block_by_section_code.yml rename to tests/Integration/DataFixtures/ORM/BlockRepositoryTest/test_it_finds_block_by_collection_code.yml index e752e060b..61f111d7f 100644 --- a/tests/Integration/DataFixtures/ORM/BlockRepositoryTest/test_it_finds_block_by_section_code.yml +++ b/tests/Integration/DataFixtures/ORM/BlockRepositoryTest/test_it_finds_block_by_collection_code.yml @@ -37,8 +37,8 @@ BitBag\SyliusCmsPlugin\Entity\Block: block1: code: 'block1-code' enabled: true - sections: - - '@section1' + collections: + - '@collection1' channels: - '@channel' translations: @@ -46,8 +46,8 @@ BitBag\SyliusCmsPlugin\Entity\Block: block2: code: 'block2-code' enabled: true - sections: - - '@section2' + collections: + - '@collection2' channels: - '@channel' translations: @@ -55,17 +55,17 @@ BitBag\SyliusCmsPlugin\Entity\Block: block3: code: 'block3-code' enabled: false - sections: - - '@section3' + collections: + - '@collection3' channels: - '@channel' translations: - '@block3_translation' -BitBag\SyliusCmsPlugin\Entity\Section: - section1: - code: 'section1-code' - section2: - code: 'section2-code' - section3: - code: 'section3-code' +BitBag\SyliusCmsPlugin\Entity\Collection: + collection1: + code: 'collection1-code' + collection2: + code: 'collection2-code' + collection3: + code: 'collection3-code' diff --git a/tests/Integration/DataFixtures/ORM/BlockRepositoryTest/test_it_finds_block_by_product_code.yml b/tests/Integration/DataFixtures/ORM/BlockRepositoryTest/test_it_finds_block_by_product_code.yml index 547e3ae7d..b59eb71e9 100644 --- a/tests/Integration/DataFixtures/ORM/BlockRepositoryTest/test_it_finds_block_by_product_code.yml +++ b/tests/Integration/DataFixtures/ORM/BlockRepositoryTest/test_it_finds_block_by_product_code.yml @@ -94,8 +94,8 @@ BitBag\SyliusCmsPlugin\Entity\Block: enabled: true products: - '@product1' - sections: - - '@section1' + collections: + - '@collection1' channels: - '@channel' translations: @@ -105,8 +105,8 @@ BitBag\SyliusCmsPlugin\Entity\Block: enabled: true products: - '@product2' - sections: - - '@section2' + collections: + - '@collection2' channels: - '@channel' translations: @@ -116,17 +116,17 @@ BitBag\SyliusCmsPlugin\Entity\Block: enabled: false products: - '@product3' - sections: - - '@section3' + collections: + - '@collection3' channels: - '@channel' translations: - '@block3_translation' -BitBag\SyliusCmsPlugin\Entity\Section: - section1: - code: 'section1-code' - section2: - code: 'section2-code' - section3: - code: 'section3-code' +BitBag\SyliusCmsPlugin\Entity\Collection: + collection1: + code: 'collection1-code' + collection2: + code: 'collection2-code' + collection3: + code: 'collection3-code' diff --git a/tests/Functional/DataFixtures/ORM/Api/SectionTest/section.yml b/tests/Integration/DataFixtures/ORM/CollectionRepositoryTest/test_it_finds_collection_by_code.yml similarity index 62% rename from tests/Functional/DataFixtures/ORM/Api/SectionTest/section.yml rename to tests/Integration/DataFixtures/ORM/CollectionRepositoryTest/test_it_finds_collection_by_code.yml index de388d554..1f2c81aa4 100644 --- a/tests/Functional/DataFixtures/ORM/Api/SectionTest/section.yml +++ b/tests/Integration/DataFixtures/ORM/CollectionRepositoryTest/test_it_finds_collection_by_code.yml @@ -17,26 +17,26 @@ Sylius\Component\Core\Model\Channel: default_locale: '@locale' tax_calculation_strategy: 'order_items_based' base_currency: '@dollar' -BitBag\SyliusCmsPlugin\Entity\SectionTranslation: - section1_translation: +BitBag\SyliusCmsPlugin\Entity\CollectionTranslation: + collection1_translation: name: 'translation1_name_en_US' locale: 'en_US' - section2_translation: + collection2_translation: name: 'translation2_name_en_US' locale: 'en_US' - section3_translation: + collection3_translation: name: 'translation3_name_en_US' locale: 'en_US' -BitBag\SyliusCmsPlugin\Entity\Section: - section1: - code: 'section1-code' +BitBag\SyliusCmsPlugin\Entity\Collection: + collection1: + code: 'collection1-code' translations: - - '@section1_translation' - section2: - code: 'section2-code' + - '@collection1_translation' + collection2: + code: 'collection2-code' translations: - - '@section2_translation' - section3: - code: 'section3-code' + - '@collection2_translation' + collection3: + code: 'collection3-code' translations: - - '@section3_translation' + - '@collection3_translation' diff --git a/tests/Integration/DataFixtures/ORM/SectionRepositoryTest/test_it_finds_section_by_codes_and_locale.yml b/tests/Integration/DataFixtures/ORM/CollectionRepositoryTest/test_it_finds_collection_by_codes_and_locale.yml similarity index 62% rename from tests/Integration/DataFixtures/ORM/SectionRepositoryTest/test_it_finds_section_by_codes_and_locale.yml rename to tests/Integration/DataFixtures/ORM/CollectionRepositoryTest/test_it_finds_collection_by_codes_and_locale.yml index de388d554..1f2c81aa4 100644 --- a/tests/Integration/DataFixtures/ORM/SectionRepositoryTest/test_it_finds_section_by_codes_and_locale.yml +++ b/tests/Integration/DataFixtures/ORM/CollectionRepositoryTest/test_it_finds_collection_by_codes_and_locale.yml @@ -17,26 +17,26 @@ Sylius\Component\Core\Model\Channel: default_locale: '@locale' tax_calculation_strategy: 'order_items_based' base_currency: '@dollar' -BitBag\SyliusCmsPlugin\Entity\SectionTranslation: - section1_translation: +BitBag\SyliusCmsPlugin\Entity\CollectionTranslation: + collection1_translation: name: 'translation1_name_en_US' locale: 'en_US' - section2_translation: + collection2_translation: name: 'translation2_name_en_US' locale: 'en_US' - section3_translation: + collection3_translation: name: 'translation3_name_en_US' locale: 'en_US' -BitBag\SyliusCmsPlugin\Entity\Section: - section1: - code: 'section1-code' +BitBag\SyliusCmsPlugin\Entity\Collection: + collection1: + code: 'collection1-code' translations: - - '@section1_translation' - section2: - code: 'section2-code' + - '@collection1_translation' + collection2: + code: 'collection2-code' translations: - - '@section2_translation' - section3: - code: 'section3-code' + - '@collection2_translation' + collection3: + code: 'collection3-code' translations: - - '@section3_translation' + - '@collection3_translation' diff --git a/tests/Integration/DataFixtures/ORM/SectionRepositoryTest/test_it_finds_section_by_code.yml b/tests/Integration/DataFixtures/ORM/CollectionRepositoryTest/test_it_finds_collection_by_name.yml similarity index 62% rename from tests/Integration/DataFixtures/ORM/SectionRepositoryTest/test_it_finds_section_by_code.yml rename to tests/Integration/DataFixtures/ORM/CollectionRepositoryTest/test_it_finds_collection_by_name.yml index de388d554..1f2c81aa4 100644 --- a/tests/Integration/DataFixtures/ORM/SectionRepositoryTest/test_it_finds_section_by_code.yml +++ b/tests/Integration/DataFixtures/ORM/CollectionRepositoryTest/test_it_finds_collection_by_name.yml @@ -17,26 +17,26 @@ Sylius\Component\Core\Model\Channel: default_locale: '@locale' tax_calculation_strategy: 'order_items_based' base_currency: '@dollar' -BitBag\SyliusCmsPlugin\Entity\SectionTranslation: - section1_translation: +BitBag\SyliusCmsPlugin\Entity\CollectionTranslation: + collection1_translation: name: 'translation1_name_en_US' locale: 'en_US' - section2_translation: + collection2_translation: name: 'translation2_name_en_US' locale: 'en_US' - section3_translation: + collection3_translation: name: 'translation3_name_en_US' locale: 'en_US' -BitBag\SyliusCmsPlugin\Entity\Section: - section1: - code: 'section1-code' +BitBag\SyliusCmsPlugin\Entity\Collection: + collection1: + code: 'collection1-code' translations: - - '@section1_translation' - section2: - code: 'section2-code' + - '@collection1_translation' + collection2: + code: 'collection2-code' translations: - - '@section2_translation' - section3: - code: 'section3-code' + - '@collection2_translation' + collection3: + code: 'collection3-code' translations: - - '@section3_translation' + - '@collection3_translation' diff --git a/tests/Integration/DataFixtures/ORM/MediaRepositoryTest/test_it_finds_media_by_section_code.yml b/tests/Integration/DataFixtures/ORM/MediaRepositoryTest/test_it_finds_media_by_collection_code.yml similarity index 84% rename from tests/Integration/DataFixtures/ORM/MediaRepositoryTest/test_it_finds_media_by_section_code.yml rename to tests/Integration/DataFixtures/ORM/MediaRepositoryTest/test_it_finds_media_by_collection_code.yml index b8b199975..d8a267654 100644 --- a/tests/Integration/DataFixtures/ORM/MediaRepositoryTest/test_it_finds_media_by_section_code.yml +++ b/tests/Integration/DataFixtures/ORM/MediaRepositoryTest/test_it_finds_media_by_collection_code.yml @@ -39,8 +39,8 @@ BitBag\SyliusCmsPlugin\Entity\Media: enabled: true type: 'image' path: '/path/to/media1' - sections: - - '@section1' + collections: + - '@collection1' channels: - '@channel' translations: @@ -50,8 +50,8 @@ BitBag\SyliusCmsPlugin\Entity\Media: enabled: true type: 'image' path: '/path/to/media2' - sections: - - '@section2' + collections: + - '@collection2' channels: - '@channel' translations: @@ -61,17 +61,17 @@ BitBag\SyliusCmsPlugin\Entity\Media: enabled: false type: 'image' path: '/path/to/media3' - sections: - - '@section3' + collections: + - '@collection3' channels: - '@channel' translations: - '@media3_translation' -BitBag\SyliusCmsPlugin\Entity\Section: - section1: - code: 'section1-code' - section2: - code: 'section2-code' - section3: - code: 'section3-code' +BitBag\SyliusCmsPlugin\Entity\Collection: + collection1: + code: 'collection1-code' + collection2: + code: 'collection2-code' + collection3: + code: 'collection3-code' diff --git a/tests/Integration/DataFixtures/ORM/MediaRepositoryTest/test_it_finds_media_by_product_code.yml b/tests/Integration/DataFixtures/ORM/MediaRepositoryTest/test_it_finds_media_by_product_code.yml index 119becddf..7c6fcadf7 100644 --- a/tests/Integration/DataFixtures/ORM/MediaRepositoryTest/test_it_finds_media_by_product_code.yml +++ b/tests/Integration/DataFixtures/ORM/MediaRepositoryTest/test_it_finds_media_by_product_code.yml @@ -96,8 +96,8 @@ BitBag\SyliusCmsPlugin\Entity\Media: path: '/path/to/media1' products: - '@product1' - sections: - - '@section1' + collections: + - '@collection1' channels: - '@channel' translations: @@ -109,8 +109,8 @@ BitBag\SyliusCmsPlugin\Entity\Media: path: '/path/to/media2' products: - '@product2' - sections: - - '@section2' + collections: + - '@collection2' channels: - '@channel' translations: @@ -122,17 +122,17 @@ BitBag\SyliusCmsPlugin\Entity\Media: path: '/path/to/media3' products: - '@product3' - sections: - - '@section3' + collections: + - '@collection3' channels: - '@channel' translations: - '@media3_translation' -BitBag\SyliusCmsPlugin\Entity\Section: - section1: - code: 'section1-code' - section2: - code: 'section2-code' - section3: - code: 'section3-code' +BitBag\SyliusCmsPlugin\Entity\Collection: + collection1: + code: 'collection1-code' + collection2: + code: 'collection2-code' + collection3: + code: 'collection3-code' diff --git a/tests/Integration/DataFixtures/ORM/PageRepositoryTest/test_it_finds_page_by_section_code.yml b/tests/Integration/DataFixtures/ORM/PageRepositoryTest/test_it_finds_page_by_collection_code.yml similarity index 81% rename from tests/Integration/DataFixtures/ORM/PageRepositoryTest/test_it_finds_page_by_section_code.yml rename to tests/Integration/DataFixtures/ORM/PageRepositoryTest/test_it_finds_page_by_collection_code.yml index 41d253e76..19d8d3eec 100644 --- a/tests/Integration/DataFixtures/ORM/PageRepositoryTest/test_it_finds_page_by_section_code.yml +++ b/tests/Integration/DataFixtures/ORM/PageRepositoryTest/test_it_finds_page_by_collection_code.yml @@ -34,8 +34,8 @@ BitBag\SyliusCmsPlugin\Entity\Page: page1: code: 'page1-code' enabled: true - sections: - - '@section1' + collections: + - '@collection1' channels: - '@channel' translations: @@ -43,8 +43,8 @@ BitBag\SyliusCmsPlugin\Entity\Page: page2: code: 'page2-code' enabled: true - sections: - - '@section2' + collections: + - '@collection2' channels: - '@channel' translations: @@ -52,17 +52,17 @@ BitBag\SyliusCmsPlugin\Entity\Page: page3: code: 'page3-code' enabled: false - sections: - - '@section3' + collections: + - '@collection3' channels: - '@channel' translations: - '@page3_translation' -BitBag\SyliusCmsPlugin\Entity\Section: - section1: - code: 'section1-code' - section2: - code: 'section2-code' - section3: - code: 'section3-code' +BitBag\SyliusCmsPlugin\Entity\Collection: + collection1: + code: 'collection1-code' + collection2: + code: 'collection2-code' + collection3: + code: 'collection3-code' diff --git a/tests/Integration/DataFixtures/ORM/PageRepositoryTest/test_it_finds_page_by_product_and_section_code.yml b/tests/Integration/DataFixtures/ORM/PageRepositoryTest/test_it_finds_page_by_product_and_collection_code.yml similarity index 90% rename from tests/Integration/DataFixtures/ORM/PageRepositoryTest/test_it_finds_page_by_product_and_section_code.yml rename to tests/Integration/DataFixtures/ORM/PageRepositoryTest/test_it_finds_page_by_product_and_collection_code.yml index d535b07bc..f3013f937 100644 --- a/tests/Integration/DataFixtures/ORM/PageRepositoryTest/test_it_finds_page_by_product_and_section_code.yml +++ b/tests/Integration/DataFixtures/ORM/PageRepositoryTest/test_it_finds_page_by_product_and_collection_code.yml @@ -91,8 +91,8 @@ BitBag\SyliusCmsPlugin\Entity\Page: enabled: true products: - '@product1' - sections: - - '@section1' + collections: + - '@collection1' channels: - '@channel' translations: @@ -102,8 +102,8 @@ BitBag\SyliusCmsPlugin\Entity\Page: enabled: true products: - '@product2' - sections: - - '@section2' + collections: + - '@collection2' channels: - '@channel' translations: @@ -113,17 +113,17 @@ BitBag\SyliusCmsPlugin\Entity\Page: enabled: false products: - '@product3' - sections: - - '@section3' + collections: + - '@collection3' channels: - '@channel' translations: - '@page3_translation' -BitBag\SyliusCmsPlugin\Entity\Section: - section1: - code: 'section1-code' - section2: - code: 'section2-code' - section3: - code: 'section3-code' +BitBag\SyliusCmsPlugin\Entity\Collection: + collection1: + code: 'collection1-code' + collection2: + code: 'collection2-code' + collection3: + code: 'collection3-code' diff --git a/tests/Integration/Repository/BlockRepositoryTest.php b/tests/Integration/Repository/BlockRepositoryTest.php index b91e15cd2..f9bd8084a 100644 --- a/tests/Integration/Repository/BlockRepositoryTest.php +++ b/tests/Integration/Repository/BlockRepositoryTest.php @@ -35,14 +35,14 @@ public function test_it_finds_enabled_block_by_code(): void self::assertNull($block3); } - public function test_it_finds_enabled_block_by_section_code(): void + public function test_it_finds_enabled_block_by_collection_code(): void { - $this->loadFixturesFromFile('BlockRepositoryTest/test_it_finds_block_by_section_code.yml'); + $this->loadFixturesFromFile('BlockRepositoryTest/test_it_finds_block_by_collection_code.yml'); $blockRepository = $this->getRepository(); - $block_array1 = $blockRepository->findByCollectionCode('section1-code', 'en_US', 'code'); - $block_array3 = $blockRepository->findByCollectionCode('section3-code', 'en_US', 'code'); + $block_array1 = $blockRepository->findByCollectionCode('collection1-code', 'en_US', 'code'); + $block_array3 = $blockRepository->findByCollectionCode('collection3-code', 'en_US', 'code'); self::assertNotEmpty($block_array1); self::assertEmpty($block_array3); diff --git a/tests/Integration/Repository/SectionRepositoryTest.php b/tests/Integration/Repository/CollectionRepositoryTest.php similarity index 62% rename from tests/Integration/Repository/SectionRepositoryTest.php rename to tests/Integration/Repository/CollectionRepositoryTest.php index 247f4ff7f..749c0b486 100644 --- a/tests/Integration/Repository/SectionRepositoryTest.php +++ b/tests/Integration/Repository/CollectionRepositoryTest.php @@ -16,7 +16,7 @@ use BitBag\SyliusCmsPlugin\Repository\CollectionRepositoryInterface; use Doctrine\ORM\QueryBuilder; -class SectionRepositoryTest extends JsonApiTestCase +class CollectionRepositoryTest extends JsonApiTestCase { public function setUp(): void { @@ -34,45 +34,45 @@ public function test_it_creates_list_query_builder(): void self::assertNotNull($queryBuilder->getQuery()); } - public function test_it_finds_section_by_name_part(): void + public function test_it_finds_collection_by_name_part(): void { - $this->loadFixturesFromFile('SectionRepositoryTest/test_it_finds_section_by_name.yml'); + $this->loadFixturesFromFile('CollectionRepositoryTest/test_it_finds_collection_by_name.yml'); $repository = $this->getRepository(); $phrase = 'translation'; $locale = 'en_US'; - $sections = $repository->findByNamePart($phrase, $locale); + $collections = $repository->findByNamePart($phrase, $locale); - self::assertIsArray($sections); - self::assertCount(3, $sections); + self::assertIsArray($collections); + self::assertCount(3, $collections); } public function test_it_finds_one_by_code(): void { - $this->loadFixturesFromFile('SectionRepositoryTest/test_it_finds_section_by_code.yml'); + $this->loadFixturesFromFile('CollectionRepositoryTest/test_it_finds_collection_by_code.yml'); $repository = $this->getRepository(); - $code = 'section1-code'; + $code = 'collection1-code'; $localeCode = 'en_US'; - $section = $repository->findOneByCode($code, $localeCode); + $collection = $repository->findOneByCode($code, $localeCode); - self::assertInstanceOf(CollectionInterface::class, $section); + self::assertInstanceOf(CollectionInterface::class, $collection); } public function test_it_finds_by_codes_and_locale(): void { - $this->loadFixturesFromFile('SectionRepositoryTest/test_it_finds_section_by_codes_and_locale.yml'); + $this->loadFixturesFromFile('CollectionRepositoryTest/test_it_finds_collection_by_codes_and_locale.yml'); $repository = $this->getRepository(); - $codes = 'section1-code,section2-code'; + $codes = 'collection1-code,collection2-code'; $localeCode = 'en_US'; - $sections = $repository->findByCodesAndLocale($codes, $localeCode); + $collections = $repository->findByCodesAndLocale($codes, $localeCode); - self::assertIsArray($sections); - self::assertCount(2, $sections); + self::assertIsArray($collections); + self::assertCount(2, $collections); } private function getRepository(): CollectionRepositoryInterface diff --git a/tests/Integration/Repository/MediaRepositoryTest.php b/tests/Integration/Repository/MediaRepositoryTest.php index d5092c4d6..e2cd565bb 100644 --- a/tests/Integration/Repository/MediaRepositoryTest.php +++ b/tests/Integration/Repository/MediaRepositoryTest.php @@ -35,14 +35,14 @@ public function test_it_finds_enabled_media_by_code(): void self::assertNull($media3); } - public function test_it_finds_enabled_media_by_section_code(): void + public function test_it_finds_enabled_media_by_collection_code(): void { - $this->loadFixturesFromFile('MediaRepositoryTest/test_it_finds_media_by_section_code.yml'); + $this->loadFixturesFromFile('MediaRepositoryTest/test_it_finds_media_by_collection_code.yml'); $mediaRepository = $this->getRepository(); - $media1 = $mediaRepository->findByCollectionCode('section1-code', 'en_US', 'code'); - $media3 = $mediaRepository->findByCollectionCode('section3-code', 'en_US', 'code'); + $media1 = $mediaRepository->findByCollectionCode('collection1-code', 'en_US', 'code'); + $media3 = $mediaRepository->findByCollectionCode('collection3-code', 'en_US', 'code'); self::assertNotEmpty($media1); self::assertEmpty($media3); diff --git a/tests/Integration/Repository/PageRepositoryTest.php b/tests/Integration/Repository/PageRepositoryTest.php index 9e2f285e8..82f71dbd1 100644 --- a/tests/Integration/Repository/PageRepositoryTest.php +++ b/tests/Integration/Repository/PageRepositoryTest.php @@ -50,14 +50,14 @@ public function test_it_finds_enabled_page_by_code(): void self::assertNull($page3); } - public function test_it_finds_enabled_page_by_section_code(): void + public function test_it_finds_enabled_page_by_collection_code(): void { - $this->loadFixturesFromFile('PageRepositoryTest/test_it_finds_page_by_section_code.yml'); + $this->loadFixturesFromFile('PageRepositoryTest/test_it_finds_page_by_collection_code.yml'); $pageRepository = $this->getRepository(); - $page1_array = $pageRepository->findByCollectionCode('section1-code', 'en_US'); - $page3_array = $pageRepository->findByCollectionCode('section3-code', 'en_US'); + $page1_array = $pageRepository->findByCollectionCode('collection1-code', 'en_US'); + $page3_array = $pageRepository->findByCollectionCode('collection3-code', 'en_US'); self::assertNotEmpty($page1_array); self::assertEmpty($page3_array); @@ -84,9 +84,9 @@ public function test_it_finds_enabled_page_by_product(): void self::assertEmpty($page3_array); } - public function test_it_finds_enabled_page_by_product_and_section_code(): void + public function test_it_finds_enabled_page_by_product_and_collection_code(): void { - $this->loadFixturesFromFile('PageRepositoryTest/test_it_finds_page_by_product_and_section_code.yml'); + $this->loadFixturesFromFile('PageRepositoryTest/test_it_finds_page_by_product_and_collection_code.yml'); $pageRepository = $this->getRepository(); @@ -98,8 +98,8 @@ public function test_it_finds_enabled_page_by_product_and_section_code(): void /** @var Product $product3 */ $product3 = $productRepository->findOneByCode('MUG_SW3'); - $page1_array = $pageRepository->findByProductAndCollectionCode($product1, 'section1-code', 'code', null); - $page3_array = $pageRepository->findByProductAndCollectionCode($product3, 'section3-code', 'code', null); + $page1_array = $pageRepository->findByProductAndCollectionCode($product1, 'collection1-code', 'code', null); + $page3_array = $pageRepository->findByProductAndCollectionCode($product3, 'collection3-code', 'code', null); self::assertNotEmpty($page1_array); self::assertEmpty($page3_array); From 15fd74e7c8cbb534ab78c491c722cfc12d160ad6 Mon Sep 17 00:00:00 2001 From: jkindly Date: Wed, 19 Jun 2024 11:52:39 +0200 Subject: [PATCH 10/25] OP-320: PHPStan fixes --- src/Entity/BlockableTrait.php | 3 +-- src/Entity/CollectionableTrait.php | 3 +-- src/Entity/MediableTrait.php | 3 +-- src/Entity/PageableTrait.php | 3 +-- 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/Entity/BlockableTrait.php b/src/Entity/BlockableTrait.php index aca59f73c..d74cc55eb 100644 --- a/src/Entity/BlockableTrait.php +++ b/src/Entity/BlockableTrait.php @@ -15,8 +15,7 @@ trait BlockableTrait { - /** @var Collection|BlockInterface[] */ - protected Collection|array $blocks; + protected Collection $blocks; public function initializeBlocksCollection(): void { diff --git a/src/Entity/CollectionableTrait.php b/src/Entity/CollectionableTrait.php index 6bfc8fda5..0e4f7c0e4 100755 --- a/src/Entity/CollectionableTrait.php +++ b/src/Entity/CollectionableTrait.php @@ -15,8 +15,7 @@ trait CollectionableTrait { - /** @var Collection|CollectionInterface[] */ - protected Collection|array $collections; + protected Collection $collections; public function initializeCollectionsCollection(): void { diff --git a/src/Entity/MediableTrait.php b/src/Entity/MediableTrait.php index 245c71e93..92c311cee 100644 --- a/src/Entity/MediableTrait.php +++ b/src/Entity/MediableTrait.php @@ -15,8 +15,7 @@ trait MediableTrait { - /** @var Collection|MediaInterface[] */ - protected Collection|array $media; + protected Collection $media; public function initializeMediaCollection(): void { diff --git a/src/Entity/PageableTrait.php b/src/Entity/PageableTrait.php index e2e7db38b..67abcdc0a 100644 --- a/src/Entity/PageableTrait.php +++ b/src/Entity/PageableTrait.php @@ -15,8 +15,7 @@ trait PageableTrait { - /** @var Collection|PageInterface[] */ - protected Collection|array $pages; + protected Collection $pages; public function initializePagesCollection(): void { From 0d20807e2f7864797104ee564c10aefe2d83a819 Mon Sep 17 00:00:00 2001 From: jkindly Date: Wed, 19 Jun 2024 12:21:13 +0200 Subject: [PATCH 11/25] OP-320: ECS fixes --- src/Fixture/Factory/BlockFixtureFactory.php | 20 +++++++++---------- .../Factory/CollectionFixtureFactory.php | 4 ++-- src/Fixture/Factory/MediaFixtureFactory.php | 14 ++++++------- src/Fixture/Factory/PageFixtureFactory.php | 20 +++++++++---------- src/Form/Type/CollectionType.php | 3 +++ src/Importer/BlockImporter.php | 14 ++++++------- src/Importer/MediaImporter.php | 12 +++++------ src/Importer/PageImporter.php | 20 +++++++++---------- src/Repository/PageRepository.php | 6 +++--- src/Repository/PageRepositoryInterface.php | 6 +++--- .../Runtime/RenderProductPagesRuntime.php | 6 +++--- .../Behat/Context/Setup/CollectionContext.php | 6 +++--- tests/Behat/Context/Setup/PageContext.php | 16 +++++++-------- .../Context/Transform/CollectionContext.php | 2 +- .../Fixture/CollectionFixtureTest.php | 2 +- 15 files changed, 77 insertions(+), 74 deletions(-) diff --git a/src/Fixture/Factory/BlockFixtureFactory.php b/src/Fixture/Factory/BlockFixtureFactory.php index 9506f18e5..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\ProductsAssignerInterface; use BitBag\SyliusCmsPlugin\Assigner\CollectionsAssignerInterface; +use BitBag\SyliusCmsPlugin\Assigner\ProductsAssignerInterface; use BitBag\SyliusCmsPlugin\Assigner\TaxonsAssignerInterface; use BitBag\SyliusCmsPlugin\Entity\BlockInterface; use BitBag\SyliusCmsPlugin\Entity\BlockTranslationInterface; @@ -26,16 +26,16 @@ final class BlockFixtureFactory implements FixtureFactoryInterface { public function __construct( - private FactoryInterface $blockFactory, - private FactoryInterface $blockTranslationFactory, - private BlockRepositoryInterface $blockRepository, - private ProductRepositoryInterface $productRepository, - private ChannelContextInterface $channelContext, - private LocaleContextInterface $localeContext, - private ProductsAssignerInterface $productsAssigner, - private TaxonsAssignerInterface $taxonsAssigner, + private FactoryInterface $blockFactory, + private FactoryInterface $blockTranslationFactory, + private BlockRepositoryInterface $blockRepository, + private ProductRepositoryInterface $productRepository, + private ChannelContextInterface $channelContext, + private LocaleContextInterface $localeContext, + private ProductsAssignerInterface $productsAssigner, + private TaxonsAssignerInterface $taxonsAssigner, private CollectionsAssignerInterface $collectionsAssigner, - private ChannelsAssignerInterface $channelAssigner, + private ChannelsAssignerInterface $channelAssigner, ) { } diff --git a/src/Fixture/Factory/CollectionFixtureFactory.php b/src/Fixture/Factory/CollectionFixtureFactory.php index f5f7ce2bc..1155ed7b6 100755 --- a/src/Fixture/Factory/CollectionFixtureFactory.php +++ b/src/Fixture/Factory/CollectionFixtureFactory.php @@ -18,8 +18,8 @@ final class CollectionFixtureFactory implements FixtureFactoryInterface { public function __construct( - private FactoryInterface $collectionFactory, - private FactoryInterface $collectionTranslationFactory, + private FactoryInterface $collectionFactory, + private FactoryInterface $collectionTranslationFactory, private CollectionRepositoryInterface $collectionRepository, ) { } diff --git a/src/Fixture/Factory/MediaFixtureFactory.php b/src/Fixture/Factory/MediaFixtureFactory.php index f25953964..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\ProductsAssignerInterface; use BitBag\SyliusCmsPlugin\Assigner\CollectionsAssignerInterface; +use BitBag\SyliusCmsPlugin\Assigner\ProductsAssignerInterface; use BitBag\SyliusCmsPlugin\Entity\MediaInterface; use BitBag\SyliusCmsPlugin\Entity\MediaTranslationInterface; use BitBag\SyliusCmsPlugin\Repository\MediaRepositoryInterface; @@ -23,13 +23,13 @@ final class MediaFixtureFactory implements FixtureFactoryInterface { public function __construct( - private FactoryInterface $mediaFactory, - private FactoryInterface $mediaTranslationFactory, + private FactoryInterface $mediaFactory, + private FactoryInterface $mediaTranslationFactory, private MediaProviderResolverInterface $mediaProviderResolver, - private MediaRepositoryInterface $mediaRepository, - private ProductsAssignerInterface $productsAssigner, - private CollectionsAssignerInterface $collectionsAssigner, - private ChannelsAssignerInterface $channelAssigner, + private MediaRepositoryInterface $mediaRepository, + private ProductsAssignerInterface $productsAssigner, + private CollectionsAssignerInterface $collectionsAssigner, + private ChannelsAssignerInterface $channelAssigner, ) { } diff --git a/src/Fixture/Factory/PageFixtureFactory.php b/src/Fixture/Factory/PageFixtureFactory.php index 85db20720..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\ProductsAssignerInterface; use BitBag\SyliusCmsPlugin\Assigner\CollectionsAssignerInterface; +use BitBag\SyliusCmsPlugin\Assigner\ProductsAssignerInterface; use BitBag\SyliusCmsPlugin\Entity\Media; use BitBag\SyliusCmsPlugin\Entity\MediaInterface; use BitBag\SyliusCmsPlugin\Entity\PageInterface; @@ -32,16 +32,16 @@ final class PageFixtureFactory implements FixtureFactoryInterface public const CHANNEL_WITH_CODE_NOT_FOUND_MESSAGE = 'Channel with code "%s" not found'; public function __construct( - private FactoryInterface $pageFactory, - private FactoryInterface $pageTranslationFactory, - private PageRepositoryInterface $pageRepository, + private FactoryInterface $pageFactory, + private FactoryInterface $pageTranslationFactory, + private PageRepositoryInterface $pageRepository, private MediaProviderResolverInterface $mediaProviderResolver, - private ProductsAssignerInterface $productsAssigner, - private CollectionsAssignerInterface $collectionsAssigner, - private ChannelsAssignerInterface $channelAssigner, - private ProductRepositoryInterface $productRepository, - private LocaleContextInterface $localeContext, - private ChannelRepositoryInterface $channelRepository, + private ProductsAssignerInterface $productsAssigner, + private CollectionsAssignerInterface $collectionsAssigner, + private ChannelsAssignerInterface $channelAssigner, + private ProductRepositoryInterface $productRepository, + private LocaleContextInterface $localeContext, + private ChannelRepositoryInterface $channelRepository, ) { } diff --git a/src/Form/Type/CollectionType.php b/src/Form/Type/CollectionType.php index 92ab25c87..c4c2854ec 100755 --- a/src/Form/Type/CollectionType.php +++ b/src/Form/Type/CollectionType.php @@ -64,12 +64,15 @@ public function buildForm(FormBuilderInterface $builder, array $options): void 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; } diff --git a/src/Importer/BlockImporter.php b/src/Importer/BlockImporter.php index 8b4a96d0a..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\ImporterProductsResolverInterface; use BitBag\SyliusCmsPlugin\Resolver\ImporterCollectionsResolverInterface; +use BitBag\SyliusCmsPlugin\Resolver\ImporterProductsResolverInterface; use BitBag\SyliusCmsPlugin\Resolver\ResourceResolverInterface; use Sylius\Component\Locale\Context\LocaleContextInterface; use Symfony\Component\Validator\Validator\ValidatorInterface; @@ -23,13 +23,13 @@ final class BlockImporter extends AbstractImporter implements BlockImporterInterface { public function __construct( - private ResourceResolverInterface $blockResourceResolver, - private LocaleContextInterface $localeContext, + private ResourceResolverInterface $blockResourceResolver, + private LocaleContextInterface $localeContext, private ImporterCollectionsResolverInterface $importerCollectionsResolver, - private ImporterChannelsResolverInterface $importerChannelsResolver, - private ImporterProductsResolverInterface $importerProductsResolver, - ValidatorInterface $validator, - private BlockRepositoryInterface $blockRepository, + private ImporterChannelsResolverInterface $importerChannelsResolver, + private ImporterProductsResolverInterface $importerProductsResolver, + ValidatorInterface $validator, + private BlockRepositoryInterface $blockRepository, ) { parent::__construct($validator); } diff --git a/src/Importer/MediaImporter.php b/src/Importer/MediaImporter.php index b1703a1eb..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\ImporterProductsResolverInterface; use BitBag\SyliusCmsPlugin\Resolver\ImporterCollectionsResolverInterface; +use BitBag\SyliusCmsPlugin\Resolver\ImporterProductsResolverInterface; use BitBag\SyliusCmsPlugin\Resolver\ResourceResolverInterface; use Sylius\Component\Locale\Context\LocaleContextInterface; use Symfony\Component\Validator\Validator\ValidatorInterface; @@ -22,12 +22,12 @@ final class MediaImporter extends AbstractImporter implements MediaImporterInterface { public function __construct( - private ResourceResolverInterface $mediaResourceResolver, - private LocaleContextInterface $localeContext, + private ResourceResolverInterface $mediaResourceResolver, + private LocaleContextInterface $localeContext, private ImporterCollectionsResolverInterface $importerCollectionsResolver, - private ImporterProductsResolverInterface $importerProductsResolver, - ValidatorInterface $validator, - private MediaRepositoryInterface $mediaRepository, + private ImporterProductsResolverInterface $importerProductsResolver, + ValidatorInterface $validator, + private MediaRepositoryInterface $mediaRepository, ) { parent::__construct($validator); } diff --git a/src/Importer/PageImporter.php b/src/Importer/PageImporter.php index 0209f729f..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\ImporterProductsResolverInterface; use BitBag\SyliusCmsPlugin\Resolver\ImporterCollectionsResolverInterface; +use BitBag\SyliusCmsPlugin\Resolver\ImporterProductsResolverInterface; use BitBag\SyliusCmsPlugin\Resolver\MediaProviderResolverInterface; use BitBag\SyliusCmsPlugin\Resolver\ResourceResolverInterface; use Doctrine\ORM\EntityManagerInterface; @@ -29,16 +29,16 @@ final class PageImporter extends AbstractImporter implements PageImporterInterface { public function __construct( - private ResourceResolverInterface $pageResourceResolver, - private LocaleContextInterface $localeContext, - private ImageDownloaderInterface $imageDownloader, - private FactoryInterface $mediaFactory, - private MediaProviderResolverInterface $mediaProviderResolver, + private ResourceResolverInterface $pageResourceResolver, + private LocaleContextInterface $localeContext, + private ImageDownloaderInterface $imageDownloader, + private FactoryInterface $mediaFactory, + private MediaProviderResolverInterface $mediaProviderResolver, private ImporterCollectionsResolverInterface $importerCollectionsResolver, - private ImporterChannelsResolverInterface $importerChannelsResolver, - private ImporterProductsResolverInterface $importerProductsResolver, - ValidatorInterface $validator, - private EntityManagerInterface $entityManager, + private ImporterChannelsResolverInterface $importerChannelsResolver, + private ImporterProductsResolverInterface $importerProductsResolver, + ValidatorInterface $validator, + private EntityManagerInterface $entityManager, ) { parent::__construct($validator); } diff --git a/src/Repository/PageRepository.php b/src/Repository/PageRepository.php index 04a40d531..72e449e80 100755 --- a/src/Repository/PageRepository.php +++ b/src/Repository/PageRepository.php @@ -129,9 +129,9 @@ public function findByProduct( } public function findByProductAndCollectionCode( - ProductInterface $product, - string $collectionCode, - string $channelCode, + ProductInterface $product, + string $collectionCode, + string $channelCode, ?\DateTimeInterface $date = null, ): array { $qb = $this->createQueryBuilder('o') diff --git a/src/Repository/PageRepositoryInterface.php b/src/Repository/PageRepositoryInterface.php index 9b6d3058f..754fa7307 100755 --- a/src/Repository/PageRepositoryInterface.php +++ b/src/Repository/PageRepositoryInterface.php @@ -40,9 +40,9 @@ public function findByProduct( ): array; public function findByProductAndCollectionCode( - ProductInterface $product, - string $collectionCode, - string $channelCode, + ProductInterface $product, + string $collectionCode, + string $channelCode, ?\DateTimeInterface $date, ): array; diff --git a/src/Twig/Runtime/RenderProductPagesRuntime.php b/src/Twig/Runtime/RenderProductPagesRuntime.php index be2daedbf..f930ee963 100644 --- a/src/Twig/Runtime/RenderProductPagesRuntime.php +++ b/src/Twig/Runtime/RenderProductPagesRuntime.php @@ -20,9 +20,9 @@ final class RenderProductPagesRuntime implements RenderProductPagesRuntimeInterface { public function __construct( - private PageRepositoryInterface $pageRepository, - private ChannelContextInterface $channelContext, - private Environment $templatingEngine, + private PageRepositoryInterface $pageRepository, + private ChannelContextInterface $channelContext, + private Environment $templatingEngine, private CollectionsSorterInterface $collectionsSorter, ) { } diff --git a/tests/Behat/Context/Setup/CollectionContext.php b/tests/Behat/Context/Setup/CollectionContext.php index b74ffb0cd..d0da967f2 100755 --- a/tests/Behat/Context/Setup/CollectionContext.php +++ b/tests/Behat/Context/Setup/CollectionContext.php @@ -21,10 +21,10 @@ final class CollectionContext implements Context { public function __construct( - private SharedStorageInterface $sharedStorage, + private SharedStorageInterface $sharedStorage, private RandomStringGeneratorInterface $randomStringGenerator, - private FactoryInterface $collectionFactory, - private CollectionRepositoryInterface $collectionRepository, + private FactoryInterface $collectionFactory, + private CollectionRepositoryInterface $collectionRepository, ) { } diff --git a/tests/Behat/Context/Setup/PageContext.php b/tests/Behat/Context/Setup/PageContext.php index 4aa9f0d93..986a2352b 100755 --- a/tests/Behat/Context/Setup/PageContext.php +++ b/tests/Behat/Context/Setup/PageContext.php @@ -15,8 +15,8 @@ use BitBag\SyliusCmsPlugin\Entity\MediaInterface; use BitBag\SyliusCmsPlugin\Entity\PageInterface; use BitBag\SyliusCmsPlugin\MediaProvider\ProviderInterface; -use BitBag\SyliusCmsPlugin\Repository\PageRepositoryInterface; use BitBag\SyliusCmsPlugin\Repository\CollectionRepositoryInterface; +use BitBag\SyliusCmsPlugin\Repository\PageRepositoryInterface; use Doctrine\ORM\EntityManagerInterface; use Sylius\Behat\Service\SharedStorageInterface; use Sylius\Component\Core\Formatter\StringInflector; @@ -29,14 +29,14 @@ final class PageContext implements Context { public function __construct( - private SharedStorageInterface $sharedStorage, + private SharedStorageInterface $sharedStorage, private RandomStringGeneratorInterface $randomStringGenerator, - private FactoryInterface $pageFactory, - private PageRepositoryInterface $pageRepository, - private EntityManagerInterface $entityManager, - private ProductRepositoryInterface $productRepository, - private CollectionRepositoryInterface $collectionRepository, - private ProviderInterface $imageProvider, + private FactoryInterface $pageFactory, + private PageRepositoryInterface $pageRepository, + private EntityManagerInterface $entityManager, + private ProductRepositoryInterface $productRepository, + private CollectionRepositoryInterface $collectionRepository, + private ProviderInterface $imageProvider, ) { } diff --git a/tests/Behat/Context/Transform/CollectionContext.php b/tests/Behat/Context/Transform/CollectionContext.php index 6b4bb0dfe..c167b9489 100644 --- a/tests/Behat/Context/Transform/CollectionContext.php +++ b/tests/Behat/Context/Transform/CollectionContext.php @@ -19,7 +19,7 @@ final class CollectionContext implements Context { public function __construct( private CollectionRepositoryInterface $collectionRepository, - private string $locale = 'en_US', + private string $locale = 'en_US', ) { } diff --git a/tests/Functional/Fixture/CollectionFixtureTest.php b/tests/Functional/Fixture/CollectionFixtureTest.php index 8efa36c1c..cb5c3a8c6 100644 --- a/tests/Functional/Fixture/CollectionFixtureTest.php +++ b/tests/Functional/Fixture/CollectionFixtureTest.php @@ -10,8 +10,8 @@ namespace Tests\BitBag\SyliusCmsPlugin\Functional\Fixture; -use BitBag\SyliusCmsPlugin\Fixture\Factory\FixtureFactoryInterface; use BitBag\SyliusCmsPlugin\Fixture\CollectionFixture; +use BitBag\SyliusCmsPlugin\Fixture\Factory\FixtureFactoryInterface; use Matthias\SymfonyConfigTest\PhpUnit\ConfigurationTestCaseTrait; use PHPUnit\Framework\TestCase; From c09f4ee2706d2b5dc8b88a52289be018d3d206f4 Mon Sep 17 00:00:00 2001 From: jkindly Date: Wed, 19 Jun 2024 12:35:14 +0200 Subject: [PATCH 12/25] OP-320: Migration FK update --- src/Migrations/Version20240618120258.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Migrations/Version20240618120258.php b/src/Migrations/Version20240618120258.php index e7060ad17..c56b74f2c 100644 --- a/src/Migrations/Version20240618120258.php +++ b/src/Migrations/Version20240618120258.php @@ -62,8 +62,8 @@ public function up(Schema $schema): void $this->addSql('ALTER TABLE bitbag_cms_section_pages DROP FOREIGN KEY FK_C96225EED823E37A'); $this->addSql('ALTER TABLE bitbag_cms_section_blocks DROP FOREIGN KEY FK_A9D9C974E9ED820C'); $this->addSql('ALTER TABLE bitbag_cms_section_blocks DROP FOREIGN KEY FK_A9D9C974D823E37A'); - $this->addSql('ALTER TABLE bitbag_cms_section_media DROP FOREIGN KEY FK_98406A0D823E37A'); - $this->addSql('ALTER TABLE bitbag_cms_section_media DROP FOREIGN KEY FK_98406A0EA9FDD75'); + $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_page_sections'); $this->addSql('DROP TABLE bitbag_cms_block_sections'); @@ -128,8 +128,8 @@ public function down(Schema $schema): void $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_blocks ADD CONSTRAINT FK_A9D9C974E9ED820C FOREIGN KEY (block_id) REFERENCES bitbag_cms_block (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_media ADD CONSTRAINT FK_98406A0D823E37A FOREIGN KEY (section_id) REFERENCES bitbag_cms_section (id) ON DELETE CASCADE'); - $this->addSql('ALTER TABLE bitbag_cms_section_media ADD CONSTRAINT FK_98406A0EA9FDD75 FOREIGN KEY (media_id) REFERENCES bitbag_cms_media (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'); // Restore data to the original tables $this->addSql('INSERT INTO bitbag_cms_section (id, code, type) SELECT id, code, type FROM bitbag_cms_collection_backup'); From d2ba33e4a9f40e8c43346a569350748423be3f23 Mon Sep 17 00:00:00 2001 From: jkindly Date: Wed, 19 Jun 2024 13:39:08 +0200 Subject: [PATCH 13/25] OP-320: Migration adjustments --- ...18120258.php => Version20240619105431.php} | 179 +++++++++--------- 1 file changed, 91 insertions(+), 88 deletions(-) rename src/Migrations/{Version20240618120258.php => Version20240619105431.php} (58%) diff --git a/src/Migrations/Version20240618120258.php b/src/Migrations/Version20240619105431.php similarity index 58% rename from src/Migrations/Version20240618120258.php rename to src/Migrations/Version20240619105431.php index c56b74f2c..e0b7fa412 100644 --- a/src/Migrations/Version20240618120258.php +++ b/src/Migrations/Version20240619105431.php @@ -7,26 +7,28 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; -final class Version20240618120258 extends AbstractMigration +/** + * Auto-generated Migration: Please modify to your needs! + */ +final class Version20240619105431 extends AbstractMigration { public function getDescription(): string { - return 'Renames tables and preserves data during migration'; + return ''; } public function up(Schema $schema): void { - // Back up data from the old tables - $this->addSql('CREATE TABLE bitbag_cms_page_sections_backup AS SELECT * FROM bitbag_cms_page_sections'); - $this->addSql('CREATE TABLE bitbag_cms_block_sections_backup AS SELECT * FROM bitbag_cms_block_sections'); - $this->addSql('CREATE TABLE bitbag_cms_media_sections_backup AS SELECT * FROM bitbag_cms_media_sections'); - $this->addSql('CREATE TABLE bitbag_cms_section_translation_backup AS SELECT * FROM bitbag_cms_section_translation'); - $this->addSql('CREATE TABLE bitbag_cms_section_pages_backup AS SELECT * FROM bitbag_cms_section_pages'); - $this->addSql('CREATE TABLE bitbag_cms_section_blocks_backup AS SELECT * FROM bitbag_cms_section_blocks'); - $this->addSql('CREATE TABLE bitbag_cms_section_media_backup AS SELECT * FROM bitbag_cms_section_media'); - $this->addSql('CREATE TABLE bitbag_cms_section_backup AS SELECT * FROM bitbag_cms_section'); - - // Perform the schema changes + $this->addSql('CREATE TABLE temp_bitbag_cms_block_sections AS SELECT * FROM bitbag_cms_block_sections'); + $this->addSql('CREATE TABLE temp_bitbag_cms_media_sections AS SELECT * FROM bitbag_cms_media_sections'); + $this->addSql('CREATE TABLE temp_bitbag_cms_page_sections AS SELECT * FROM bitbag_cms_page_sections'); + $this->addSql('CREATE TABLE temp_bitbag_cms_section_translation AS SELECT * FROM bitbag_cms_section_translation'); + $this->addSql('CREATE TABLE temp_bitbag_cms_section_pages AS SELECT * FROM bitbag_cms_section_pages'); + $this->addSql('CREATE TABLE temp_bitbag_cms_section_blocks AS SELECT * FROM bitbag_cms_section_blocks'); + $this->addSql('CREATE TABLE temp_bitbag_cms_section_media AS SELECT * FROM bitbag_cms_section_media'); + $this->addSql('CREATE TABLE temp_bitbag_cms_section AS SELECT * FROM bitbag_cms_section'); + + // this up() migration is auto-generated, please modify it to your needs $this->addSql('CREATE TABLE bitbag_cms_block_collections (block_id INT NOT NULL, collection_id INT NOT NULL, INDEX IDX_55C5E95EE9ED820C (block_id), INDEX IDX_55C5E95E514956FD (collection_id), PRIMARY KEY(block_id, collection_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); $this->addSql('CREATE TABLE bitbag_cms_collection (id INT AUTO_INCREMENT NOT NULL, code VARCHAR(250) NOT NULL, type VARCHAR(250) DEFAULT NULL, UNIQUE INDEX UNIQ_9634175177153098 (code), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); $this->addSql('CREATE TABLE bitbag_cms_collection_pages (collection_id INT NOT NULL, page_id INT NOT NULL, INDEX IDX_3989329D514956FD (collection_id), INDEX IDX_3989329DC4663E4 (page_id), PRIMARY KEY(collection_id, page_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); @@ -35,7 +37,6 @@ public function up(Schema $schema): void $this->addSql('CREATE TABLE bitbag_cms_collection_translation (id INT AUTO_INCREMENT NOT NULL, translatable_id INT NOT NULL, name VARCHAR(255) DEFAULT NULL, locale VARCHAR(255) NOT NULL, INDEX IDX_1250294C2C2AC5D3 (translatable_id), UNIQUE INDEX bitbag_cms_collection_translation_uniq_trans (translatable_id, locale), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); $this->addSql('CREATE TABLE bitbag_cms_media_collections (media_id INT NOT NULL, collection_id INT NOT NULL, INDEX IDX_78A0CE16EA9FDD75 (media_id), INDEX IDX_78A0CE16514956FD (collection_id), PRIMARY KEY(media_id, collection_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); $this->addSql('CREATE TABLE bitbag_cms_page_collections (block_id INT NOT NULL, collection_id INT NOT NULL, INDEX IDX_9A9CE227E9ED820C (block_id), INDEX IDX_9A9CE227514956FD (collection_id), PRIMARY KEY(block_id, collection_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); - $this->addSql('ALTER TABLE bitbag_cms_block_collections ADD CONSTRAINT FK_55C5E95EE9ED820C FOREIGN KEY (block_id) REFERENCES bitbag_cms_block (id) ON DELETE CASCADE'); $this->addSql('ALTER TABLE bitbag_cms_block_collections ADD CONSTRAINT FK_55C5E95E514956FD FOREIGN KEY (collection_id) REFERENCES bitbag_cms_collection (id) ON DELETE CASCADE'); $this->addSql('ALTER TABLE bitbag_cms_collection_pages ADD CONSTRAINT FK_3989329D514956FD FOREIGN KEY (collection_id) REFERENCES bitbag_cms_collection (id) ON DELETE CASCADE'); @@ -49,99 +50,93 @@ public function up(Schema $schema): void $this->addSql('ALTER TABLE bitbag_cms_media_collections ADD CONSTRAINT FK_78A0CE16514956FD FOREIGN KEY (collection_id) REFERENCES bitbag_cms_collection (id) ON DELETE CASCADE'); $this->addSql('ALTER TABLE bitbag_cms_page_collections ADD CONSTRAINT FK_9A9CE227E9ED820C FOREIGN KEY (block_id) REFERENCES bitbag_cms_page (id) ON DELETE CASCADE'); $this->addSql('ALTER TABLE bitbag_cms_page_collections ADD CONSTRAINT FK_9A9CE227514956FD FOREIGN KEY (collection_id) REFERENCES bitbag_cms_collection (id) ON DELETE CASCADE'); - - // Drop old tables - $this->addSql('ALTER TABLE bitbag_cms_page_sections DROP FOREIGN KEY FK_D548E347E9ED820C'); - $this->addSql('ALTER TABLE bitbag_cms_page_sections DROP FOREIGN KEY FK_D548E347D823E37A'); $this->addSql('ALTER TABLE bitbag_cms_block_sections DROP FOREIGN KEY FK_5C95115DE9ED820C'); $this->addSql('ALTER TABLE bitbag_cms_block_sections DROP FOREIGN KEY FK_5C95115DD823E37A'); - $this->addSql('ALTER TABLE bitbag_cms_media_sections DROP FOREIGN KEY FK_98BC300D823E37A'); $this->addSql('ALTER TABLE bitbag_cms_media_sections DROP FOREIGN KEY FK_98BC300EA9FDD75'); + $this->addSql('ALTER TABLE bitbag_cms_media_sections DROP FOREIGN KEY FK_98BC300D823E37A'); + $this->addSql('ALTER TABLE bitbag_cms_page_sections DROP FOREIGN KEY FK_D548E347D823E37A'); + $this->addSql('ALTER TABLE bitbag_cms_page_sections DROP FOREIGN KEY FK_D548E347E9ED820C'); $this->addSql('ALTER TABLE bitbag_cms_section_translation DROP FOREIGN KEY FK_F99CA8582C2AC5D3'); $this->addSql('ALTER TABLE bitbag_cms_section_pages DROP FOREIGN KEY FK_C96225EEC4663E4'); $this->addSql('ALTER TABLE bitbag_cms_section_pages DROP FOREIGN KEY FK_C96225EED823E37A'); - $this->addSql('ALTER TABLE bitbag_cms_section_blocks DROP FOREIGN KEY FK_A9D9C974E9ED820C'); $this->addSql('ALTER TABLE bitbag_cms_section_blocks DROP FOREIGN KEY FK_A9D9C974D823E37A'); - $this->addSql('ALTER TABLE bitbag_cms_section_media DROP FOREIGN KEY FK_833A6197D823E37A'); + $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_833A6197EA9FDD75'); - - $this->addSql('DROP TABLE bitbag_cms_page_sections'); + $this->addSql('ALTER TABLE bitbag_cms_section_media DROP FOREIGN KEY FK_833A6197D823E37A'); $this->addSql('DROP TABLE bitbag_cms_block_sections'); $this->addSql('DROP TABLE bitbag_cms_media_sections'); + $this->addSql('DROP TABLE bitbag_cms_page_sections'); $this->addSql('DROP TABLE bitbag_cms_section_translation'); $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('DROP TABLE bitbag_cms_section'); - // Restore data to the new tables - $this->addSql('INSERT INTO bitbag_cms_collection (id, code, type) SELECT id, code, type FROM bitbag_cms_section_backup'); - $this->addSql('INSERT INTO bitbag_cms_collection_translation (id, translatable_id, name, locale) SELECT id, translatable_id, name, locale FROM bitbag_cms_section_translation_backup'); - $this->addSql('INSERT INTO bitbag_cms_collection_pages (collection_id, page_id) SELECT section_id, page_id FROM bitbag_cms_section_pages_backup'); - $this->addSql('INSERT INTO bitbag_cms_collection_blocks (collection_id, block_id) SELECT section_id, block_id FROM bitbag_cms_section_blocks_backup'); - $this->addSql('INSERT INTO bitbag_cms_collection_media (collection_id, media_id) SELECT section_id, media_id FROM bitbag_cms_section_media_backup'); - $this->addSql('INSERT INTO bitbag_cms_page_collections (block_id, collection_id) SELECT page_id, section_id FROM bitbag_cms_page_sections_backup'); - $this->addSql('INSERT INTO bitbag_cms_block_collections (block_id, collection_id) SELECT block_id, section_id FROM bitbag_cms_block_sections_backup'); - $this->addSql('INSERT INTO bitbag_cms_media_collections (media_id, collection_id) SELECT media_id, section_id FROM bitbag_cms_media_sections_backup'); - - // Drop the backup tables - $this->addSql('DROP TABLE bitbag_cms_page_sections_backup'); - $this->addSql('DROP TABLE bitbag_cms_block_sections_backup'); - $this->addSql('DROP TABLE bitbag_cms_media_sections_backup'); - $this->addSql('DROP TABLE bitbag_cms_section_translation_backup'); - $this->addSql('DROP TABLE bitbag_cms_section_pages_backup'); - $this->addSql('DROP TABLE bitbag_cms_section_blocks_backup'); - $this->addSql('DROP TABLE bitbag_cms_section_media_backup'); - $this->addSql('DROP TABLE bitbag_cms_section_backup'); + $this->addSql('INSERT INTO bitbag_cms_block_collections (block_id, collection_id) SELECT block_id, section_id FROM temp_bitbag_cms_block_sections'); + $this->addSql('INSERT INTO bitbag_cms_collection (id, code, type) SELECT id, code, type FROM temp_bitbag_cms_section'); + $this->addSql('INSERT INTO bitbag_cms_collection_pages (collection_id, page_id) SELECT section_id, page_id FROM temp_bitbag_cms_section_pages'); + $this->addSql('INSERT INTO bitbag_cms_collection_blocks (collection_id, block_id) SELECT section_id, block_id FROM temp_bitbag_cms_section_blocks'); + $this->addSql('INSERT INTO bitbag_cms_collection_media (collection_id, media_id) SELECT section_id, media_id FROM temp_bitbag_cms_section_media'); + $this->addSql('INSERT INTO bitbag_cms_collection_translation (translatable_id, name, locale) SELECT translatable_id, name, locale FROM temp_bitbag_cms_section_translation'); + $this->addSql('INSERT INTO bitbag_cms_media_collections (media_id, collection_id) SELECT media_id, section_id FROM temp_bitbag_cms_media_sections'); + $this->addSql('INSERT INTO bitbag_cms_page_collections (block_id, collection_id) SELECT block_id, section_id FROM temp_bitbag_cms_page_sections'); + + $this->addSql('DROP TABLE temp_bitbag_cms_block_sections'); + $this->addSql('DROP TABLE temp_bitbag_cms_media_sections'); + $this->addSql('DROP TABLE temp_bitbag_cms_page_sections'); + $this->addSql('DROP TABLE temp_bitbag_cms_section_translation'); + $this->addSql('DROP TABLE temp_bitbag_cms_section_pages'); + $this->addSql('DROP TABLE temp_bitbag_cms_section_blocks'); + $this->addSql('DROP TABLE temp_bitbag_cms_section_media'); + $this->addSql('DROP TABLE temp_bitbag_cms_section'); } public function down(Schema $schema): void { - // Back up data from the new tables - $this->addSql('CREATE TABLE bitbag_cms_page_collections_backup AS SELECT * FROM bitbag_cms_page_collections'); - $this->addSql('CREATE TABLE bitbag_cms_block_collections_backup AS SELECT * FROM bitbag_cms_block_collections'); - $this->addSql('CREATE TABLE bitbag_cms_media_collections_backup AS SELECT * FROM bitbag_cms_media_collections'); - $this->addSql('CREATE TABLE bitbag_cms_collection_translation_backup AS SELECT * FROM bitbag_cms_collection_translation'); - $this->addSql('CREATE TABLE bitbag_cms_collection_pages_backup AS SELECT * FROM bitbag_cms_collection_pages'); - $this->addSql('CREATE TABLE bitbag_cms_collection_blocks_backup AS SELECT * FROM bitbag_cms_collection_blocks'); - $this->addSql('CREATE TABLE bitbag_cms_collection_media_backup AS SELECT * FROM bitbag_cms_collection_media'); - $this->addSql('CREATE TABLE bitbag_cms_collection_backup AS SELECT * FROM bitbag_cms_collection'); - - // Restore the original table structures - $this->addSql('CREATE TABLE bitbag_cms_page_sections (page_id INT NOT NULL, section_id INT NOT NULL, INDEX IDX_D548E347C4663E4 (page_id), INDEX IDX_D548E347D823E37A (section_id), PRIMARY KEY(page_id, section_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); - $this->addSql('CREATE TABLE bitbag_cms_block_sections (block_id INT NOT NULL, section_id INT NOT NULL, INDEX IDX_5C95115DE9ED820C (block_id), INDEX IDX_5C95115DD823E37A (section_id), PRIMARY KEY(block_id, section_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); - $this->addSql('CREATE TABLE bitbag_cms_media_sections (media_id INT NOT NULL, section_id INT NOT NULL, INDEX IDX_98BC300EA9FDD75 (media_id), INDEX IDX_98BC300D823E37A (section_id), PRIMARY KEY(media_id, section_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); - $this->addSql('CREATE TABLE bitbag_cms_section_translation (id INT AUTO_INCREMENT NOT NULL, translatable_id INT NOT NULL, name VARCHAR(255) DEFAULT NULL, locale VARCHAR(255) NOT NULL, INDEX IDX_F99CA8582C2AC5D3 (translatable_id), UNIQUE INDEX bitbag_cms_section_translation_uniq_trans (translatable_id, locale), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); - $this->addSql('CREATE TABLE bitbag_cms_section_pages (section_id INT NOT NULL, page_id INT NOT NULL, INDEX IDX_C96225EEC4663E4 (page_id), INDEX IDX_C96225EED823E37A (section_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_A9D9C974E9ED820C (block_id), INDEX IDX_A9D9C974D823E37A (section_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_98406A0EA9FDD75 (media_id), INDEX IDX_98406A0D823E37A (section_id), PRIMARY KEY(section_id, media_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); - $this->addSql('CREATE TABLE bitbag_cms_section (id INT AUTO_INCREMENT NOT NULL, code VARCHAR(250) NOT NULL, type VARCHAR(250) DEFAULT NULL, UNIQUE INDEX UNIQ_D7D8598F77153098 (code), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); - - $this->addSql('ALTER TABLE bitbag_cms_page_sections ADD CONSTRAINT FK_D548E347E9ED820C FOREIGN KEY (page_id) REFERENCES bitbag_cms_page (id) ON DELETE CASCADE'); - $this->addSql('ALTER TABLE bitbag_cms_page_sections ADD CONSTRAINT FK_D548E347D823E37A FOREIGN KEY (section_id) REFERENCES bitbag_cms_section (id) ON DELETE CASCADE'); + $this->addSql('CREATE TABLE temp_bitbag_cms_block_collections AS SELECT * FROM bitbag_cms_block_collections'); + $this->addSql('CREATE TABLE temp_bitbag_cms_media_collections AS SELECT * FROM bitbag_cms_media_collections'); + $this->addSql('CREATE TABLE temp_bitbag_cms_page_collections AS SELECT * FROM bitbag_cms_page_collections'); + $this->addSql('CREATE TABLE temp_bitbag_cms_collection_translation AS SELECT * FROM bitbag_cms_collection_translation'); + $this->addSql('CREATE TABLE temp_bitbag_cms_collection_pages AS SELECT * FROM bitbag_cms_collection_pages'); + $this->addSql('CREATE TABLE temp_bitbag_cms_collection_blocks AS SELECT * FROM bitbag_cms_collection_blocks'); + $this->addSql('CREATE TABLE temp_bitbag_cms_collection_media AS SELECT * FROM bitbag_cms_collection_media'); + $this->addSql('CREATE TABLE temp_bitbag_cms_collection AS SELECT * FROM bitbag_cms_collection'); + + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('CREATE TABLE bitbag_cms_block_sections (block_id INT NOT NULL, section_id INT NOT NULL, INDEX IDX_5C95115DE9ED820C (block_id), INDEX IDX_5C95115DD823E37A (section_id), PRIMARY KEY(block_id, section_id)) DEFAULT CHARACTER SET utf8mb3 COLLATE `utf8mb3_unicode_ci` ENGINE = InnoDB COMMENT = \'\' '); + $this->addSql('CREATE TABLE bitbag_cms_media_sections (media_id INT NOT NULL, section_id INT NOT NULL, INDEX IDX_98BC300D823E37A (section_id), INDEX IDX_98BC300EA9FDD75 (media_id), PRIMARY KEY(media_id, section_id)) DEFAULT CHARACTER SET utf8mb3 COLLATE `utf8mb3_unicode_ci` ENGINE = InnoDB COMMENT = \'\' '); + $this->addSql('CREATE TABLE bitbag_cms_page_sections (block_id INT NOT NULL, section_id INT NOT NULL, INDEX IDX_D548E347D823E37A (section_id), INDEX IDX_D548E347E9ED820C (block_id), PRIMARY KEY(block_id, section_id)) DEFAULT CHARACTER SET utf8mb3 COLLATE `utf8mb3_unicode_ci` ENGINE = InnoDB COMMENT = \'\' '); + $this->addSql('CREATE TABLE bitbag_cms_section_translation (id INT AUTO_INCREMENT NOT NULL, translatable_id INT NOT NULL, name VARCHAR(255) CHARACTER SET utf8mb3 DEFAULT NULL COLLATE `utf8mb3_unicode_ci`, locale VARCHAR(255) CHARACTER SET utf8mb3 NOT NULL COLLATE `utf8mb3_unicode_ci`, INDEX IDX_F99CA8582C2AC5D3 (translatable_id), UNIQUE INDEX bitbag_cms_section_translation_uniq_trans (translatable_id, locale), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb3 COLLATE `utf8mb3_unicode_ci` ENGINE = InnoDB COMMENT = \'\' '); + $this->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 COMMENT = \'\' '); + $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 COMMENT = \'\' '); + $this->addSql('CREATE TABLE bitbag_cms_section_media (section_id INT NOT NULL, media_id INT NOT NULL, INDEX IDX_833A6197EA9FDD75 (media_id), INDEX IDX_833A6197D823E37A (section_id), PRIMARY KEY(section_id, media_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB COMMENT = \'\' '); + $this->addSql('CREATE TABLE bitbag_cms_section (id INT AUTO_INCREMENT NOT NULL, code VARCHAR(250) CHARACTER SET utf8mb3 NOT NULL COLLATE `utf8mb3_unicode_ci`, type VARCHAR(250) CHARACTER SET utf8mb3 DEFAULT NULL COLLATE `utf8mb3_unicode_ci`, UNIQUE INDEX UNIQ_421D079777153098 (code), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb3 COLLATE `utf8mb3_unicode_ci` ENGINE = InnoDB COMMENT = \'\' '); $this->addSql('ALTER TABLE bitbag_cms_block_sections ADD CONSTRAINT FK_5C95115DE9ED820C FOREIGN KEY (block_id) REFERENCES bitbag_cms_block (id) ON DELETE CASCADE'); $this->addSql('ALTER TABLE bitbag_cms_block_sections ADD CONSTRAINT FK_5C95115DD823E37A FOREIGN KEY (section_id) REFERENCES bitbag_cms_section (id) ON DELETE CASCADE'); - $this->addSql('ALTER TABLE bitbag_cms_media_sections ADD CONSTRAINT FK_98BC300D823E37A FOREIGN KEY (section_id) REFERENCES bitbag_cms_section (id) ON DELETE CASCADE'); $this->addSql('ALTER TABLE bitbag_cms_media_sections ADD CONSTRAINT FK_98BC300EA9FDD75 FOREIGN KEY (media_id) REFERENCES bitbag_cms_media (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE bitbag_cms_media_sections ADD CONSTRAINT FK_98BC300D823E37A FOREIGN KEY (section_id) REFERENCES bitbag_cms_section (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE bitbag_cms_page_sections ADD CONSTRAINT FK_D548E347D823E37A FOREIGN KEY (section_id) REFERENCES bitbag_cms_section (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE bitbag_cms_page_sections ADD CONSTRAINT FK_D548E347E9ED820C FOREIGN KEY (block_id) REFERENCES bitbag_cms_page (id) ON DELETE CASCADE'); $this->addSql('ALTER TABLE bitbag_cms_section_translation ADD CONSTRAINT FK_F99CA8582C2AC5D3 FOREIGN KEY (translatable_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_pages ADD CONSTRAINT FK_C96225EED823E37A 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_blocks ADD CONSTRAINT FK_A9D9C974D823E37A FOREIGN KEY (section_id) REFERENCES bitbag_cms_section (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_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_833A6197EA9FDD75 FOREIGN KEY (media_id) REFERENCES bitbag_cms_media (id) ON DELETE CASCADE'); - - // Restore data to the original tables - $this->addSql('INSERT INTO bitbag_cms_section (id, code, type) SELECT id, code, type FROM bitbag_cms_collection_backup'); - $this->addSql('INSERT INTO bitbag_cms_section_translation (id, translatable_id, name, locale) SELECT id, translatable_id, name, locale FROM bitbag_cms_collection_translation_backup'); - $this->addSql('INSERT INTO bitbag_cms_section_pages (section_id, page_id) SELECT collection_id, page_id FROM bitbag_cms_collection_pages_backup'); - $this->addSql('INSERT INTO bitbag_cms_section_blocks (section_id, block_id) SELECT collection_id, block_id FROM bitbag_cms_collection_blocks_backup'); - $this->addSql('INSERT INTO bitbag_cms_section_media (section_id, media_id) SELECT collection_id, media_id FROM bitbag_cms_collection_media_backup'); - $this->addSql('INSERT INTO bitbag_cms_page_sections (page_id, section_id) SELECT block_id, collection_id FROM bitbag_cms_page_collections_backup'); - $this->addSql('INSERT INTO bitbag_cms_block_sections (block_id, section_id) SELECT block_id, collection_id FROM bitbag_cms_block_collections_backup'); - $this->addSql('INSERT INTO bitbag_cms_media_sections (media_id, section_id) SELECT media_id, collection_id FROM bitbag_cms_media_collections_backup'); - - // Drop the new tables + $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_block_collections DROP FOREIGN KEY FK_55C5E95EE9ED820C'); + $this->addSql('ALTER TABLE bitbag_cms_block_collections DROP FOREIGN KEY FK_55C5E95E514956FD'); + $this->addSql('ALTER TABLE bitbag_cms_collection_pages DROP FOREIGN KEY FK_3989329D514956FD'); + $this->addSql('ALTER TABLE bitbag_cms_collection_pages DROP FOREIGN KEY FK_3989329DC4663E4'); + $this->addSql('ALTER TABLE bitbag_cms_collection_blocks DROP FOREIGN KEY FK_602502E5514956FD'); + $this->addSql('ALTER TABLE bitbag_cms_collection_blocks DROP FOREIGN KEY FK_602502E5E9ED820C'); + $this->addSql('ALTER TABLE bitbag_cms_collection_media DROP FOREIGN KEY FK_73D176E4514956FD'); + $this->addSql('ALTER TABLE bitbag_cms_collection_media DROP FOREIGN KEY FK_73D176E4EA9FDD75'); + $this->addSql('ALTER TABLE bitbag_cms_collection_translation DROP FOREIGN KEY FK_1250294C2C2AC5D3'); + $this->addSql('ALTER TABLE bitbag_cms_media_collections DROP FOREIGN KEY FK_78A0CE16EA9FDD75'); + $this->addSql('ALTER TABLE bitbag_cms_media_collections DROP FOREIGN KEY FK_78A0CE16514956FD'); + $this->addSql('ALTER TABLE bitbag_cms_page_collections DROP FOREIGN KEY FK_9A9CE227E9ED820C'); + $this->addSql('ALTER TABLE bitbag_cms_page_collections DROP FOREIGN KEY FK_9A9CE227514956FD'); $this->addSql('DROP TABLE bitbag_cms_block_collections'); $this->addSql('DROP TABLE bitbag_cms_collection'); $this->addSql('DROP TABLE bitbag_cms_collection_pages'); @@ -151,14 +146,22 @@ public function down(Schema $schema): void $this->addSql('DROP TABLE bitbag_cms_media_collections'); $this->addSql('DROP TABLE bitbag_cms_page_collections'); - // Drop the backup tables - $this->addSql('DROP TABLE bitbag_cms_page_collections_backup'); - $this->addSql('DROP TABLE bitbag_cms_block_collections_backup'); - $this->addSql('DROP TABLE bitbag_cms_media_collections_backup'); - $this->addSql('DROP TABLE bitbag_cms_collection_translation_backup'); - $this->addSql('DROP TABLE bitbag_cms_collection_pages_backup'); - $this->addSql('DROP TABLE bitbag_cms_collection_blocks_backup'); - $this->addSql('DROP TABLE bitbag_cms_collection_media_backup'); - $this->addSql('DROP TABLE bitbag_cms_collection_backup'); + $this->addSql('INSERT INTO bitbag_cms_block_sections (block_id, section_id) SELECT block_id, collection_id FROM temp_bitbag_cms_block_collections'); + $this->addSql('INSERT INTO bitbag_cms_media_sections (media_id, section_id) SELECT media_id, collection_id FROM temp_bitbag_cms_media_collections'); + $this->addSql('INSERT INTO bitbag_cms_page_sections (block_id, section_id) SELECT block_id, collection_id FROM temp_bitbag_cms_page_collections'); + $this->addSql('INSERT INTO bitbag_cms_section_translation (translatable_id, name, locale) SELECT translatable_id, name, locale FROM temp_bitbag_cms_collection_translation'); + $this->addSql('INSERT INTO bitbag_cms_section_pages (section_id, page_id) SELECT section_id, collection_id FROM temp_bitbag_cms_collection_pages'); + $this->addSql('INSERT INTO bitbag_cms_section_blocks (section_id, block_id) SELECT section_id, collection_id FROM temp_bitbag_cms_collection_blocks'); + $this->addSql('INSERT INTO bitbag_cms_section_media (section_id, media_id) SELECT section_id, collection_id FROM temp_bitbag_cms_collection_media'); + $this->addSql('INSERT INTO bitbag_cms_section (id, code, type) SELECT id, code, type FROM temp_bitbag_cms_collection'); + + $this->addSql('DROP TABLE temp_bitbag_cms_block_collections'); + $this->addSql('DROP TABLE temp_bitbag_cms_media_collections'); + $this->addSql('DROP TABLE temp_bitbag_cms_page_collections'); + $this->addSql('DROP TABLE temp_bitbag_cms_collection_translation'); + $this->addSql('DROP TABLE temp_bitbag_cms_collection_pages'); + $this->addSql('DROP TABLE temp_bitbag_cms_collection_blocks'); + $this->addSql('DROP TABLE temp_bitbag_cms_collection_media'); + $this->addSql('DROP TABLE temp_bitbag_cms_collection'); } } From 4ec1c83ff53e14f607b4ca12bdb8a45918747363 Mon Sep 17 00:00:00 2001 From: jkindly Date: Wed, 19 Jun 2024 14:21:20 +0200 Subject: [PATCH 14/25] OP-320: Spec fixes --- spec/Twig/Runtime/RenderProductPagesRuntimeSpec.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/Twig/Runtime/RenderProductPagesRuntimeSpec.php b/spec/Twig/Runtime/RenderProductPagesRuntimeSpec.php index e9c31808b..cb761020b 100644 --- a/spec/Twig/Runtime/RenderProductPagesRuntimeSpec.php +++ b/spec/Twig/Runtime/RenderProductPagesRuntimeSpec.php @@ -62,7 +62,7 @@ public function it_renders_product_pages( $collection->getCode()->willReturn('COLLECTION_CODE'); $pageRepository->findByProduct($product, 'WEB', null)->willReturn([])->shouldBeCalled(); $collectionsSorter->sortByCollections([])->willReturn([]); - $templatingEngine->render('_pagesByCollection.html.twig', ['data' => []])->willReturn('content'); + $templatingEngine->render('@BitBagSyliusCmsPlugin/Shop/Product/_pagesByCollection.html.twig', ['data' => []])->willReturn('content'); $this->renderProductPages($product)->shouldReturn('content'); } @@ -83,7 +83,7 @@ public function it_renders_product_pages_with_collections( $collection->getCode()->willReturn('COLLECTION_CODE'); $pageRepository->findByProductAndCollectionCode($product, 'COLLECTION_CODE', 'WEB', null)->willReturn([])->shouldBeCalled(); $collectionsSorter->sortByCollections([])->willReturn([]); - $templatingEngine->render('_pagesByCollection.html.twig', ['data' => []])->willReturn('content'); + $templatingEngine->render('@BitBagSyliusCmsPlugin/Shop/Product/_pagesByCollection.html.twig', ['data' => []])->willReturn('content'); $this->renderProductPages($product, 'COLLECTION_CODE')->shouldReturn('content'); } From b256b4eeae4122bc13bb454a8f3dd268b05b8a77 Mon Sep 17 00:00:00 2001 From: jkindly Date: Wed, 19 Jun 2024 14:30:55 +0200 Subject: [PATCH 15/25] OP-320: Behat fixes --- tests/Behat/Resources/services/contexts/setup.xml | 2 +- tests/Behat/Resources/services/contexts/ui.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Behat/Resources/services/contexts/setup.xml b/tests/Behat/Resources/services/contexts/setup.xml index dc47ca86d..87af1d70e 100644 --- a/tests/Behat/Resources/services/contexts/setup.xml +++ b/tests/Behat/Resources/services/contexts/setup.xml @@ -29,7 +29,7 @@ - + diff --git a/tests/Behat/Resources/services/contexts/ui.xml b/tests/Behat/Resources/services/contexts/ui.xml index 83901074b..a6fdfe9f1 100644 --- a/tests/Behat/Resources/services/contexts/ui.xml +++ b/tests/Behat/Resources/services/contexts/ui.xml @@ -36,7 +36,7 @@ - + From 78a16403a8df077ff690b416543a7ccc8d9c889d Mon Sep 17 00:00:00 2001 From: jkindly Date: Wed, 19 Jun 2024 14:47:27 +0200 Subject: [PATCH 16/25] OP-320: etc/build/.gitkeep --- etc/build/.gitkeep | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 etc/build/.gitkeep diff --git a/etc/build/.gitkeep b/etc/build/.gitkeep new file mode 100644 index 000000000..e69de29bb From 4e75b6544dbd52974787f1144787d43b2cc34719 Mon Sep 17 00:00:00 2001 From: jkindly Date: Wed, 19 Jun 2024 17:46:32 +0200 Subject: [PATCH 17/25] OP-320: fix path in layout --- .../templates/bundles/SyliusShopBundle/layout.html.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 @@
- {{ 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'})) }} From 0319049474685ee4b9f9b701be23c4255434d6d2 Mon Sep 17 00:00:00 2001 From: Jakub Kozupa <39444635+jkindly@users.noreply.github.com> Date: Fri, 21 Jun 2024 14:22:27 +0200 Subject: [PATCH 23/25] Update spec/Resolver/ImporterCollectionsResolverSpec.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Marcin Kukliński --- spec/Resolver/ImporterCollectionsResolverSpec.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/spec/Resolver/ImporterCollectionsResolverSpec.php b/spec/Resolver/ImporterCollectionsResolverSpec.php index b96642a7d..bb701891f 100644 --- a/spec/Resolver/ImporterCollectionsResolverSpec.php +++ b/spec/Resolver/ImporterCollectionsResolverSpec.php @@ -31,8 +31,7 @@ public function it_is_initializable() public function it_resolves_collections_for_collectionable_entity( CollectionsAssignerInterface $collectionsAssigner, CollectionableInterface $collectionable - ) - { + ) { $collectionsRow = 'collection1, collection2, collection3'; $collectionsCodes = ['collection1', 'collection2', 'collection3']; From d9978647bbbbd12aaaaa3d56d2d8e0493001f0d5 Mon Sep 17 00:00:00 2001 From: jkindly Date: Fri, 21 Jun 2024 14:43:03 +0200 Subject: [PATCH 24/25] OP-320: CR Updates --- spec/Assigner/CollectionsAssignerSpec.php | 12 +++++-- spec/Importer/BlockImporterSpec.php | 29 +++++++-------- spec/Importer/MediaImporterSpec.php | 25 ++++++------- spec/Importer/PageImporterSpec.php | 35 ++++++++++--------- .../ImporterCollectionsResolverSpec.php | 4 +-- .../Runtime/RenderProductPagesRuntimeSpec.php | 28 +++++++-------- src/Entity/Block.php | 2 +- ...tionableTrait.php => CollectibleTrait.php} | 2 +- src/Entity/Collection.php | 4 +-- src/Entity/CollectionInterface.php | 2 +- src/Entity/Media.php | 2 +- ...ableTrait.php => MediaCollectionTrait.php} | 2 +- src/Entity/Page.php | 2 +- ...rface.php => PagesCollectionInterface.php} | 2 +- ...ableTrait.php => PagesCollectionTrait.php} | 2 +- .../Repository/CollectionRepositoryTest.php | 2 +- 16 files changed, 82 insertions(+), 73 deletions(-) rename src/Entity/{CollectionableTrait.php => CollectibleTrait.php} (98%) rename src/Entity/{MediableTrait.php => MediaCollectionTrait.php} (97%) rename src/Entity/{PageableInterface.php => PagesCollectionInterface.php} (95%) rename src/Entity/{PageableTrait.php => PagesCollectionTrait.php} (97%) diff --git a/spec/Assigner/CollectionsAssignerSpec.php b/spec/Assigner/CollectionsAssignerSpec.php index ff777b4a5..bfbfd29d0 100644 --- a/spec/Assigner/CollectionsAssignerSpec.php +++ b/spec/Assigner/CollectionsAssignerSpec.php @@ -1,5 +1,11 @@ findOneBy(['code' => 'about'])->willReturn($aboutCollection); diff --git a/spec/Importer/BlockImporterSpec.php b/spec/Importer/BlockImporterSpec.php index c7a5cd00b..a5d5a3687 100644 --- a/spec/Importer/BlockImporterSpec.php +++ b/spec/Importer/BlockImporterSpec.php @@ -24,13 +24,13 @@ final class BlockImporterSpec extends ObjectBehavior { public function let( - ResourceResolverInterface $blockResourceResolver, - LocaleContextInterface $localeContext, + ResourceResolverInterface $blockResourceResolver, + LocaleContextInterface $localeContext, ImporterCollectionsResolverInterface $importerCollectionsResolver, - ImporterChannelsResolverInterface $importerChannelsResolver, - ImporterProductsResolverInterface $importerProductsResolver, - ValidatorInterface $validator, - BlockRepositoryInterface $blockRepository + ImporterChannelsResolverInterface $importerChannelsResolver, + ImporterProductsResolverInterface $importerProductsResolver, + ValidatorInterface $validator, + BlockRepositoryInterface $blockRepository ) { $this->beConstructedWith( $blockResourceResolver, @@ -50,15 +50,16 @@ public function it_is_initializable() } public function it_imports_block( - ResourceResolverInterface $blockResourceResolver, - LocaleContextInterface $localeContext, + ResourceResolverInterface $blockResourceResolver, + LocaleContextInterface $localeContext, ImporterCollectionsResolverInterface $importerCollectionsResolver, - ImporterChannelsResolverInterface $importerChannelsResolver, - ImporterProductsResolverInterface $importerProductsResolver, - ValidatorInterface $validator, - BlockRepositoryInterface $blockRepository, - BlockInterface $block - ) { + 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); diff --git a/spec/Importer/MediaImporterSpec.php b/spec/Importer/MediaImporterSpec.php index 427d48871..6f65797ea 100644 --- a/spec/Importer/MediaImporterSpec.php +++ b/spec/Importer/MediaImporterSpec.php @@ -23,12 +23,12 @@ final class MediaImporterSpec extends ObjectBehavior { public function let( - ResourceResolverInterface $mediaResourceResolver, - LocaleContextInterface $localeContext, + ResourceResolverInterface $mediaResourceResolver, + LocaleContextInterface $localeContext, ImporterCollectionsResolverInterface $importerCollectionsResolver, - ImporterProductsResolverInterface $importerProductsResolver, - ValidatorInterface $validator, - MediaRepositoryInterface $mediaRepository + ImporterProductsResolverInterface $importerProductsResolver, + ValidatorInterface $validator, + MediaRepositoryInterface $mediaRepository ) { $this->beConstructedWith( $mediaResourceResolver, @@ -47,14 +47,15 @@ public function it_is_initializable() } public function it_imports_media( - ResourceResolverInterface $mediaResourceResolver, - LocaleContextInterface $localeContext, + ResourceResolverInterface $mediaResourceResolver, + LocaleContextInterface $localeContext, ImporterCollectionsResolverInterface $importerCollectionsResolver, - ImporterProductsResolverInterface $importerProductsResolver, - ValidatorInterface $validator, - MediaRepositoryInterface $mediaRepository, - MediaInterface $media - ) { + 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); diff --git a/spec/Importer/PageImporterSpec.php b/spec/Importer/PageImporterSpec.php index 73b3efc8e..0b150c71a 100644 --- a/spec/Importer/PageImporterSpec.php +++ b/spec/Importer/PageImporterSpec.php @@ -27,16 +27,16 @@ final class PageImporterSpec extends ObjectBehavior { public function let( - ResourceResolverInterface $pageResourceResolver, - LocaleContextInterface $localeContext, - ImageDownloaderInterface $imageDownloader, - FactoryInterface $mediaFactory, - MediaProviderResolverInterface $mediaProviderResolver, + ResourceResolverInterface $pageResourceResolver, + LocaleContextInterface $localeContext, + ImageDownloaderInterface $imageDownloader, + FactoryInterface $mediaFactory, + MediaProviderResolverInterface $mediaProviderResolver, ImporterCollectionsResolverInterface $importerCollectionsResolver, - ImporterChannelsResolverInterface $importerChannelsResolver, - ImporterProductsResolverInterface $importerProductsResolver, - ValidatorInterface $validator, - EntityManagerInterface $entityManager + ImporterChannelsResolverInterface $importerChannelsResolver, + ImporterProductsResolverInterface $importerProductsResolver, + ValidatorInterface $validator, + EntityManagerInterface $entityManager ) { $this->beConstructedWith( $pageResourceResolver, @@ -59,15 +59,16 @@ public function it_is_initializable() } public function it_imports_page_no_url( - ResourceResolverInterface $pageResourceResolver, - LocaleContextInterface $localeContext, + ResourceResolverInterface $pageResourceResolver, + LocaleContextInterface $localeContext, ImporterCollectionsResolverInterface $importerCollectionsResolver, - ImporterChannelsResolverInterface $importerChannelsResolver, - ImporterProductsResolverInterface $importerProductsResolver, - ValidatorInterface $validator, - EntityManagerInterface $entityManager, - PageInterface $page, - ) { + ImporterChannelsResolverInterface $importerChannelsResolver, + ImporterProductsResolverInterface $importerProductsResolver, + ValidatorInterface $validator, + EntityManagerInterface $entityManager, + PageInterface $page, + ) + { $row = [ 'code' => 'page_code', 'slug_pl' => 'slug', diff --git a/spec/Resolver/ImporterCollectionsResolverSpec.php b/spec/Resolver/ImporterCollectionsResolverSpec.php index bb701891f..7bf04650b 100644 --- a/spec/Resolver/ImporterCollectionsResolverSpec.php +++ b/spec/Resolver/ImporterCollectionsResolverSpec.php @@ -30,7 +30,7 @@ public function it_is_initializable() public function it_resolves_collections_for_collectionable_entity( CollectionsAssignerInterface $collectionsAssigner, - CollectionableInterface $collectionable + CollectionableInterface $collectionable ) { $collectionsRow = 'collection1, collection2, collection3'; $collectionsCodes = ['collection1', 'collection2', 'collection3']; @@ -42,7 +42,7 @@ public function it_resolves_collections_for_collectionable_entity( public function it_skips_resolution_when_collections_row_is_null( CollectionsAssignerInterface $collectionsAssigner, - CollectionableInterface $collectionable + CollectionableInterface $collectionable ) { $collectionsRow = null; diff --git a/spec/Twig/Runtime/RenderProductPagesRuntimeSpec.php b/spec/Twig/Runtime/RenderProductPagesRuntimeSpec.php index cb761020b..80f4b8a71 100644 --- a/spec/Twig/Runtime/RenderProductPagesRuntimeSpec.php +++ b/spec/Twig/Runtime/RenderProductPagesRuntimeSpec.php @@ -47,13 +47,13 @@ public function it_implements_render_product_pages_runtime_interface(): void } public function it_renders_product_pages( - ChannelContextInterface $channelContext, - ProductInterface $product, - ChannelInterface $channel, - PageRepositoryInterface $pageRepository, - PageInterface $page, - CollectionInterface $collection, - Environment $templatingEngine, + ChannelContextInterface $channelContext, + ProductInterface $product, + ChannelInterface $channel, + PageRepositoryInterface $pageRepository, + PageInterface $page, + CollectionInterface $collection, + Environment $templatingEngine, CollectionsSorterInterface $collectionsSorter ): void { $channel->getCode()->willReturn('WEB'); @@ -68,13 +68,13 @@ public function it_renders_product_pages( } public function it_renders_product_pages_with_collections( - ChannelContextInterface $channelContext, - ProductInterface $product, - ChannelInterface $channel, - PageRepositoryInterface $pageRepository, - PageInterface $page, - CollectionInterface $collection, - Environment $templatingEngine, + ChannelContextInterface $channelContext, + ProductInterface $product, + ChannelInterface $channel, + PageRepositoryInterface $pageRepository, + PageInterface $page, + CollectionInterface $collection, + Environment $templatingEngine, CollectionsSorterInterface $collectionsSorter ): void { $channel->getCode()->willReturn('WEB'); diff --git a/src/Entity/Block.php b/src/Entity/Block.php index 277940816..2037d6cec 100755 --- a/src/Entity/Block.php +++ b/src/Entity/Block.php @@ -17,7 +17,7 @@ class Block implements BlockInterface { use ToggleableTrait; - use CollectionableTrait; + use CollectibleTrait; use ProductsAwareTrait; use TaxonAwareTrait; use ChannelsAwareTrait; diff --git a/src/Entity/CollectionableTrait.php b/src/Entity/CollectibleTrait.php similarity index 98% rename from src/Entity/CollectionableTrait.php rename to src/Entity/CollectibleTrait.php index 0e4f7c0e4..32acfe1fb 100755 --- a/src/Entity/CollectionableTrait.php +++ b/src/Entity/CollectibleTrait.php @@ -13,7 +13,7 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; -trait CollectionableTrait +trait CollectibleTrait { protected Collection $collections; diff --git a/src/Entity/Collection.php b/src/Entity/Collection.php index f6a456535..485e3d77f 100755 --- a/src/Entity/Collection.php +++ b/src/Entity/Collection.php @@ -15,9 +15,9 @@ class Collection implements CollectionInterface { - use PageableTrait; + use PagesCollectionTrait; use BlockableTrait; - use MediableTrait; + use MediaCollectionTrait; use TranslatableTrait { __construct as private initializeTranslationsCollection; } diff --git a/src/Entity/CollectionInterface.php b/src/Entity/CollectionInterface.php index 31aa7e5ce..57274d430 100755 --- a/src/Entity/CollectionInterface.php +++ b/src/Entity/CollectionInterface.php @@ -16,7 +16,7 @@ interface CollectionInterface extends ResourceInterface, TranslatableInterface, - PageableInterface, + PagesCollectionInterface, BlockableInterface, MediableInterface { diff --git a/src/Entity/Media.php b/src/Entity/Media.php index 4cdc28aaa..c7ddfc705 100644 --- a/src/Entity/Media.php +++ b/src/Entity/Media.php @@ -20,7 +20,7 @@ class Media implements MediaInterface { use ToggleableTrait; - use CollectionableTrait; + use CollectibleTrait; use ProductsAwareTrait; use ChannelsAwareTrait; use TranslatableTrait { diff --git a/src/Entity/MediableTrait.php b/src/Entity/MediaCollectionTrait.php similarity index 97% rename from src/Entity/MediableTrait.php rename to src/Entity/MediaCollectionTrait.php index 92c311cee..cddb1b4ad 100644 --- a/src/Entity/MediableTrait.php +++ b/src/Entity/MediaCollectionTrait.php @@ -13,7 +13,7 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; -trait MediableTrait +trait MediaCollectionTrait { protected Collection $media; diff --git a/src/Entity/Page.php b/src/Entity/Page.php index e23180d22..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 CollectionableTrait; + use CollectibleTrait; use TimestampableTrait; use ChannelsAwareTrait; use TranslatableTrait { diff --git a/src/Entity/PageableInterface.php b/src/Entity/PagesCollectionInterface.php similarity index 95% rename from src/Entity/PageableInterface.php rename to src/Entity/PagesCollectionInterface.php index 6271fbbb5..bd09893f9 100644 --- a/src/Entity/PageableInterface.php +++ b/src/Entity/PagesCollectionInterface.php @@ -12,7 +12,7 @@ use Doctrine\Common\Collections\Collection; -interface PageableInterface +interface PagesCollectionInterface { public function initializePagesCollection(): void; diff --git a/src/Entity/PageableTrait.php b/src/Entity/PagesCollectionTrait.php similarity index 97% rename from src/Entity/PageableTrait.php rename to src/Entity/PagesCollectionTrait.php index 67abcdc0a..97f7e751c 100644 --- a/src/Entity/PageableTrait.php +++ b/src/Entity/PagesCollectionTrait.php @@ -13,7 +13,7 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; -trait PageableTrait +trait PagesCollectionTrait { protected Collection $pages; diff --git a/tests/Integration/Repository/CollectionRepositoryTest.php b/tests/Integration/Repository/CollectionRepositoryTest.php index 749c0b486..3e8710194 100644 --- a/tests/Integration/Repository/CollectionRepositoryTest.php +++ b/tests/Integration/Repository/CollectionRepositoryTest.php @@ -16,7 +16,7 @@ use BitBag\SyliusCmsPlugin\Repository\CollectionRepositoryInterface; use Doctrine\ORM\QueryBuilder; -class CollectionRepositoryTest extends JsonApiTestCase +final class CollectionRepositoryTest extends JsonApiTestCase { public function setUp(): void { From 5431c2e3db299fae6961b77d1b37e37c4399e5e3 Mon Sep 17 00:00:00 2001 From: jkindly Date: Tue, 25 Jun 2024 09:48:02 +0200 Subject: [PATCH 25/25] OP-320: PR fixes --- spec/Assigner/CollectionsAssignerSpec.php | 4 ++-- spec/Resolver/ImporterCollectionsResolverSpec.php | 6 +++--- src/Assigner/CollectionsAssigner.php | 4 ++-- src/Assigner/CollectionsAssignerInterface.php | 4 ++-- src/Entity/BlockInterface.php | 2 +- ...BlockableInterface.php => BlocksCollectionInterface.php} | 2 +- .../{BlockableTrait.php => BlocksCollectionTrait.php} | 2 +- ...CollectionableInterface.php => CollectibleInterface.php} | 2 +- src/Entity/Collection.php | 2 +- src/Entity/CollectionInterface.php | 4 ++-- .../{MediableInterface.php => MediaCollectionInterface.php} | 2 +- src/Entity/MediaInterface.php | 2 +- src/Entity/PageInterface.php | 2 +- src/Resolver/ImporterCollectionsResolver.php | 4 ++-- src/Resolver/ImporterCollectionsResolverInterface.php | 4 ++-- 15 files changed, 23 insertions(+), 23 deletions(-) rename src/Entity/{BlockableInterface.php => BlocksCollectionInterface.php} (95%) rename src/Entity/{BlockableTrait.php => BlocksCollectionTrait.php} (97%) rename src/Entity/{CollectionableInterface.php => CollectibleInterface.php} (96%) rename src/Entity/{MediableInterface.php => MediaCollectionInterface.php} (95%) diff --git a/spec/Assigner/CollectionsAssignerSpec.php b/spec/Assigner/CollectionsAssignerSpec.php index bfbfd29d0..898ad2de7 100644 --- a/spec/Assigner/CollectionsAssignerSpec.php +++ b/spec/Assigner/CollectionsAssignerSpec.php @@ -12,7 +12,7 @@ use BitBag\SyliusCmsPlugin\Assigner\CollectionsAssigner; use BitBag\SyliusCmsPlugin\Assigner\CollectionsAssignerInterface; -use BitBag\SyliusCmsPlugin\Entity\CollectionableInterface; +use BitBag\SyliusCmsPlugin\Entity\CollectibleInterface; use BitBag\SyliusCmsPlugin\Entity\CollectionInterface; use BitBag\SyliusCmsPlugin\Repository\CollectionRepositoryInterface; use PhpSpec\ObjectBehavior; @@ -38,7 +38,7 @@ public function it_assigns_collections( CollectionRepositoryInterface $collectionRepository, CollectionInterface $aboutCollection, CollectionInterface $blogCollection, - CollectionableInterface $collectionsAware + CollectibleInterface $collectionsAware ): void { $collectionRepository->findOneBy(['code' => 'about'])->willReturn($aboutCollection); diff --git a/spec/Resolver/ImporterCollectionsResolverSpec.php b/spec/Resolver/ImporterCollectionsResolverSpec.php index 7bf04650b..50568efdb 100644 --- a/spec/Resolver/ImporterCollectionsResolverSpec.php +++ b/spec/Resolver/ImporterCollectionsResolverSpec.php @@ -11,7 +11,7 @@ namespace spec\BitBag\SyliusCmsPlugin\Resolver; use BitBag\SyliusCmsPlugin\Assigner\CollectionsAssignerInterface; -use BitBag\SyliusCmsPlugin\Entity\CollectionableInterface; +use BitBag\SyliusCmsPlugin\Entity\CollectibleInterface; use BitBag\SyliusCmsPlugin\Resolver\ImporterCollectionsResolver; use PhpSpec\ObjectBehavior; use Prophecy\Argument; @@ -30,7 +30,7 @@ public function it_is_initializable() public function it_resolves_collections_for_collectionable_entity( CollectionsAssignerInterface $collectionsAssigner, - CollectionableInterface $collectionable + CollectibleInterface $collectionable ) { $collectionsRow = 'collection1, collection2, collection3'; $collectionsCodes = ['collection1', 'collection2', 'collection3']; @@ -42,7 +42,7 @@ public function it_resolves_collections_for_collectionable_entity( public function it_skips_resolution_when_collections_row_is_null( CollectionsAssignerInterface $collectionsAssigner, - CollectionableInterface $collectionable + CollectibleInterface $collectionable ) { $collectionsRow = null; diff --git a/src/Assigner/CollectionsAssigner.php b/src/Assigner/CollectionsAssigner.php index 4cb237ecd..808f4dd61 100644 --- a/src/Assigner/CollectionsAssigner.php +++ b/src/Assigner/CollectionsAssigner.php @@ -10,7 +10,7 @@ namespace BitBag\SyliusCmsPlugin\Assigner; -use BitBag\SyliusCmsPlugin\Entity\CollectionableInterface; +use BitBag\SyliusCmsPlugin\Entity\CollectibleInterface; use BitBag\SyliusCmsPlugin\Entity\CollectionInterface; use BitBag\SyliusCmsPlugin\Repository\CollectionRepositoryInterface; use Webmozart\Assert\Assert; @@ -21,7 +21,7 @@ public function __construct(private CollectionRepositoryInterface $collectionRep { } - public function assign(CollectionableInterface $collectionsAware, array $collectionsCodes): void + public function assign(CollectibleInterface $collectionsAware, array $collectionsCodes): void { foreach ($collectionsCodes as $collectionCode) { /** @var CollectionInterface|null $collection */ diff --git a/src/Assigner/CollectionsAssignerInterface.php b/src/Assigner/CollectionsAssignerInterface.php index 860b3b8d0..7ad276981 100644 --- a/src/Assigner/CollectionsAssignerInterface.php +++ b/src/Assigner/CollectionsAssignerInterface.php @@ -10,9 +10,9 @@ namespace BitBag\SyliusCmsPlugin\Assigner; -use BitBag\SyliusCmsPlugin\Entity\CollectionableInterface; +use BitBag\SyliusCmsPlugin\Entity\CollectibleInterface; interface CollectionsAssignerInterface { - public function assign(CollectionableInterface $collectionsAware, array $collectionsCodes): void; + public function assign(CollectibleInterface $collectionsAware, array $collectionsCodes): void; } diff --git a/src/Entity/BlockInterface.php b/src/Entity/BlockInterface.php index e8a9d313e..8289d2fbc 100755 --- a/src/Entity/BlockInterface.php +++ b/src/Entity/BlockInterface.php @@ -21,7 +21,7 @@ interface BlockInterface extends ToggleableInterface, ProductsAwareInterface, TaxonAwareInterface, - CollectionableInterface, + CollectibleInterface, ChannelsAwareInterface, ContentableInterface { diff --git a/src/Entity/BlockableInterface.php b/src/Entity/BlocksCollectionInterface.php similarity index 95% rename from src/Entity/BlockableInterface.php rename to src/Entity/BlocksCollectionInterface.php index 477443bbc..f6fcd828d 100644 --- a/src/Entity/BlockableInterface.php +++ b/src/Entity/BlocksCollectionInterface.php @@ -12,7 +12,7 @@ use Doctrine\Common\Collections\Collection; -interface BlockableInterface +interface BlocksCollectionInterface { public function initializeBlocksCollection(): void; diff --git a/src/Entity/BlockableTrait.php b/src/Entity/BlocksCollectionTrait.php similarity index 97% rename from src/Entity/BlockableTrait.php rename to src/Entity/BlocksCollectionTrait.php index d74cc55eb..71bf4c78b 100644 --- a/src/Entity/BlockableTrait.php +++ b/src/Entity/BlocksCollectionTrait.php @@ -13,7 +13,7 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; -trait BlockableTrait +trait BlocksCollectionTrait { protected Collection $blocks; diff --git a/src/Entity/CollectionableInterface.php b/src/Entity/CollectibleInterface.php similarity index 96% rename from src/Entity/CollectionableInterface.php rename to src/Entity/CollectibleInterface.php index 2fec26479..106ae7f0d 100755 --- a/src/Entity/CollectionableInterface.php +++ b/src/Entity/CollectibleInterface.php @@ -12,7 +12,7 @@ use Doctrine\Common\Collections\Collection; -interface CollectionableInterface +interface CollectibleInterface { public function initializeCollectionsCollection(): void; diff --git a/src/Entity/Collection.php b/src/Entity/Collection.php index 485e3d77f..d80c7b599 100755 --- a/src/Entity/Collection.php +++ b/src/Entity/Collection.php @@ -16,7 +16,7 @@ class Collection implements CollectionInterface { use PagesCollectionTrait; - use BlockableTrait; + use BlocksCollectionTrait; use MediaCollectionTrait; use TranslatableTrait { __construct as private initializeTranslationsCollection; diff --git a/src/Entity/CollectionInterface.php b/src/Entity/CollectionInterface.php index 57274d430..1eef9d2d9 100755 --- a/src/Entity/CollectionInterface.php +++ b/src/Entity/CollectionInterface.php @@ -17,8 +17,8 @@ interface CollectionInterface extends ResourceInterface, TranslatableInterface, PagesCollectionInterface, - BlockableInterface, - MediableInterface + BlocksCollectionInterface, + MediaCollectionInterface { public function getCode(): ?string; diff --git a/src/Entity/MediableInterface.php b/src/Entity/MediaCollectionInterface.php similarity index 95% rename from src/Entity/MediableInterface.php rename to src/Entity/MediaCollectionInterface.php index b4fc57f15..45c1dd98e 100644 --- a/src/Entity/MediableInterface.php +++ b/src/Entity/MediaCollectionInterface.php @@ -12,7 +12,7 @@ use Doctrine\Common\Collections\Collection; -interface MediableInterface +interface MediaCollectionInterface { public function initializeMediaCollection(): void; diff --git a/src/Entity/MediaInterface.php b/src/Entity/MediaInterface.php index c189a95d8..83478d68a 100644 --- a/src/Entity/MediaInterface.php +++ b/src/Entity/MediaInterface.php @@ -21,7 +21,7 @@ interface MediaInterface extends TranslatableInterface, ToggleableInterface, ProductsAwareInterface, - CollectionableInterface, + CollectibleInterface, ChannelsAwareInterface, ContentableInterface { diff --git a/src/Entity/PageInterface.php b/src/Entity/PageInterface.php index 23e7b38d4..b154afd76 100755 --- a/src/Entity/PageInterface.php +++ b/src/Entity/PageInterface.php @@ -22,7 +22,7 @@ interface PageInterface extends TranslatableInterface, ToggleableInterface, ProductsAwareInterface, - CollectionableInterface, + CollectibleInterface, TimestampableInterface, ChannelsAwareInterface, ContentableInterface, diff --git a/src/Resolver/ImporterCollectionsResolver.php b/src/Resolver/ImporterCollectionsResolver.php index 3f90be302..d803ecebc 100644 --- a/src/Resolver/ImporterCollectionsResolver.php +++ b/src/Resolver/ImporterCollectionsResolver.php @@ -11,7 +11,7 @@ namespace BitBag\SyliusCmsPlugin\Resolver; use BitBag\SyliusCmsPlugin\Assigner\CollectionsAssignerInterface; -use BitBag\SyliusCmsPlugin\Entity\CollectionableInterface; +use BitBag\SyliusCmsPlugin\Entity\CollectibleInterface; final class ImporterCollectionsResolver implements ImporterCollectionsResolverInterface { @@ -19,7 +19,7 @@ public function __construct(private CollectionsAssignerInterface $collectionsAss { } - public function resolve(CollectionableInterface $collectionable, ?string $collectionsRow): void + public function resolve(CollectibleInterface $collectionable, ?string $collectionsRow): void { if (null === $collectionsRow) { return; diff --git a/src/Resolver/ImporterCollectionsResolverInterface.php b/src/Resolver/ImporterCollectionsResolverInterface.php index 6484167aa..23c931e95 100644 --- a/src/Resolver/ImporterCollectionsResolverInterface.php +++ b/src/Resolver/ImporterCollectionsResolverInterface.php @@ -10,9 +10,9 @@ namespace BitBag\SyliusCmsPlugin\Resolver; -use BitBag\SyliusCmsPlugin\Entity\CollectionableInterface; +use BitBag\SyliusCmsPlugin\Entity\CollectibleInterface; interface ImporterCollectionsResolverInterface { - public function resolve(CollectionableInterface $collectionable, ?string $collectionsRow): void; + public function resolve(CollectibleInterface $collectionable, ?string $collectionsRow): void; }