diff --git a/README.md b/README.md index 25008c6c2..519b71d48 100755 --- a/README.md +++ b/README.md @@ -1,126 +1,47 @@ # [![](https://bitbag.io/wp-content/uploads/2021/01/CMS.png)](https://bitbag.io/contact-us/?utm_source=github&utm_medium=referral&utm_campaign=plugins_cms) -# BitBag SyliusCMSPlugin +# SyliusCMSPlugin ---- [![](https://img.shields.io/packagist/l/bitbag/cms-plugin.svg) ](https://packagist.org/packages/bitbag/cms-plugin "License") [ ![](https://img.shields.io/packagist/v/bitbag/cms-plugin.svg) ](https://packagist.org/packages/bitbag/cms-plugin "Version") [ ![](https://img.shields.io/github/actions/workflow/status/BitBagCommerce/SyliusCmsPlugin/build.yml) ](https://github.com/BitBagCommerce/SyliusCmsPlugin/actions "Build status") [ ![](https://img.shields.io/scrutinizer/g/BitBagCommerce/SyliusCMSPlugin.svg) ](https://scrutinizer-ci.com/g/BitBagCommerce/SyliusCMSPlugin/ "Scrutinizer") [![](https://poser.pugx.org/bitbag/cms-plugin/downloads)](https://packagist.org/packages/bitbag/cms-plugin "Total Downloads") [![Slack](https://img.shields.io/badge/community%20chat-slack-FF1493.svg)](http://sylius-devs.slack.com) [![Support](https://img.shields.io/badge/support-contact%20author-blue])](https://bitbag.io/contact-us/?utm_source=github&utm_medium=referral&utm_campaign=plugins_cms) -

- -

- -At BitBag we do believe in open source. However, we are able to do it just because of our awesome clients, who are kind enough to share some parts of our work with the community. Therefore, if you feel like there is a possibility for us to work together, feel free to reach out. You will find out more about our professional services, technologies, and contact details at [https://bitbag.io/](https://bitbag.io/contact-us/?utm_source=github&utm_medium=referral&utm_campaign=plugins_cms). - -Like what we do? Want to join us? Check out our job listings on our [career page](https://bitbag.io/career/?utm_source=github&utm_medium=referral&utm_campaign=career). Not familiar with Symfony & Sylius yet, but still want to start with us? Join our [academy](https://bitbag.io/pl/akademia?utm_source=github&utm_medium=url&utm_campaign=akademia)! - -## Table of Content - -*** - -* [Overview](#overview) -* [Support](#we-are-here-to-help) -* [About us](#about-us) - * [Community](#community) -* [Demo](#demo-sylius-shop) -* [License](#license) -* [Contact](#contact) - # Overview *** -Almost every eCommerce app has to present some content. Managing it is often done via third-party libraries like WordPress, eZ Platform, or a built-in content management system. As Sylius does not have a CMS in the standard platform, we decided to develop our own, which will be as flexible as Sylius. This plugin allows you to add dynamic blocks with images, text or HTML to your storefront, as well as pages and FAQs section. - +Almost every eCommerce app has to present some content. Managing it is often done via third-party libraries like WordPress, +eZ Platform, or a built-in content management system. As Sylius does not have a CMS in the standard platform, +we decided to develop our own, which will be as flexible as Sylius. This plugin allows you to add dynamic blocks and pages +with content elements to your storefront. - [Use Case](doc/use_case.md) + - [Collections](doc/use_case_collections.md) + - [Content Templates](doc/use_case_content_templates.md) + - [Pages](doc/use_case_pages.md) + - [Blocks](doc/use_case_blocks.md) + - [Media](doc/use_case_media.md) - [Installation](doc/installation.md) - [Upgrading](UPGRADE.md) -- [Blocks](doc/blocks.md) +- [Collections](doc/collections.md) +- [Content Templates](doc/content_templates.md) - [Pages](doc/pages.md) -- [Sections](doc/sections.md) +- [Blocks](doc/blocks.md) +- [Page/Block templates](doc/templates.md) - [Media](doc/media.md) -- [FAQs](doc/faqs.md) - [Fixtures](doc/fixtures.md) - [WYSIWYG](doc/wysiwyg.md) - [Importing resources](doc/importing-resources.md) -- [Using Twig functions in the admin panel](doc/twig-functions-in-admin.md) +- [Legacy data migration](doc/legacy_data_migration.md) - [Sitemap](doc/sitemap.md) - [Customization](doc/customization.md) -## We are here to help -This **open-source plugin was developed to help the Sylius community**. If you have any additional questions, would like help with installing or configuring the plugin, or need any assistance with your Sylius project - let us know! - -[![](https://bitbag.io/wp-content/uploads/2020/10/button-contact.png)](https://bitbag.io/contact-us/?utm_source=github&utm_medium=referral&utm_campaign=plugins_cms) - -Read more about [Sylius CMS](https://bitbag.io/sylius-cms-all-you-need-to-know-3-implementation-methods/?utm_source=github&utm_medium=referral&utm_campaign=plugins_cms) - -# About us - ---- - -BitBag is a company of people who **love what they do** and do it right. We fulfill the eCommerce technology stack with **Sylius**, Shopware, Akeneo, and Pimcore for PIM, eZ Platform for CMS, and VueStorefront for PWA. Our goal is to provide real digital transformation with an agile solution that scales with the **clients’ needs**. Our main area of expertise includes eCommerce consulting and development for B2C, B2B, and Multi-vendor Marketplaces.
-We are advisers in the first place. We start each project with a diagnosis of problems, and an analysis of the needs and **goals** that the client wants to achieve.
-We build **unforgettable**, consistent digital customer journeys on top of the **best technologies**. Based on a detailed analysis of the goals and needs of a given organization, we create dedicated systems and applications that let businesses grow.
-Our team is fluent in **Polish, English, German and, French**. That is why our cooperation with clients from all over the world is smooth. - -**Some numbers from BitBag regarding Sylius:** - - 50+ **experts** including consultants, UI/UX designers, Sylius trained front-end and back-end developers, - - 120+ projects **delivered** on top of Sylius, - - 25+ **countries** of BitBag’s customers, - - 4+ **years** in the Sylius ecosystem. - -**Our services:** - - Business audit/Consulting in the field of **strategy** development, - - Data/shop **migration**, - - Headless **eCommerce**, - - Personalized **software** development, - - **Project** maintenance and long term support, - - Technical **support**. - -**Key clients:** Mollie, Guave, P24, Folkstar, i-LUNCH, Elvi Project, WestCoast Gifts. - ---- - -If you need some help with Sylius development, don't be hesitated to contact us directly. You can fill the form on [this site](https://bitbag.io/contact-us/?utm_source=github&utm_medium=referral&utm_campaign=plugins_cms) or send us an e-mail at hello@bitbag.io! - ---- - -[![](https://bitbag.io/wp-content/uploads/2021/08/sylius-badges-transparent-wide.png)](https://bitbag.io/contact-us/?utm_source=github&utm_medium=referral&utm_campaign=plugins_cms) - ## Community ---- For online communication, we invite you to chat with us & other users on [Sylius Slack](https://sylius-devs.slack.com/). -# Demo Sylius Shop - ---- - -We created a demo app with some useful use-cases of plugins! -Visit [sylius-demo.bitbag.io](https://sylius-demo.bitbag.io/) to take a look at it. The admin can be accessed under -[sylius-demo.bitbag.io/admin/login](https://sylius-demo.bitbag.io/admin/login) link and `bitbag: bitbag` credentials. -Plugins that we have used in the demo: - -| BitBag's Plugin | GitHub | Sylius' Store| -| ------ | ------ | ------| -| ACL Plugin | *Private. Available after the purchasing.*| https://plugins.sylius.com/plugin/access-control-layer-plugin/| -| Braintree Plugin | https://github.com/BitBagCommerce/SyliusBraintreePlugin |https://plugins.sylius.com/plugin/braintree-plugin/| -| CMS Plugin | https://github.com/BitBagCommerce/SyliusCmsPlugin | https://plugins.sylius.com/plugin/cmsplugin/| -| Elasticsearch Plugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin | https://plugins.sylius.com/plugin/2004/| -| Mailchimp Plugin | https://github.com/BitBagCommerce/SyliusMailChimpPlugin | https://plugins.sylius.com/plugin/mailchimp/ | -| Multisafepay Plugin | https://github.com/BitBagCommerce/SyliusMultiSafepayPlugin | -| Wishlist Plugin | https://github.com/BitBagCommerce/SyliusWishlistPlugin | https://plugins.sylius.com/plugin/wishlist-plugin/| -| **Sylius' Plugin** | **GitHub** | **Sylius' Store** | -| Admin Order Creation Plugin | https://github.com/Sylius/AdminOrderCreationPlugin | https://plugins.sylius.com/plugin/admin-order-creation-plugin/ | -| Invoicing Plugin | https://github.com/Sylius/InvoicingPlugin | https://plugins.sylius.com/plugin/invoicing-plugin/ | -| Refund Plugin | https://github.com/Sylius/RefundPlugin | https://plugins.sylius.com/plugin/refund-plugin/ | - -**If you need an overview of Sylius' capabilities, schedule a consultation with our expert.** - -[![](https://bitbag.io/wp-content/uploads/2020/10/button_free_consulatation-1.png)](https://bitbag.io/contact-us/?utm_source=github&utm_medium=referral&utm_campaign=plugins_cms) - ## Additional resources for developers --- @@ -137,10 +58,3 @@ To learn more about our contribution workflow and more, we encourage you to use This plugin's source code is completely free and released under the terms of the MIT license. [//]: # (These are reference links used in the body of this note and get stripped out when the markdown processor does its job. There is no need to format nicely because it shouldn't be seen.) - -## Contact - ---- -If you want to contact us, the best way is to fill the form on [our website](https://bitbag.io/contact-us/?utm_source=github&utm_medium=referral&utm_campaign=plugins_cms) or send us an e-mail to hello@bitbag.io with your question(s). We guarantee that we answer as soon as we can! - -[![](https://bitbag.io/wp-content/uploads/2021/08/badges-bitbag.png)](https://bitbag.io/contact-us/?utm_source=github&utm_medium=referral&utm_campaign=plugins_cms) diff --git a/UPGRADE-5.0.md b/UPGRADE-5.0.md new file mode 100644 index 000000000..1509e0965 --- /dev/null +++ b/UPGRADE-5.0.md @@ -0,0 +1,105 @@ +# UPGRADE FROM 4.2 TO 5.0 + +This upgrade is a major one, as it introduces a new feature - [Content Elements](doc/content_elements.md) +and removes the old way of creating blocks and pages. + +* A lot of database modifications has been made. Read the below changelog first and then migrate your structure using + `bin/console doctrine:migrations:diff && bin/console doctrine:migrations:migrate` commands. +* Sections are now Collections, as it was a more suitable name for the feature. +* Pages and Blocks now have `Content elements` segment, where you can add elements to the page or block. +* Removed FAQ, as you can now create a FAQ page with the new content elements. +* Added new `Content Templates` section where you can create templates for your content elements. Read more about it in [Use case content templates](doc/use_case_content_templates.md) +and [Content Templates](doc/content_templates.md) docs. +* Removed CKEditor deprecation modal. +* Reordered forms/elements for functionality consistency. +* Updated import functionality to work with the new structure. +* Updated fixtures to work with the new structure +* Removed `sylius_cms_render_product_pages` twig extension. +* Removed support for rendering twig functions in WYSIWYG editor. +* Added twig extensions: + * `sylius_cms_render_collection` + * `sylius_cms_render_content_elements` + +## Briefly about Content Elements + +Content elements is a new segment in the block/page form where you can add elements that will be rendered on the store's frontend, like: +* Textarea +* Heading +* Images +* Products carousel +* etc. + +> Read more about the content elements in the updated [Content elements](doc/content_elements.md) doc. + +## Changes in Collections (old Sections) + +### Added fields: + +* Type +* Pages/Block/Media (depending on the chosen type) + +### Moved fields: + +* Name field has been moved from translations to the main settings tab + +> Read more about the collections in the updated [Use case collections](doc/use_case_collections.md) and [Collections](doc/collections.md) docs. + +## Changes in Pages + +### Removed fields: + +* Products +* Breadcrumb +* Name when linked +* Description when linked +* Image +* Content +* Title + +### Added fields + +* Teaser title +* Teaser content +* Teaser image + +### Moved fields + +* Name field has been moved from translations to the main settings tab + +> Read more about the pages in the updated [Use case pages](doc/use_case_pages.md) and [Pages](doc/pages.md) docs. + +## Changes in Blocks + +### Removed fields: + +* Products +* Taxons +* Whole translations tab + +### Added fields + +* Name +* Locales +* Display for products +* Display for products in taxons +* Display for taxons + +> Read more about the blocks in the updated [Use case blocks](doc/use_case_blocks.md) and [Blocks](doc/blocks.md) docs. + +## Changes in Media + +### Removed fields: + +* Products + +### Added fields + +* Media preview with path + +### Moved fields + +* Name field has been moved from translations to the main settings tab + +### Renamed fields + +* Content -> Link content diff --git a/UPGRADE.md b/UPGRADE.md index 0e3db3428..b04679a0c 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -19,7 +19,7 @@ structure using `bin/console doctrine:migrations:diff && bin/console doctrine:mi use raw content in [WYSIWYG editor](doc/wysiwyg.md) * Chanel awareness has been added to pages, blocks, FAQs, sections and media. That being said, many repository methods changed their signatures. In case you customized them in your src, check -new signatures in interfaces under [BitBag\SyliusCmsPlugin\Repository](src/Repository) namespace +new signatures in interfaces under [Sylius\CmsPlugin\Repository](src/Repository) namespace * WYSIWYG editor has been introduced. You will need to import it in your AppKernel and install its assets. For more, check the [installation guide](doc/installation.md) * Sitemap support was added, you will need to enable extra bundle in your AppKernel. Read more diff --git a/behat.yml.dist b/behat.yml.dist index 6c02a541e..b3bfe96cc 100755 --- a/behat.yml.dist +++ b/behat.yml.dist @@ -47,7 +47,7 @@ default: FriendsOfBehat\SymfonyExtension: bootstrap: tests/Application/config/bootstrap.php kernel: - class: Tests\BitBag\SyliusCmsPlugin\Application\Kernel + class: Tests\Sylius\CmsPlugin\Application\Kernel FriendsOfBehat\VariadicExtension: ~ diff --git a/composer.json b/composer.json index 6f32f2416..4d334066f 100644 --- a/composer.json +++ b/composer.json @@ -9,11 +9,10 @@ "description": "CMS plugin for Sylius applications.", "license": "MIT", "require": { - "php": "^8.0", + "php": "^8.1", "sylius/sylius": "^1.12.0 || ^1.13.0", "league/csv": "^9.1", "friendsofsymfony/ckeditor-bundle": "^2.0", - "instaclick/php-webdriver": "^1.4", "symfony/webpack-encore-bundle": "^1.12" }, "require-dev": { @@ -31,6 +30,7 @@ "friends-of-behat/suite-settings-extension": "^1.0", "friends-of-behat/symfony-extension": "^2.1", "friends-of-behat/variadic-extension": "^1.3", + "instaclick/php-webdriver": "^1.4", "lchrusciel/api-test-case": "^4.1 || ^5.0", "matthiasnoback/symfony-config-test": "^5.1", "phpspec/phpspec": "^7.2", @@ -51,26 +51,19 @@ "symfony/runtime": "^5.4 || ^6.4", "symfony/web-profiler-bundle": "^5.4 || ^6.4" }, - "conflict": { - "symfony/symfony": "4.1.8", - "symfony/browser-kit": "4.1.8", - "symfony/dom-crawler": "4.1.8", - "symfony/routing": "4.1.8", - "symfony/doctrine-bridge": "4.4.16" - }, "suggest": { - "stefandoorn/sitemap-plugin": "^2.0@alpha" + "stefandoorn/sitemap-plugin": "^2.2" }, "prefer-stable": true, "autoload": { "psr-4": { - "BitBag\\SyliusCmsPlugin\\": "src/", - "Tests\\BitBag\\SyliusCmsPlugin\\": "tests/" + "Sylius\\CmsPlugin\\": "src/", + "Tests\\Sylius\\CmsPlugin\\": "tests/" } }, "autoload-dev": { "psr-4": { - "spec\\BitBag\\SyliusCmsPlugin\\": "spec/" + "spec\\Sylius\\CmsPlugin\\": "spec/" }, "classmap": ["tests/Application/Kernel.php"] }, diff --git a/doc/01.1-webpack-config.md b/doc/01.1-webpack-config.md index 8f2858c77..5252c5524 100644 --- a/doc/01.1-webpack-config.md +++ b/doc/01.1-webpack-config.md @@ -1,4 +1,4 @@ -# BitBag SyliusCmsPlugin +# SyliusCmsPlugin - [⬅️ Back](./installation.md) @@ -13,10 +13,10 @@ ```js // webpack.config.js -const [ bitbagCmsShop, bitbagCmsAdmin ] = require('./vendor/bitbag/cms-plugin/webpack.config.js') +const [ cmsShop, cmsAdmin ] = require('./vendor/bitbag/cms-plugin/webpack.config.js') ... -module.exports = [..., bitbagCmsShop, bitbagCmsAdmin]; +module.exports = [..., cmsShop, cmsAdmin]; ``` 2. Add new packages in `./config/packages/assets.yaml` @@ -29,9 +29,9 @@ framework: packages: # ... cms_shop: - json_manifest_path: '%kernel.project_dir%/public/build/bitbag/cms/shop/manifest.json' + json_manifest_path: '%kernel.project_dir%/public/build/cms/shop/manifest.json' cms_admin: - json_manifest_path: '%kernel.project_dir%/public/build/bitbag/cms/admin/manifest.json' + json_manifest_path: '%kernel.project_dir%/public/build/cms/admin/manifest.json' ``` 3. Add new build paths in `./config/packages/webpack_encore.yml` @@ -42,24 +42,24 @@ framework: webpack_encore: builds: # ... - cms_shop: '%kernel.project_dir%/public/build/bitbag/cms/shop' - cms_admin: '%kernel.project_dir%/public/build/bitbag/cms/admin' + cms_shop: '%kernel.project_dir%/public/build/cms/shop' + cms_admin: '%kernel.project_dir%/public/build/cms/admin' ``` 4. Add encore functions to your templates ```twig {# @SyliusShopBundle/_scripts.html.twig #} -{{ encore_entry_script_tags('bitbag-cms-shop', null, 'cms_shop') }} +{{ encore_entry_script_tags('sylius-cms-shop', null, 'cms_shop') }} {# @SyliusShopBundle/_styles.html.twig #} -{{ encore_entry_link_tags('bitbag-cms-shop', null, 'cms_shop') }} +{{ encore_entry_link_tags('sylius-cms-shop', null, 'cms_shop') }} {# @SyliusAdminBundle/_scripts.html.twig #} -{{ encore_entry_script_tags('bitbag-cms-admin', null, 'cms_admin') }} +{{ encore_entry_script_tags('sylius-cms-admin', null, 'cms_admin') }} {# @SyliusAdminBundle/_styles.html.twig #} -{{ encore_entry_link_tags('bitbag-cms-admin', null, 'cms_admin') }} +{{ encore_entry_link_tags('sylius-cms-admin', null, 'cms_admin') }} ``` 5. Run `yarn encore dev` or `yarn encore production` diff --git a/doc/01.2-webpack-entry.md b/doc/01.2-webpack-entry.md index 1b05a90af..f9f3bac48 100644 --- a/doc/01.2-webpack-entry.md +++ b/doc/01.2-webpack-entry.md @@ -1,4 +1,4 @@ -# BitBag SyliusCmsPlugin +# SyliusCmsPlugin - [⬅️ Back](./installation.md) @@ -14,26 +14,26 @@ // ./webpack.config.js // Shop config - .addEntry('bitbag-cms-shop', 'vendor/bitbag/cms-plugin/src/Resources/assets/shop/entry.js') + .addEntry('sylius-cms-shop', 'vendor/bitbag/cms-plugin/src/Resources/assets/shop/entry.js') // Admin config - .addEntry('bitbag-cms-admin', 'vendor/bitbag/cms-plugin/src/Resources/assets/admin/entry.js') + .addEntry('sylius-cms-admin', 'vendor/bitbag/cms-plugin/src/Resources/assets/admin/entry.js') ``` 2. Add encore functions to your templates ```twig {# @SyliusShopBundle/_scripts.html.twig #} -{{ encore_entry_script_tags('bitbag-cms-shop', null, 'shop') }} +{{ encore_entry_script_tags('sylius-cms-shop', null, 'shop') }} {# @SyliusShopBundle/_styles.html.twig #} -{{ encore_entry_link_tags('bitbag-cms-shop', null, 'shop') }} +{{ encore_entry_link_tags('sylius-cms-shop', null, 'shop') }} {# @SyliusAdminBundle/_scripts.html.twig #} -{{ encore_entry_script_tags('bitbag-cms-admin', null, 'admin') }} +{{ encore_entry_script_tags('sylius-cms-admin', null, 'admin') }} {# @SyliusAdminBundle/_styles.html.twig #} -{{ encore_entry_link_tags('bitbag-cms-admin', null, 'admin') }} +{{ encore_entry_link_tags('sylius-cms-admin', null, 'admin') }} ``` 3. Run `yarn encore dev` or `yarn encore production` diff --git a/doc/01.3-import-entry.md b/doc/01.3-import-entry.md index b9682057b..35d9b0140 100644 --- a/doc/01.3-import-entry.md +++ b/doc/01.3-import-entry.md @@ -1,4 +1,4 @@ -# BitBag SyliusCmsPlugin +# SyliusCmsPlugin - [⬅️ Back](./installation.md) diff --git a/doc/01.4-custom-solution.md b/doc/01.4-custom-solution.md index c8289ce29..a232831f4 100644 --- a/doc/01.4-custom-solution.md +++ b/doc/01.4-custom-solution.md @@ -1,4 +1,4 @@ -# BitBag SyliusCmsPlugin +# SyliusCmsPlugin - [⬅️ Back](./installation.md) diff --git a/doc/01.5-non-webpack.md b/doc/01.5-non-webpack.md index b20d41b1c..174faab67 100644 --- a/doc/01.5-non-webpack.md +++ b/doc/01.5-non-webpack.md @@ -1,4 +1,4 @@ -# BitBag SyliusCmsPlugin +# SyliusCmsPlugin - [⬅️ Back](./installation.md) @@ -20,21 +20,21 @@ $ bin/console assets:install ```twig {# @SyliusAdminBundle/_scripts.html.twig #} {% include '@SyliusUi/_javascripts.html.twig' with { - 'path': 'bundles/bitbagsyliuscmsplugin/build/bitbag-cms-admin.js' + 'path': 'bundles/SyliusCmsPlugin/build/sylius-cms-admin.js' } %} {# @SyliusAdminBundle/_styles.html.twig #} {% include '@SyliusUi/_stylesheets.html.twig' with { - 'path': 'bundles/bitbagsyliuscmsplugin/build/bitbag-cms-admin.css' + 'path': 'bundles/SyliusCmsPlugin/build/sylius-cms-admin.css' } %} {# @SyliusShopBundle/_scripts.html.twig #} {% include '@SyliusUi/_javascripts.html.twig' with { - 'path': 'bundles/bitbagsyliuscmsplugin/build/bitbag-cms-shop.js' + 'path': 'bundles/SyliusCmsPlugin/build/sylius-cms-shop.js' } %} {# @SyliusShopBundle/_styles.html.twig #} {% include '@SyliusUi/_stylesheets.html.twig' with { - 'path': 'bundles/bitbagsyliuscmsplugin/build/bitbag-cms-shop.css' + 'path': 'bundles/SyliusCmsPlugin/build/sylius-cms-shop.css' } %} ``` diff --git a/doc/block.csv b/doc/block.csv index 0e592d202..227dc60b7 100644 --- a/doc/block.csv +++ b/doc/block.csv @@ -1,2 +1,2 @@ -code,type,name_en_US,content_en_US,sections,channels,products,image_en_US,slug_en_US -test4,image,Test,test,"blog, general",US_WEB,"010ba66b-adee-3d6e-9d63-67c44d686db1, 01d35db9-247d-3834-b300-20483d5e34e8",https://bitbag.shop/assets/web/images/header-logo.png,https://bitbag.shop/assets/web/images/header-logo.png +code,name,enabled,collections,locales,channels,products,products_in_taxons,taxons +test4,Block name,1,"blog,general",,FASHION_WEB,"000F_office_grey_jeans, 007M_black_elegance_jeans","caps, t_shirts",t_shirts diff --git a/doc/block_legacy.csv b/doc/block_legacy.csv new file mode 100644 index 000000000..0e592d202 --- /dev/null +++ b/doc/block_legacy.csv @@ -0,0 +1,2 @@ +code,type,name_en_US,content_en_US,sections,channels,products,image_en_US,slug_en_US +test4,image,Test,test,"blog, general",US_WEB,"010ba66b-adee-3d6e-9d63-67c44d686db1, 01d35db9-247d-3834-b300-20483d5e34e8",https://bitbag.shop/assets/web/images/header-logo.png,https://bitbag.shop/assets/web/images/header-logo.png diff --git a/doc/blocks.md b/doc/blocks.md index 7d062162a..c03196ce7 100644 --- a/doc/blocks.md +++ b/doc/blocks.md @@ -1,11 +1,13 @@ # Blocks -Blocks represent single parts of your Sylius web app, where you can put some content hardcoded in the -template and change it in the future from admin panel. +Blocks represent single parts of your Sylius web app, where you can put some content elements via the admin panel. +Blocks can be placed on the homepage, product page, or any other page of your store. ## General usage -In the admin panel, you can create block resources. It could be rendered in your twig templates using `bitbag_cms_render_block([block_code])` helper extension. +### Rendering the block + +In the admin panel, you can create block resources. It could be rendered in your twig templates using `sylius_cms_render_block([block_code])` helper extension. For instance, let's assume you created a block with `homepage_intro` code and want to render it on store homepage. In your `app/Resources/views/SyliusShopBundle/Homepage/index.html.twig` file add the Twig filter like this: @@ -14,27 +16,45 @@ In your `app/Resources/views/SyliusShopBundle/Homepage/index.html.twig` file add {% block content %} -# The template is not a mandatory parameter +{{ sylius_cms_render_block('homepage_intro') }} -{{ render(path('bitbag_sylius_cms_plugin_shop_block_render', {'code' : 'homepage_header_image', 'template' : '@App/Some/Template/_path.html.twig'})) }} +{% endblock %} +``` -# However, you can pass it to the `bitbag_cms_render_block` function if you wish :) +`{{ sylius_cms_render_block([block_code]) }}` function can also take two additional parameters: `template` and `context`. -{{ bitbag_cms_render_block('homepage_intro') }} +`template` allows you to render a block with a custom template. For instance: -{% endblock %} +```twig +{{ sylius_cms_render_block('homepage_intro', '@App/Some/Template/_path.html.twig') }} ``` -To render a block by the product code, you can use `route`. +`context` allows you to pass additional variables to the block template. It can be one of three types: +- `ProductInterface` +- `TaxonInterface` +- `array` + +For instance: ```twig -{{ render(path('bitbag_sylius_cms_plugin_shop_block_index_by_product_code', {'productCode' : product.code, 'template' : '@BitBagSyliusCmsPlugin/Shop/Block/index.html.twig'})) }} +{{ sylius_cms_render_block('homepage_intro', null, {'some_variable': 'some_value'}) }} +{{ sylius_cms_render_block('homepage_intro', null, product) }} +{{ sylius_cms_render_block('homepage_intro', null, taxon) }} ``` +When you pass `ProductInterface` or `TaxonInterface` as a context, the block will be rendered only if it is assigned to the given product or taxon +in the admin panel. + ## Customization -If you don't know how to override templates yet, +### Override block template + +If you don't know how to override templates yet, read [Sylius template customization guide](http://docs.sylius.org/en/latest/customization/template.html). -You can create a template under `app/Resources/BitBagSyliusCmsPlugin/views/Shop/Block` location. +Even if you can pass template argument to render block resource, you can change the global templates under `app/templates/bundles/SyliusCmsPlugin/Shop/Block` location. Available templates you can override can be found under [this location](../src/Resources/views/Shop/Block). + +### Custom Block Templates + +For more information about custom block templates, check the [documentation](templates.md). diff --git a/doc/blocks_cms.png b/doc/blocks_cms.png index 003236f22..6369b9c15 100644 Binary files a/doc/blocks_cms.png and b/doc/blocks_cms.png differ diff --git a/doc/blocks_cms_result.png b/doc/blocks_cms_result.png index ecc5035aa..e4f3dd635 100644 Binary files a/doc/blocks_cms_result.png and b/doc/blocks_cms_result.png differ diff --git a/doc/blocks_create_cms.png b/doc/blocks_create_cms.png index 4eca96ca7..8ae7fe255 100644 Binary files a/doc/blocks_create_cms.png and b/doc/blocks_create_cms.png differ diff --git a/doc/collections.md b/doc/collections.md new file mode 100644 index 000000000..9f37fc3f3 --- /dev/null +++ b/doc/collections.md @@ -0,0 +1,39 @@ +# Collections + +Collections are a way to group multiple pages, blocks or media together. +They are useful for organizing things in a way that makes sense to you. \ +For example, you might want to group all of your blog posts together in a collection called `Blog`. +Or you might want to group all of your specific blocks together in a collection called `Homepage blocks`. + +## General usage + +### Rendering the collection + +In the admin panel, you can create collection resources. +It could be rendered in your twig templates using `sylius_cms_render_collection([collection_code])` helper extension. + +`{{ sylius_cms_render_collection([collection_code]) }}` function can also take two additional parameters: `countToRender` and `template`. + +`countToRender` allows you to render a specific number of items from the collection. For instance: + +```twig +{{ sylius_cms_render_collection('homepage_blocks', 3) }} +``` + +`template` allows you to render a collection with a custom template. For instance: + +```twig +{{ sylius_cms_render_collection('homepage_blocks', null, '@App/Some/Template/_path.html.twig') }} +``` + +By default, collection items are sorted by object ID parameter. If you want to change it, you can use decorator strategy. +You can read more about it [here](https://symfony.com/doc/current/service_container/service_decoration.html). + +## Customization + +### Override collection template + +If you don't know how to override templates yet, read [Sylius template customization guide](http://docs.sylius.org/en/latest/customization/template.html). + +Even if you can pass template argument to render collection resource, you can change the global templates under `app/templates/bundles/SyliusCmsPlugin/Shop/Collection` location. +Available templates you can override can be found under [this location](../src/Resources/views/Shop/Collection). diff --git a/doc/collections_cms.png b/doc/collections_cms.png new file mode 100644 index 000000000..b26f91de5 Binary files /dev/null and b/doc/collections_cms.png differ diff --git a/doc/collections_cms_result.png b/doc/collections_cms_result.png new file mode 100644 index 000000000..6a52a266b Binary files /dev/null and b/doc/collections_cms_result.png differ diff --git a/doc/collections_create_cms.png b/doc/collections_create_cms.png new file mode 100644 index 000000000..13cc513c5 Binary files /dev/null and b/doc/collections_create_cms.png differ diff --git a/doc/content_elements.md b/doc/content_elements.md new file mode 100644 index 000000000..8c75730af --- /dev/null +++ b/doc/content_elements.md @@ -0,0 +1,128 @@ +# Content elements + +Content elements are used to create a page or block content that will be displayed on the store's frontend. + +## General usage + +Currently, there are 11 predefined content elements available: +- **[Textarea](content_elements/textarea.md)** - a simple textarea with WYSIWYG editor +- **[Single media](content_elements/single_media.md)** - a single media from the media library +- **[Multiple media](content_elements/multiple_media.md)** - multiple media from the media library +- **[Heading](content_elements/heading.md)** - a simple heading from h1 to h6 +- **[Products carousel](content_elements/products_carousel.md)** - a carousel with products +- **[Products carousel by Taxon](content_elements/products_carousel_by_taxon.md)** - a carousel with products from a specific taxon +- **[Products grid](content_elements/products_grid.md)** - a grid with products +- **[Products grid by Taxon](content_elements/products_grid_by_taxon.md)** - a grid with products from a specific taxon +- **[Taxons list](content_elements/taxons_list.md)** - a list of taxons +- **[Pages collection](content_elements/pages_collection.md)** - a collection of pages +- **[Spacer](content_elements/spacer.md)** - a simple spacer with a defined height in pixels + +Instead of rendering block or page, you can render just content elements in your twig templates using `sylius_cms_render_content_elements([page|block])` helper extension, +where `page` or `block` is an instance of `Sylius\CmsPlugin\Entity\PageInterface` or `Sylius\CmsPlugin\Entity\BlockInterface`. + +## Customization + +### Templates + +Each of the content elements has its own template that you can override. + +If you don't know how to override templates yet, +read [Sylius template customization guide](http://docs.sylius.org/en/latest/customization/template.html). + +You can create a template under `app/templates/bundles/SyliusCmsPlugin/Shop/ContentElement` location. +Available templates you can override can be found under [this location](../src/Resources/views/Shop/ContentElement). + +### Creating a new content element + +If you want to create a new content element, you need to follow these steps: + +1. Create a new form type under `src/Form/Type/ContentElements` location. Define your fields and remember to define public const `TYPE` with a unique name. +For example, you can create a new form type called `Text`: + +```php +final class TextContentElementType extends AbstractType +{ + public const TYPE = 'text'; + + public function buildForm(FormBuilderInterface $builder, array $options): void + { + $builder + ->add(self::TYPE, TextType::class, [ + 'label' => 'sylius_cms.ui.content_elements.type.' . self::TYPE, + ]) + ; + } +} +``` + +2. If your form type have constructor with some arguments, define constant parameter in `config/parameters.yaml` or yours any other `yaml` file: + +```yaml +parameters: + sylius_cms.content_elements.type.text: !php/const 'YourNamespace\Form\Type\ContentElements\TextContentElementType::TYPE' +``` + +If your form type doesn't have any constructor arguments, you can skip this step, because compiler pass will automatically define it for you. + + +3. If your form type have constructor with some arguments, you must define form type in service container under `config/services.yml` with correct tags: + +```yaml +services: + sylius_cms.form.type.content_element.text: + class: YourNamespace\Form\Type\ContentElements\TextContentElementType + arguments: [...] + tags: + - { name: 'sylius_cms.content_elements.type', key: '%sylius_cms.content_elements.type.text%' } + - { name: 'form.type' } +``` + +If your form type doesn't have any constructor arguments, you can skip this step, because compiler pass will automatically register it for you. + +4. Create a new renderer class under `src/Renderer/ContentElement` location. Extend `Sylius\CmsPlugin\Renderer\ContentElement\AbstractContentElement` class. +For example, you can create a new renderer called `TextContentElementRenderer`: + +```php +final class TextContentElementRenderer extends AbstractContentElement +{ + public function supports(ContentConfigurationInterface $contentConfiguration): bool + { + return TextContentElementType::TYPE === $contentConfiguration->getType(); + } + + public function render(ContentConfigurationInterface $contentConfiguration): string + { + $text = $contentConfiguration->getConfiguration()['text']; + + return $this->twig->render('@SyliusCmsPlugin/Shop/ContentElement/index.html.twig', [ + 'content_element' => $this->template, + 'text' => $text, + ]); + } +} +``` + +5. Register your renderer with tag in service container under `config/services.yml`: + +```yaml +services: + sylius_cms.renderer.content_element.text: + class: YourNamespace\Renderer\ContentElement\TextContentElementRenderer + arguments: + - '@twig' + tags: + - { + name: 'sylius_cms.renderer.content_element', + template: '@YourNamespace/Shop/ContentElement/_text.html.twig', + form_type: 'YourNamespace\Form\Type\ContentElements\TextContentElementType' + } +``` + +Define form_type only if your form type doesn't have constructor with additional arguments. + +6. Finally, create a new template under `templates/bundles/SyliusCmsPlugin/Shop/ContentElement` location. +For example, you can create a new template called `_text.html.twig`: + +```twig +

{{ text }}

+``` diff --git a/doc/content_elements/heading.md b/doc/content_elements/heading.md new file mode 100644 index 000000000..a82a67b03 --- /dev/null +++ b/doc/content_elements/heading.md @@ -0,0 +1,11 @@ +# Heading content element + +Heading content element allows you to add a heading (from H1 to H6) to your block or page. + +## View in admin panel + +![Heading in admin panel](heading1.png) + +## View in front page + +![Heading in front page](heading2.png) diff --git a/doc/content_elements/heading1.png b/doc/content_elements/heading1.png new file mode 100644 index 000000000..baa1ce118 Binary files /dev/null and b/doc/content_elements/heading1.png differ diff --git a/doc/content_elements/heading2.png b/doc/content_elements/heading2.png new file mode 100644 index 000000000..bf7678611 Binary files /dev/null and b/doc/content_elements/heading2.png differ diff --git a/doc/content_elements/multiple_media.md b/doc/content_elements/multiple_media.md new file mode 100644 index 000000000..92cb2c7df --- /dev/null +++ b/doc/content_elements/multiple_media.md @@ -0,0 +1,12 @@ +# Multiple media content element + +Multiple media content element allows you to add multiple media (images, videos, or files) +from the media library to your block or page. + +## View in admin panel + +![Multiple media in admin panel](multiple_media1.png) + +## View in front page + +![Multiple media in front page](multiple_media2.png) diff --git a/doc/content_elements/multiple_media1.png b/doc/content_elements/multiple_media1.png new file mode 100644 index 000000000..f65db2a59 Binary files /dev/null and b/doc/content_elements/multiple_media1.png differ diff --git a/doc/content_elements/multiple_media2.png b/doc/content_elements/multiple_media2.png new file mode 100644 index 000000000..7630818c6 Binary files /dev/null and b/doc/content_elements/multiple_media2.png differ diff --git a/doc/content_elements/pages_collection.md b/doc/content_elements/pages_collection.md new file mode 100644 index 000000000..8213a6854 --- /dev/null +++ b/doc/content_elements/pages_collection.md @@ -0,0 +1,11 @@ +# Pages collection content element + +Pages collection content element renders a pages from a selected collection. + +## View in admin panel + +![Pages collection in admin panel](pages_collection1.png) + +## View in front page + +![Pages collection in front page](pages_collection2.png) diff --git a/doc/content_elements/pages_collection1.png b/doc/content_elements/pages_collection1.png new file mode 100644 index 000000000..6d1772cbf Binary files /dev/null and b/doc/content_elements/pages_collection1.png differ diff --git a/doc/content_elements/pages_collection2.png b/doc/content_elements/pages_collection2.png new file mode 100644 index 000000000..4f313f905 Binary files /dev/null and b/doc/content_elements/pages_collection2.png differ diff --git a/doc/content_elements/products_carousel.md b/doc/content_elements/products_carousel.md new file mode 100644 index 000000000..dfee37309 --- /dev/null +++ b/doc/content_elements/products_carousel.md @@ -0,0 +1,11 @@ +# Products carousel content element + +Products carousel content element allows you to add a carousel with shop products to your block or page. + +## View in admin panel + +![Products carousel in admin panel](products_carousel1.png) + +## View in front page + +![Products carousel in front page](products_carousel2.png) diff --git a/doc/content_elements/products_carousel1.png b/doc/content_elements/products_carousel1.png new file mode 100644 index 000000000..56438a64d Binary files /dev/null and b/doc/content_elements/products_carousel1.png differ diff --git a/doc/content_elements/products_carousel2.png b/doc/content_elements/products_carousel2.png new file mode 100644 index 000000000..1eefc60c9 Binary files /dev/null and b/doc/content_elements/products_carousel2.png differ diff --git a/doc/content_elements/products_carousel_by_taxon.md b/doc/content_elements/products_carousel_by_taxon.md new file mode 100644 index 000000000..9acb0078e --- /dev/null +++ b/doc/content_elements/products_carousel_by_taxon.md @@ -0,0 +1,12 @@ +# Products carousel by Taxon content element + +Products carousel by Taxon content element allows you to add a carousel +with shop products from specified taxon to your block or page. + +## View in admin panel + +![Products carousel by Taxon in admin panel](products_carousel_by_taxon1.png) + +## View in front page + +![Products carousel by Taxon in front page](products_carousel2.png) diff --git a/doc/content_elements/products_carousel_by_taxon1.png b/doc/content_elements/products_carousel_by_taxon1.png new file mode 100644 index 000000000..9683f78b1 Binary files /dev/null and b/doc/content_elements/products_carousel_by_taxon1.png differ diff --git a/doc/content_elements/products_grid.md b/doc/content_elements/products_grid.md new file mode 100644 index 000000000..efe77aae6 --- /dev/null +++ b/doc/content_elements/products_grid.md @@ -0,0 +1,12 @@ +# Products grid content element + +Products grid content element allows you to add a grid with +shop products to your block or page. + +## View in admin panel + +![Products grid in admin panel](products_grid1.png) + +## View in front page + +![Products grid in front page](products_grid2.png) diff --git a/doc/content_elements/products_grid1.png b/doc/content_elements/products_grid1.png new file mode 100644 index 000000000..48b4e1973 Binary files /dev/null and b/doc/content_elements/products_grid1.png differ diff --git a/doc/content_elements/products_grid2.png b/doc/content_elements/products_grid2.png new file mode 100644 index 000000000..57374aeb3 Binary files /dev/null and b/doc/content_elements/products_grid2.png differ diff --git a/doc/content_elements/products_grid_by_taxon.md b/doc/content_elements/products_grid_by_taxon.md new file mode 100644 index 000000000..9cccd08b8 --- /dev/null +++ b/doc/content_elements/products_grid_by_taxon.md @@ -0,0 +1,12 @@ +# Products grid by Taxon content element + +Products grid by Taxon content element allows you to add a grid +with shop products from specified taxon to your block or page. + +## View in admin panel + +![Products grid by Taxon in admin panel](products_grid_by_taxon1.png) + +## View in front page + +![Products grid by Taxon in front page](products_grid2.png) diff --git a/doc/content_elements/products_grid_by_taxon1.png b/doc/content_elements/products_grid_by_taxon1.png new file mode 100644 index 000000000..2deae902b Binary files /dev/null and b/doc/content_elements/products_grid_by_taxon1.png differ diff --git a/doc/content_elements/single_media.md b/doc/content_elements/single_media.md new file mode 100644 index 000000000..03386d056 --- /dev/null +++ b/doc/content_elements/single_media.md @@ -0,0 +1,12 @@ +# Single media content element + +Single media content element allows you to add a single media (image, video, or file) +from the media library to your block or page. + +## View in admin panel + +![Single media in admin panel](single_media1.png) + +## View in front page + +![Single media in front page](single_media2.png) diff --git a/doc/content_elements/single_media1.png b/doc/content_elements/single_media1.png new file mode 100644 index 000000000..35009ed5d Binary files /dev/null and b/doc/content_elements/single_media1.png differ diff --git a/doc/content_elements/single_media2.png b/doc/content_elements/single_media2.png new file mode 100644 index 000000000..d21dfb69c Binary files /dev/null and b/doc/content_elements/single_media2.png differ diff --git a/doc/content_elements/spacer.md b/doc/content_elements/spacer.md new file mode 100644 index 000000000..526ddf0ac --- /dev/null +++ b/doc/content_elements/spacer.md @@ -0,0 +1,12 @@ +# Spacer content element + +Spacer content element allows you to add a space in pixels +between content elements to your block or page. + +## View in admin panel + +![Spacer in admin panel](spacer1.png) + +## View in front page + +![Spacer in front page](spacer2.png) diff --git a/doc/content_elements/spacer1.png b/doc/content_elements/spacer1.png new file mode 100644 index 000000000..4dc49e262 Binary files /dev/null and b/doc/content_elements/spacer1.png differ diff --git a/doc/content_elements/spacer2.png b/doc/content_elements/spacer2.png new file mode 100644 index 000000000..99dfd6c6c Binary files /dev/null and b/doc/content_elements/spacer2.png differ diff --git a/doc/content_elements/taxons_list.md b/doc/content_elements/taxons_list.md new file mode 100644 index 000000000..e74952287 --- /dev/null +++ b/doc/content_elements/taxons_list.md @@ -0,0 +1,12 @@ +# Taxons list content element + +Taxons list content element allows you to add a list of taxons +to your block or page. + +## View in admin panel + +![Taxons list in admin panel](taxons_list1.png) + +## View in front page + +![Taxons list in front page](taxons_list2.png) diff --git a/doc/content_elements/taxons_list1.png b/doc/content_elements/taxons_list1.png new file mode 100644 index 000000000..cae575202 Binary files /dev/null and b/doc/content_elements/taxons_list1.png differ diff --git a/doc/content_elements/taxons_list2.png b/doc/content_elements/taxons_list2.png new file mode 100644 index 000000000..04e34a0a8 Binary files /dev/null and b/doc/content_elements/taxons_list2.png differ diff --git a/doc/content_elements/textarea.md b/doc/content_elements/textarea.md new file mode 100644 index 000000000..413ac41cf --- /dev/null +++ b/doc/content_elements/textarea.md @@ -0,0 +1,12 @@ +# Textarea content element + +Textarea content element allows you to add a simple text area to your block or page +with WYSIWYG editor (CKEditor). + +## View in admin panel + +![Textarea in admin panel](textarea1.png) + +## View in front page + +![Textarea in front page](textarea2.png) diff --git a/doc/content_elements/textarea1.png b/doc/content_elements/textarea1.png new file mode 100644 index 000000000..50f56a4fa Binary files /dev/null and b/doc/content_elements/textarea1.png differ diff --git a/doc/content_elements/textarea2.png b/doc/content_elements/textarea2.png new file mode 100644 index 000000000..aba0bd2e9 Binary files /dev/null and b/doc/content_elements/textarea2.png differ diff --git a/doc/content_management.png b/doc/content_management.png index a3136ee59..70c878937 100644 Binary files a/doc/content_management.png and b/doc/content_management.png differ diff --git a/doc/content_template_create_cms.png b/doc/content_template_create_cms.png new file mode 100644 index 000000000..caf6ecdaa Binary files /dev/null and b/doc/content_template_create_cms.png differ diff --git a/doc/content_templates.gif b/doc/content_templates.gif new file mode 100644 index 000000000..25cf4c454 Binary files /dev/null and b/doc/content_templates.gif differ diff --git a/doc/content_templates.md b/doc/content_templates.md new file mode 100644 index 000000000..1dce18372 --- /dev/null +++ b/doc/content_templates.md @@ -0,0 +1,21 @@ +# Content Templates + +Content Templates are a way to define the structure of content elements, which can be used in blocks and pages. + +![Content Templates usage](content_templates.gif) + +## General usage + +Let's assume you want to create a content template for a blog post. +You want to add following content elements: +- **Title** (textarea) +- **Subtitle** (textarea) +- **Image** (single media) +- **Content** (textarea) +- **Author** (textarea) +- **Products carousel** (products carousel by taxon) + +Then, when you create a page, in the content elements section you can choose the content template you created. +It will create a form with fields you defined in the template. \ +Your job is just to fill them with content. \ +Of course, you can add additional content elements to the form, after you choose the template. It's super flexible! diff --git a/doc/content_templates_cms.png b/doc/content_templates_cms.png new file mode 100644 index 000000000..7e941ced2 Binary files /dev/null and b/doc/content_templates_cms.png differ diff --git a/doc/customization.md b/doc/customization.md index e5e398d9c..f73654d61 100644 --- a/doc/customization.md +++ b/doc/customization.md @@ -9,34 +9,34 @@ You can customize this plugin using: In order to check what services are available with this plugin, run the following command: ```bash -$ bin/console debug:container bitbag_sylius_cms_plugin +$ bin/console debug:container sylius_cms ``` **Note:** -*All forms are prefixed with 'bitbag_sylius_cms_plugin.form.*'* +*All forms are prefixed with 'sylius_cms.form.*'* If you want to check what routes are available with this plugin, use: ```bash -$ bin/console debug:router | grep bitbag_sylius_cms_plugin +$ bin/console debug:router | grep sylius_cms ``` To check parameters available with the plugin, execute: ```bash -$ bin/console debug:container --parameters | grep bitbag +$ bin/console debug:container --parameters | grep sylius_cms ``` ## How to disable localised URLs? -Customise vendor routing in the file `app/Resources/BitBagSyliusCmsPlugin/config/routing.yml` (create if not exist). +Customise vendor routing in the file `app/Resources/SyliusCmsPlugin/config/routing.yml` (create if not exist). Add: ``` -bitbag_sylius_cms_plugin_admin: - resource: "@BitBagSyliusCmsPlugin/Resources/config/routing/admin.yml" +sylius_cms_admin: + resource: "@SyliusCmsPlugin/Resources/config/routing/admin.yml" prefix: /admin -bitbag_sylius_cms_plugin_shop: - resource: "@BitBagSyliusCmsPlugin/Resources/config/routing/shop.yml" +sylius_cms_shop: + resource: "@SyliusCmsPlugin/Resources/config/routing/shop.yml" prefix: / sylius_sitemap: diff --git a/doc/faq_cms.png b/doc/faq_cms.png deleted file mode 100644 index 3df5d48f1..000000000 Binary files a/doc/faq_cms.png and /dev/null differ diff --git a/doc/faq_cms_result.png b/doc/faq_cms_result.png deleted file mode 100644 index bce828b55..000000000 Binary files a/doc/faq_cms_result.png and /dev/null differ diff --git a/doc/faq_create_cms.png b/doc/faq_create_cms.png deleted file mode 100644 index 3dc4dd109..000000000 Binary files a/doc/faq_create_cms.png and /dev/null differ diff --git a/doc/faqs.md b/doc/faqs.md deleted file mode 100644 index 2b27b1279..000000000 --- a/doc/faqs.md +++ /dev/null @@ -1,20 +0,0 @@ -# FAQs - -Frequently asked question is a common part of each eCommerce website. You can add the in your admin -panel configuring question, answer and position. All results will be paginated in the store front. - -## General usage - -To render FAQs list, use the `bitbag_sylius_cms_plugin_shop_frequently_asked_question_index` route. - -```twig -{{ 'app.ui.faqs'|trans }} -``` - -## Customization - -If you don't know how to override templates yet, -read [Sylius template customization guide](http://docs.sylius.org/en/latest/customization/template.html). - -You can create a template under `app/Resources/BitBagSyliusCmsPlugin/views/Shop/FrequentlyAskedQuestion` location. -Available templates you can override can be found under [this location](../src/Resources/views/Shop/FrequentlyAskedQuestion). diff --git a/doc/fixtures.md b/doc/fixtures.md index 5b3d2c191..c4cc0a82f 100644 --- a/doc/fixtures.md +++ b/doc/fixtures.md @@ -9,4 +9,4 @@ read [this documentation page](http://docs.sylius.com/en/1.2/book/architecture/f ## General usage -As you can see in [here](../tests/Application/config/packages/bitbag_sylius_cms_plugin.yml), cms fixtures are configured to be run under `default` suite. It means that after installing plugin all you need to do is run `bin/console sylius:fixtures:load` and all of cms fixtures will load as well. +As you can see in [here](../tests/Application/config/packages/sylius_cms.yml), cms fixtures are configured to be run under `default` suite. It means that after installing plugin all you need to do is run `bin/console sylius:fixtures:load` and all of cms fixtures will load as well. diff --git a/doc/importing-resources.md b/doc/importing-resources.md index 8cce460a4..0e8d0e696 100644 --- a/doc/importing-resources.md +++ b/doc/importing-resources.md @@ -21,10 +21,9 @@ are validated against constraints used in the admin panel. What's more, thanks t Currently implemented importers support following column names, which are constants values from below table. **Note:** -- `__locale__` suffix needs to be replaced with a specific locale configured in your admin panel. -- `sections`, `channels` and `products` represent associations that are recognized with comma separated resource codes. -For instance, if you want to associate three sections via the CSV file, you should fill the `sections` column with -`homepage, blog, delivery` value, where each value is a single section code. +- `collections`, `channels`, `locales`, `products`, `products_in_taxons`, `taxons` represent associations that are recognized with comma separated resource codes. +For instance, if you want to associate three collections via the CSV file, you should fill the `collections` column with +`homepage, blog, delivery` value, where each value is a single collection code. | Resource code | Importer columns interface | |---------------|--------------------------------------------------------------------| @@ -39,13 +38,13 @@ As previously mentioned, in order to import a data, you need to pick specific re In order to import data via command, execute: ```bash -$ bin/console bitbag:import:csv [resource code] [path/to/your/csv/file.csv] +$ bin/console cms:import:csv [resource code] [path/to/your/csv/file.csv] ``` For instance, if you wish to import a page, run: ```bash -$ bin/console bitbag:import:csv page ~/Documents/pages.csv +$ bin/console cms:import:csv page ~/Documents/pages.csv ``` ## Importing via admin panel @@ -64,7 +63,7 @@ the resolver needs to create a new resource or update an existing one: ```yaml app.resolver.resource.product: - class: BitBag\SyliusCmsPlugin\Resolver\ResourceResolver + class: Sylius\CmsPlugin\Resolver\ResourceResolver arguments: - "@sylius.repository.product" - "@sylius.factory.product" @@ -80,7 +79,7 @@ declare(strict_types=1); namespace AppBundle\Importer; -use BitBag\SyliusCmsPlugin\Importer\ImporterInterface; +use Sylius\CmsPlugin\Importer\ImporterInterface; interface ProductImporterInterface extends ImporterInterface { @@ -100,8 +99,8 @@ declare(strict_types=1); namespace AppBundle\Importer; -use BitBag\SyliusCmsPlugin\Importer\AbstractImporter; -use BitBag\SyliusCmsPlugin\Resolver\ResourceResolverInterface; +use Sylius\CmsPlugin\Importer\AbstractImporter; +use Sylius\CmsPlugin\Resolver\ResourceResolverInterface; use Doctrine\ORM\EntityManagerInterface; use Sylius\Component\Locale\Context\LocaleContextInterface; use Symfony\Component\Validator\Validator\ValidatorInterface; @@ -181,12 +180,12 @@ final class ProductImporter extends AbstractImporter implements ProductImporterI - "@validator" - "@doctrine.orm.entity_manager" tags: - - { name: bitbag.cmsplugin.importer } + - { name: cms_plugin.importer } ``` 5. :tada: -Now you can use the `$ bin/console bitbag:import:csv product /path/to/products.csv/file` command to upload your products. +Now you can use the `$ bin/console cms:import:csv product /path/to/products.csv/file` command to upload your products. Read the below section to enable the import from UI feature. @@ -213,7 +212,7 @@ sylius_grid: ### Overriding the importer grid template -Create an `_importForm.html.twig` file under `app/Resources/BitBagSyliusCmsPlugin/views/Grid/Form` location. Take a look at +Create an `_importForm.html.twig` file under `app/Resources/SyliusCmsPlugin/views/Grid/Form` location. Take a look at the default [_importForm.html.twig](../src/Resources/views/Grid/Form/_importForm.html.twig) file. ### Example diff --git a/doc/installation.md b/doc/installation.md index 842b00618..51a4a3cc5 100644 --- a/doc/installation.md +++ b/doc/installation.md @@ -1,39 +1,64 @@ -## Installation - - -1. *We work on stable, supported and up-to-date versions of packages. We recommend you to do the same.* - +# Installation + +## Overview: +GENERAL +- [Requirements](#requirements) +- [Composer](#composer) +- [Basic configuration](#basic-configuration) +--- +BACKEND +- [Entities](#entities) +--- +FRONTEND +- [Webpack](#webpack) +--- +ADDITIONAL +- [Tests](#tests) +--- + +## Requirements: +We work on stable, supported and up-to-date versions of packages. We recommend you to do the same. + +| Package | Version | +|---------------|-----------------| +| PHP | \>=8.1 | +| sylius/sylius | 1.12.x - 1.13.x | +| MySQL | \>= 5.7 | +| NodeJS | \>= 18.x | + +## Composer: ```bash -$ composer require bitbag/cms-plugin --no-scripts +composer require bitbag/cms-plugin --no-scripts ``` -2. Add plugin dependencies to your `config/bundles.php` file: +## Basic configuration: +1. Add plugin dependencies to your `config/bundles.php` file (if not added automatically): ```php +# config/bundles.php + return [ ... - FOS\CKEditorBundle\FOSCKEditorBundle::class => ['all' => true], // WYSIWYG editor - BitBag\SyliusCmsPlugin\BitBagSyliusCmsPlugin::class => ['all' => true], + Sylius\CmsPlugin\SyliusCmsPlugin::class => ['all' => true], ]; ``` -The first line above (FOSCKEditorBundle) might have been already added during composer require command. -Install WYSIWYG editor ([FOS CKEditor](https://symfony.com/doc/master/bundles/FOSCKEditorBundle/usage/ckeditor.html)) +2. Install WYSIWYG editor ([FOS CKEditor](https://symfony.com/doc/master/bundles/FOSCKEditorBundle/usage/ckeditor.html)) ```bash -$ bin/console ckeditor:install +bin/console ckeditor:install ``` **Note.** If you have an issue with the ckeditor not running, please try to install it using the `4.22.1` tag: ```bash -$ bin/console ckeditor:install --tag=4.22.1 +bin/console ckeditor:install --tag=4.22.1 ``` For more information regardin `4.22.1` tag please visit the #485 issue. -Since FOSCKEditorBundle 2.0, to make Twig render the WYSIWYG editor, you must add some configuration under the `twig.form_themes` config key: +3. If you are not using Symfony Flex, you need to add the following configuration: ```yaml # Symfony 2/3: app/config/config.yml @@ -42,120 +67,82 @@ Since FOSCKEditorBundle 2.0, to make Twig render the WYSIWYG editor, you must ad twig: form_themes: - '@FOSCKEditor/Form/ckeditor_widget.html.twig' - - '@BitBagSyliusCmsPlugin/Form/ckeditor_widget.html.twig' + - '@SyliusCmsPlugin/Form/ckeditor_widget.html.twig' ``` -3. Import required config in your `config/packages/_sylius.yaml` file: ```yaml # config/packages/_sylius.yaml imports: - ... - - - { resource: "@BitBagSyliusCmsPlugin/Resources/config/config.yml" } -``` + ... + - { resource: "@SyliusCmsPlugin/Resources/config/config.yml" } -4. Import routing in your `config/routes.yaml` file: - -```yaml # config/routes.yaml ... - -bitbag_sylius_cms_plugin: - resource: "@BitBagSyliusCmsPlugin/Resources/config/routing.yml" -``` -If You have installed https://github.com/stefandoorn/sitemap-plugin according to its installation instructions -import optional sitemap providers: -```yaml -# config/services.yaml -... -imports: -... - - { resource: "@BitBagSyliusCmsPlugin/Resources/config/services/sitemap_provider.yml" } +sylius_cms: + resource: "@SyliusCmsPlugin/Resources/config/routing.yml" ``` -and plugin dependency to your `config/bundles.php` file: -```php -return [ - ... - - SitemapPlugin\SitemapPlugin::class => ['all' => true], // Sitemap support -]; +4. Install assets: +```bash +bin/console assets:install --symlink +bin/console sylius:theme:assets:install --symlink ``` -you will probably need to change the extension of the imported file in - -```yaml -# config/packages/sitemap_plugin.yaml - - imports: - - { resource: "@SitemapPlugin/Resources/config/config.yaml" } +## Entities +### Update your database +First, please run legacy-versioned migrations by using command: +```bash +bin/console doctrine:migrations:migrate ``` -5. Finish the installation by updating the database schema and installing assets: - +After migration, please create a new diff migration and update database: ```bash -$ bin/console cache:clear - -# If you used migrations in your project... -$ bin/console doctrine:migrations:migrate -# ... or if you use doctrine schema tool. -$ bin/cosole doctrine:schema:update --dump-sql # and --force switch when you're ready :) - -$ bin/console assets:install --symlink -$ bin/console sylius:theme:assets:install --symlink +bin/console doctrine:migrations:diff +bin/console doctrine:migrations:migrate ``` +**Note:** If you are running it on production, add the `-e prod` flag to this command. -Note. In some cases the `--symlink` option [may trow some errors](https://github.com/Sylius/SyliusThemeBundle/issues/91). If you consider running the commands without `--symlink` option, please keep in mind to run them on every potential plugin update. +### Clear application cache by using command: +```bash +bin/console cache:clear +``` +**Note:** If you are running it on production, add the `-e prod` flag to this command. -6. Add plugin assets to your project +## Webpack We recommend you to use Webpack (Encore), for which we have prepared four different instructions on how to add this plugin's assets to your project: - [Import webpack config](./01.1-webpack-config.md)* -- [Add entry to existing config](./01.2-webpack-entry.md)) -- [Import entries in your entry.js files](./01.3-import-entry.md)) -- [Your own custom config](./01.4-custom-solution.md)) +- [Add entry to existing config](./01.2-webpack-entry.md) +- [Import entries in your entry.js files](./01.3-import-entry.md) +- [Your own custom config](./01.4-custom-solution.md) * Default option for plugin development - However, if you are not using Webpack, here are instructions on how to add optimized and compressed assets directly to your project templates: - [Non webpack solution](./01.5-non-webpack.md) -7. Passing required "backend" values to "frontend" - -In order to make plugin finally work you need to declare "route", in admin _scripts.html.twig you can pass: - -``` - -``` - -Any other approach, that will allow cms pages to read this value in js, under "route" key, will work. - -## Testing & running the plugin -```bash -$ composer install -$ cd tests/Application -``` -Copy file `package.json.~1.XX.0.dist` to `package.json` where `~1.XX.0` is the Sylius version you are using. - +### Run commands ```bash -$ cp package.json.~1.12.0.dist package.json +yarn install +yarn encore dev # or prod, depends on your environment ``` +## Tests +To run the tests, execute the commands: ```bash -$ yarn install -$ yarn encore dev -$ APP_ENV=test bin/console assets:install -$ APP_ENV=test bin/console doctrine:schema:create -$ APP_ENV=test symfony server:start --port=8080 -d -$ cd ../.. -$ open http://localhost:8080 -$ vendor/bin/behat -$ vendor/bin/phpspec run +composer install +cd tests/Application +yarn install +yarn encore dev +APP_ENV=test bin/console assets:install +APP_ENV=test bin/console doctrine:schema:create +APP_ENV=test symfony server:start --port=8080 -d +cd ../.. +open http://localhost:8080 +vendor/bin/behat +vendor/bin/phpspec run ``` diff --git a/doc/legacy_data_migration.md b/doc/legacy_data_migration.md new file mode 100644 index 000000000..4ee2ce364 --- /dev/null +++ b/doc/legacy_data_migration.md @@ -0,0 +1,49 @@ +# Legacy data migration + +## Introduction + +You can migrate your blocks & pages from the 4.x version to the 5.x version of the plugin. +To do so, you need to follow the steps below. + +## Steps + +1. Create new CSV files with blocks & pages data in the 4.x format. +See an example in [block_legacy.csv](block_legacy.csv) or [page_legacy.csv](page_legacy.csv). +2. Install the 5.x version of the plugin. +3. Go to the console and run the following command: +```bash +bin/console cms:import:csv page_legacy {file_path}.csv +bin/console cms:import:csv block_legacy {file_path}.csv +``` + +## Info about legacy CSV files columns + +### Blocks + +- **code** - block code. +- **type** - it will be ignored. +- **name_LOCALE** - block name. First occurrence of its column is the default name for the block. +For each locale, there will be created a Heading content element. +- **content_LOCALE** - block content. For each locale, there will be created a Textarea content element. +- **sections** - it will be converted to the block's collections. +- **channels** - block channels. +- **products** - block products. There will be created Products grid content element. +- **image_LOCALE** - block image. For each locale, there will be created a Single media content element. +- **slug_LOCALE** - it will be ignored. + +### Pages + +- **code** - page code. +- **sections** - it will be converted to the page's collections. +- **channels** - page channels. +- **products** - page products. There will be created Products grid content element. +- **slug_LOCALE** - page slug. +- **name_LOCALE** - page name. First occurrence of its column is the default name for the page. +For each locale, there will be created a Heading content element. +- **image_LOCALE** - page image. For each locale, there will be created a Single media content element. +- **meta_keywords_LOCALE** - page meta keywords. +- **meta_description_LOCALE** - page meta description. +- **content_LOCALE** - page content. For each locale, there will be created a Textarea content element. +- **breadcrumb_LOCALE** - it will be ignored. +- **name_when_linked_LOCALE** - for each locale, there will be created a teaser title. +- **description_when_linked_LOCALE** - for each locale, there will be created a teaser content. diff --git a/doc/media.md b/doc/media.md index 542508321..ebd781ae2 100644 --- a/doc/media.md +++ b/doc/media.md @@ -10,50 +10,45 @@ Currently, it supports following media types: ## General usage -You can render media in four ways: +You can render media in two ways: By rendering a media code template: ```twig -{{ bitbag_cms_render_media('media_code') }} +{{ sylius_cms_render_media('media_code') }} ``` - -Rendering a media code directly: +Function above can also take an additional parameter: `template`. ```twig -{{ render(path('bitbag_sylius_cms_plugin_shop_media_render', {'code' : 'file', 'template' : '@App/Some/Template/_path.html.twig'})) }} +{{ sylius_cms_render_media('media_code', '@App/templates/example.html.twig')}} ``` -If you want to list media by specific section. Useful for displaying set of images. For example, using "gallery" section you can group set of images and display them as gallery, or even slider. +Rendering a media code directly: ```twig -{{ render(path('bitbag_sylius_cms_plugin_shop_media_index_by_section_code', {'sectionCode' : 'gallery', 'template' : '@App/Some/Template/_path.html.twig'})) }} +{{ render(path('sylius_cms_shop_media_render', {'code' : 'file', 'template' : '@App/Some/Template/_path.html.twig'})) }} ``` -Or by providing custom twig template. Useful when you want to render media in a different template: +## Media provider -```{{ bitbag_cms_render_media('media_code', '@App/templates/example.html.twig')}}``` +You can add your own media provider by adding a service with a tag named `sylius_cms.media_provider`: -### Media provider - -You can add your own media provider by adding a service with a tag named `bitbag_sylius_cms_plugin.media_provider`: - -```php +```twig app.media_provider.audio: - class: BitBag\SyliusCmsPlugin\MediaProvider\GenericProvider + class: Sylius\CmsPlugin\MediaProvider\GenericProvider arguments: - - "@bitbag_sylius_cms_plugin.media_uploader" + - "@sylius_cms.media_uploader" - "@templating.engine.twig" - - "@@BitBagSyliusCmsPlugin/Shop/Media/Show/audio.html.twig" + - "@@SyliusCmsPlugin/Shop/Media/Show/audio.html.twig" - "media/audio" tags: - - { name: bitbag_sylius_cms_plugin.media_provider, type: audio, label: bitbag_sylius_cms_plugin.ui.audio_provider } + - { name: sylius_cms.media_provider, type: audio, label: sylius_cms.ui.audio_provider } ``` ## Customization -If you don't know how to override templates yet, +If you don't know how to override templates yet, read [Sylius template customization guide](http://docs.sylius.org/en/latest/customization/template.html). -You can create a template under `app/Resources/BitBagSyliusCmsPlugin/views/Shop/Media` location. +Even if you can pass template argument to render media resource, you can change the global templates under `app/templates/bundles/SyliusCmsPlugin/Shop/Media` location. Available templates you can override can be found under [this location](../src/Resources/views/Shop/Media). diff --git a/doc/media_cms.png b/doc/media_cms.png index d5edbe354..e5827414a 100644 Binary files a/doc/media_cms.png and b/doc/media_cms.png differ diff --git a/doc/media_cms_result.png b/doc/media_cms_result.png index c0767e15b..332dc4068 100644 Binary files a/doc/media_cms_result.png and b/doc/media_cms_result.png differ diff --git a/doc/media_create_cms.png b/doc/media_create_cms.png index 32aaa25bc..63f049ec4 100644 Binary files a/doc/media_create_cms.png and b/doc/media_create_cms.png differ diff --git a/doc/page.csv b/doc/page.csv index 47d208dd7..4518d95bf 100644 --- a/doc/page.csv +++ b/doc/page.csv @@ -1,2 +1,2 @@ -code,sections,channels,products,slug_en_US,name_en_US,image_en_US,meta_keywords_en_US,meta_description_en_US,content_en_US,breadcrumb_en_US,name_when_linked_en_US,description_when_linked_en_US -aboutUS,,US_WEB,,about_us,About US,,About US,About US,"",,, +code,name,enabled,collections,channels,slug_en_US,meta_title_en_US,meta_keywords_en_US,meta_description_en_US,slug_de_DE,meta_title_de_DE,meta_keywords_de_DE,meta_description_de_DE +aboutUS,About US,1,,FASHION_WEB,about_us,Meta title en US,About US,About US,about_us,Meta title en DE,About US,About US diff --git a/doc/page_legacy.csv b/doc/page_legacy.csv new file mode 100644 index 000000000..47d208dd7 --- /dev/null +++ b/doc/page_legacy.csv @@ -0,0 +1,2 @@ +code,sections,channels,products,slug_en_US,name_en_US,image_en_US,meta_keywords_en_US,meta_description_en_US,content_en_US,breadcrumb_en_US,name_when_linked_en_US,description_when_linked_en_US +aboutUS,,US_WEB,,about_us,About US,,About US,About US,"",,, diff --git a/doc/pages.md b/doc/pages.md index 6ecac44b1..919362e49 100644 --- a/doc/pages.md +++ b/doc/pages.md @@ -1,69 +1,47 @@ # Pages -Pages represent a customizable web page, you can adjust to your needs in admin panel. +Pages represent a customizable web page, you can adjust to your needs in admin panel. + +## Page sections + +Page contain 4 main editable sections: +- **General settings** - where you can set page name, code, channels, collections and publish at. It also contains a Preview button, which allows you to preview the page. +- **Content elements** - where you can add content elements to the page, read more about content elements [here](content_elements.md). +- **Teaser** - where you can set image, title and content. Teaser is a small preview of the page. It is used during rendering a collection of pages. +- **SEO** - where you can set slug, meta title, meta keywords and meta description. ## General usage +### Rendering the page + Once you created a page in the admin panel, you can render page in two ways: By rendering a page link template: ```twig -{{ render(path('bitbag_sylius_cms_plugin_shop_page_show_link_by_code', {'code' : 'about', 'template' : '@BitBagSyliusCmsPlugin/Shop/Page/Show/_link.html.twig'})) }} +{{ render(path('sylius_cms_shop_page_show_link_by_code', {'code' : 'about', 'template' : '@SyliusCmsPlugin/Shop/Page/Show/_link.html.twig'})) }} ``` Or rendering a page link directly: ```twig -{{ render(path('bitbag_sylius_cms_plugin_shop_page_show', {'slug' : 'about'})) }} -``` - -### Render product pages by section - -Let's assume you associated pages to specific products. You can render them grouped by section in your product view by using - -```twig -{{ bitbag_cms_render_product_pages(product) }} -``` - -Twig function. This is where `nameWhenLinked` and `descriptionWhenLinked` fields are used. If you associate pages to -specific sections, they will be displayed in columns titled with section name. - -### Render link to page from its code - -If you want to create a link to a page from its code, you can do either with `bitbag_cms_render_link_for_code` or `bitbag_cms_get_link_for_code` twig functions. These functions will automatically generate a link with the correct locale. - -You can define attributes to customize the tag. You can also customize the displayed name (by default the function will try to display the name when linked, if it is not defined, it will fallback to the page name). - -If you only need the link, you can use `bitbag_cms_get_link_for_code`. - -You can display a message if the page wasn't found with the `notFoundMessage` option. - -```twig -{{ bitbag_cms_render_link_for_code('code') }} -{{ bitbag_cms_render_link_for_code('code', { attr: { class: 'ui button' }, name: 'Custom name' }) }} -{{ bitbag_cms_render_link_for_code('code', {}, 'custom/template.html.twig') }} -{{ bitbag_cms_get_link_for_code('code') }} -{{ bitbag_cms_render_link_for_code('wrong-code', { notFoundMessage: 'Page not found' }) }} -{{ bitbag_cms_get_link_for_code('wrong-code', { notFoundMessage: 'Page not found' }) }} - +{{ render(path('sylius_cms_shop_page_show', {'slug' : 'about'})) }} ``` -Will render: +### Visiting the page -```html -Name when linked -Custom name - -/{_locale}/pages/{slug} -Page not found -Page not found -``` +Page URL is generated based on the page slug. Full link looks like this: `domain.com/{locale}/page/{slug}`. ## Customization -If you don't know how to override templates yet, +### Override page template + +If you don't know how to override templates yet, read [Sylius template customization guide](http://docs.sylius.org/en/latest/customization/template.html). -You can create a template under `app/Resources/BitBagSyliusCmsPlugin/views/Shop/Page` location. +You can create a template under `app/templates/bundles/SyliusCmsPlugin/Shop/Page` location. Available templates you can override can be found under [this location](../src/Resources/views/Shop/Page). + +### Custom Page Templates + +For more information about custom page templates, check the [documentation](templates.md). diff --git a/doc/pages_cms.png b/doc/pages_cms.png index 711a53e97..1ab5fdc97 100644 Binary files a/doc/pages_cms.png and b/doc/pages_cms.png differ diff --git a/doc/pages_cms_result_1.png b/doc/pages_cms_result_1.png index 094238046..da3100824 100644 Binary files a/doc/pages_cms_result_1.png and b/doc/pages_cms_result_1.png differ diff --git a/doc/pages_cms_result_2.png b/doc/pages_cms_result_2.png index 8e329eac8..3898426d0 100644 Binary files a/doc/pages_cms_result_2.png and b/doc/pages_cms_result_2.png differ diff --git a/doc/pages_create_cms.png b/doc/pages_create_cms.png index df577ae35..d6c6689dd 100644 Binary files a/doc/pages_create_cms.png and b/doc/pages_create_cms.png differ diff --git a/doc/section_cms_result.png b/doc/section_cms_result.png deleted file mode 100644 index e6d365051..000000000 Binary files a/doc/section_cms_result.png and /dev/null differ diff --git a/doc/sections.md b/doc/sections.md deleted file mode 100644 index 755c28c69..000000000 --- a/doc/sections.md +++ /dev/null @@ -1,20 +0,0 @@ -# Sections - -With sections, you can organize your blocks and pages under some specific categories. -For instance, you can create a Blog section and display pages and blocks under it. - -## General usage - -In order to render a page by section code, use: - -```twig - - {{ 'app.ui.blog'|trans }} - -``` - -If you want to list blocks by specific section, use: - -```twig -{{ render(path('bitbag_sylius_cms_plugin_shop_block_index_by_section_code', {'sectionCode' : 'blog', 'template' : '@BitBagSyliusCmsPlugin/Shop/Block/index.html.twig'})) }} -``` diff --git a/doc/sections_cms.png b/doc/sections_cms.png deleted file mode 100644 index b386589ba..000000000 Binary files a/doc/sections_cms.png and /dev/null differ diff --git a/doc/sections_create_cms.png b/doc/sections_create_cms.png deleted file mode 100644 index abcb65a86..000000000 Binary files a/doc/sections_create_cms.png and /dev/null differ diff --git a/doc/sitemap.md b/doc/sitemap.md deleted file mode 100644 index c3c90f812..000000000 --- a/doc/sitemap.md +++ /dev/null @@ -1,11 +0,0 @@ -# Sitemap - -This plugin suggests to install the Sylius sitemap plugin. The plugin is not installed automatically, but to install run: - -```bash - $ composer require stefandoorn/sitemap-plugin ^2.0@alpha -``` - -It's already configured after installation and contains a page & section provider. - -For more information, read the original [SitemapPlugin documentation](https://github.com/stefandoorn/sitemap-plugin). diff --git a/doc/templates.md b/doc/templates.md new file mode 100644 index 000000000..d32b6f821 --- /dev/null +++ b/doc/templates.md @@ -0,0 +1,24 @@ +# Page/Block Templates + +Templates allow you to define and select the layout of your pages and blocks. + +## General usage + +By default, the blocks and pages have its own templates. You can create your own templates and use it in specific blocks or pages. + +### Creating a new template + +1. Go to the `config/packages/cms_plugin.yaml` file. +2. Define your templates in following format: +```yaml +sylius_cms: + templates: + pages: + - "@SyliusCMSPlugin/Shop/MyPage/template.twig" + - "@SyliusCMSPlugin/Shop/MySecondPage/template.twig" + blocks: + - "@SyliusCMSPlugin/Shop/MyPage/template.twig" + - "@SyliusCMSPlugin/Shop/MySecondPage/template.twig +``` +3. Create a new template file. For example, `templates/bundles/SyliusCMSPlugin/Shop/MyPage/template.twig`. +4. Go to the Block/Page form and select your template from the list. diff --git a/doc/twig-functions-in-admin.md b/doc/twig-functions-in-admin.md deleted file mode 100644 index 209aeb957..000000000 --- a/doc/twig-functions-in-admin.md +++ /dev/null @@ -1,27 +0,0 @@ -# Using Twig functions in admin panel - -With CMS 2.0+, you can use some Twig functions in the admin panel content. It's extremely helpful -if you wish to render a block within a page, or what's even more common - a media, for instance an -image or video. - -So far, only following functions are allowed: - -```yaml -parameters: - bitbag_cms.twig.admin_functions: - - bitbag_cms_render_block - - bitbag_cms_render_media -``` - -As this is a parameter, you can easily customize its value in your `config.yml`. - -**Note:** - -*With the parser, you are supposed to use the function with `{{ function_name('foo', 'bar') }}` format. -All characters, including spaces and apostrophes are recognized. Only string parameters are allowed.* - -*If for some reason the function would not be able to execute, an empty string result will be returned.* - -*To render the interpretable content, you need to use a special `{{ bitbag_cms_render_content([resource]) }}` Twig function. -The resource needs to implement [ContentableInterface](../src/Entity/ContentableInterface.php). -For an example, take a look at the Block's [show.html.twig](../src/Resources/views/Shop/Block/show.html.twig)* file. diff --git a/doc/use_case.md b/doc/use_case.md index a1c912296..0d23bcfb1 100644 --- a/doc/use_case.md +++ b/doc/use_case.md @@ -1,6 +1,6 @@ # What is and how to use Sylius CMS Plugin -BitBag Sylius CMS Plugin is a plugin developed for Sylius, +CMS Plugin is a plugin developed for Sylius, a popular open-source e-commerce system based on Symfony. The plugin enhances Sylius with advanced content management capabilities, allowing the creation, editing, and publication of dynamic CMS (Content Management System) pages within an e-commerce store. @@ -12,8 +12,8 @@ This empowers businesses to easily adapt their store's content to meet current n ## What Sylius CMS Plugin provides us with -When using the BitBag Sylius CMS Plugin, administrators gain access to various tiles within the admin panel, each serving a specific purpose. -These tiles include Blocks, Media, Pages, FAQs, and Sections. +When using the Sylius CMS Plugin, administrators gain access to various tiles within the admin panel, each serving a specific purpose. +These tiles include Collections, Templates, Pages, Blocks and Media. ## Brief overview of what each tile offers @@ -23,65 +23,66 @@ In admin panel, the whole CMS functionality is located under "Content Management Our CMS Plugin allows you to manage: -* Sections - the containers for blocks -* Blocks - separate parts for the content -* Media - files, that can be attached to the page -* Pages - whole pages, obtainable by the link -* FAQ - the simple mechanism for Frequently Asked Questions function +* **Collections** - responsible for grouping the pages/blocks/media +* **Content Templates** - allows to create a template of content elements for the page or block +* **Pages** - whole pages, obtainable by the link +* **Blocks** - separate parts for the content, composed of the content elements +* **Media** - images, videos, etc. that can be used in other segments of the CMS --- -### Sections: -The Sections tile allows administrators to create and manage sections within CMS pages. +### Collections: -Sections serve as containers for content blocks and provide a structured way to organize content. -By utilizing sections, administrators can easily arrange and customize the layout of CMS pages to achieve the desired visual and informational structure. +The Collections tile allows administrators to create and manage collections within CMS pages. -![Screenshot showing content management config in admin](sections_cms.png) +Collections serve as containers for blocks, pages, media and provide a structured way to organize content. +By utilizing collections, administrators can group related content elements together, such as blog posts, product listings, or promotional banners. -More information about Sections you can get [here](use_case_sections.md). +![Screenshot showing content management config in admin](collections_cms.png) -### Blocks -The Blocks tile allows administrators to create and manage reusable content blocks. - -The Blocks can be utilized across different CMS pages, providing flexibility and consistency in content presentation. Blocks can contain text, images, videos, or any other desired content elements. +More information about Collections you can get [here](use_case_collections.md). -![Screenshot showing content management config in admin](blocks_cms.png) +### Content Templates: -More information about Blocks you can get [here](use_case_blocks.md). - -### Media -The Media tile provides a centralized hub for managing media files within the CMS. +The Content Templates tile allows administrators to create and manage templates built from content elements skeletons. -Administrators can upload and organize images, videos, and other media assets. The files can then be easily inserted into CMS pages, enriching the content with visual elements. - -![Screenshot showing content management config in admin](media_cms.png) - -More information about Media you can get [here](use_case_media.md). +![Screenshot showing content management config in admin](content_templates_cms.png) ### Pages: + The Pages tile is where administrators can create, edit, and organize CMS pages. -It enables the creation of various types of pages, such as the homepage, informational pages, or blog posts. Administrators can add content, images, and other media, customize the layout, and manage page hierarchy. +It enables the creation of various types of pages, such as the homepage, informational pages, or blog posts. ![Screenshot showing content management config in admin](pages_cms.png) More information about Pages you can get [here](use_case_pages.md). -### FAQ -The FAQ tile is specifically designed to manage frequently asked questions. +### Blocks -Administrators can create question-and-answer pairs, categorize them, and make them available to customers on relevant pages. This helps provide clear information and addresses common queries for a seamless customer experience. +The Blocks tile allows administrators to create and manage blocks built from content elements. -![Screenshot showing content management config in admin](faq_cms.png) +The Blocks can be rendered in twig templates, providing flexibility and consistency in content presentation. -More information about the FAQ you can get [here](use_case_faq.md). +![Screenshot showing content management config in admin](blocks_cms.png) + +More information about Blocks you can get [here](use_case_blocks.md). + +### Media + +The Media tile provides a centralized hub for managing media files within the CMS. + +Administrators can upload and organize images, videos, and other media assets. The files can then be easily used in other parts of the CMS. + +![Screenshot showing content management config in admin](media_cms.png) + +More information about Media you can get [here](use_case_media.md). ## Summary -In summary, the BitBag Sylius CMS Plugin provides administrators with a range of tiles in the admin panel, including [Sections](use_case_sections.md), [Blocks](use_case_blocks.md), -[Media](use_case_media.md), [Pages](use_case_pages.md) and [FAQ](use_case_faq.md). +In summary, the Sylius CMS Plugin provides administrators with a range of tiles in the admin panel, +including [Collections](use_case_collections.md), [Content Templates](use_case_content_templates.md), [Pages](use_case_pages.md), [Blocks](use_case_blocks.md), [Media](use_case_media.md). -These tiles offer functionalities for managing reusable content blocks, media assets, CMS pages, frequently asked questions, -and page sections. Together, they enable administrators to efficiently create, edit, and organize content within the Sylius e-commerce system, +These tiles offer functionalities for managing CMS segments. +Together, they enable administrators to efficiently create, edit, and organize content within the Sylius e-commerce system, resulting in a more engaging and personalized user experience. diff --git a/doc/use_case_blocks.md b/doc/use_case_blocks.md index 8096e1b5c..bda630961 100644 --- a/doc/use_case_blocks.md +++ b/doc/use_case_blocks.md @@ -1,6 +1,6 @@ # Blocks -With the BitBag SyliusCmsPlugin, administrators can arrange content blocks within sections, including the product page. +With the SyliusCmsPlugin, administrators can create and manage blocks built from content elements. This allows for customized content presentation, showcasing product features, promotions, and relevant information. @@ -20,7 +20,7 @@ By following the steps below, administrators can easily add blocks and customize 1. Please access the administrator panel of the Sylius e-commerce system. 2. Navigate to the CMS section or the designated area for managing blocks. 3. Locate the option to create a new block and click on it. -4. Fill in the required fields in the block creation form, such as the code and content of the block. +4. Fill in the required fields in the block creation form, such as the code and name. 5. Save the block after filling in the necessary details and selecting any desired associations. 6. Repeat the process to add additional blocks, as needed. 7. After refreshing the store page, the newly implemented changes should now be visible. @@ -29,9 +29,9 @@ By following the steps below, administrators can easily add blocks and customize In the form, you will find additional fields, which will help you with your e-commerce related content: -- Products - You can select specific products that are associated with the block. This allows the block to be displayed on the product pages of the selected products. -- Sections - You can choose the sections where the block should be placed. This helps in organizing and structuring the block within the relevant sections of the website. -- Taxons - This field allows you to select specific taxonomies or categories associated with the block. By choosing relevant taxons, the block can be displayed on the pages related to those categories. +- Display for products - You can select specific products that are associated with the block. This allows the block to be displayed on the product pages of the selected products. +- Display for products in taxon - This field allows you to select specific taxon associated with the block. By choosing relevant taxon, the block will be displayed on the product pages related to those taxon. Only "Main Taxon" is taken. +- Display for taxons - This field allows you to select specific taxonomies associated with the block. By choosing relevant taxons, the block can be displayed on the pages related to those taxons. The mentioned form: diff --git a/doc/use_case_collections.md b/doc/use_case_collections.md new file mode 100644 index 000000000..4b5b97185 --- /dev/null +++ b/doc/use_case_collections.md @@ -0,0 +1,40 @@ +# Collections + +With collections, you can organize your blocks, pages and media under specific categories. +For instance, you can create a Blog collection and display pages under it. + +Collections in the Sylius CMS Plugin serve as containers where various elements, such as content blocks, CMS pages, +and media, can be placed. These collections allow administrators to organize and manage the layout and presentation of content on pages. + +The ability to place blocks, pages, and media within collections provides full control over the appearance and structure of CMS pages, +enabling the creation of visually appealing and cohesive content layouts. Collections offer flexibility in designing pages, +allowing for customization and adaptation of displayed content to user preferences and marketing strategies. + +**Note.** If you haven't implemented the collection properly in your code yet, please visit the [Collections](collections.md) tech doc. + +## The process of creating a Collection: + +By following the steps below, administrators can add collections by providing the code, name and type for each collection. +These collections can be then utilized within the CMS pages for organizing and structuring content. + +1. Please access the administrator panel of the Sylius e-commerce system. +2. Navigate to the CMS section or the designated area for managing collections. +3. Select the option to create a new collection. +4. Fill in the required fields in the collection creation form, such as the code, name and type of the collection. +5. Save the collection after providing the necessary details. +6. Repeat the process to add additional collections, as needed. +7. After refreshing the store page, the newly implemented changes should now be visible. + +The mentioned form: + +![Screenshot showing content management config in admin](collections_create_cms.png) + +## Result possible to achieve on the front of the store: + +It's possible to attach [Blocks](use_case_blocks.md), [Media](use_case_media.md) and [Pages](use_case_pages.md) to the Collections. This makes you able to [display all](collections.md) the content attached to the single Collection. + +The image below presents you a sample result of Collection rendered on the product page: + +![Screenshot showing content management config in admin](collections_cms_result.png) + + diff --git a/doc/use_case_content_templates.md b/doc/use_case_content_templates.md new file mode 100644 index 000000000..fed178459 --- /dev/null +++ b/doc/use_case_content_templates.md @@ -0,0 +1,20 @@ +# Content Templates + +In this plugin, content templates are responsible for defining the structure of content elements, which can be used in blocks and pages. + +## The process of creating a Content Template + +By following these steps below, administrators can easily add and manage content templates. + +1. Please access the administrator panel of the Sylius e-commerce system. +2. Navigate to the CMS section or the designated area for managing content templates. +3. Select the option to create a new content template item. +4. Fill in the required fields in the content template creation form, such as the name and type. +5. Add some content elements. +6. Save the content template item after filling in the necessary details. +7. Repeat the process to add additional content template items, as needed. +8. Now you can use content templates in blocks and pages. + +The mentioned form: + +![Screenshot showing content template creation form in admin](content_template_create_cms.png) diff --git a/doc/use_case_faq.md b/doc/use_case_faq.md deleted file mode 100644 index 4b81dbe81..000000000 --- a/doc/use_case_faq.md +++ /dev/null @@ -1,30 +0,0 @@ -# Frequently Asked Questions - -FAQ is a common part of each eCommerce website. You can add them in your admin panel by configuring question, answer, and position. All results will be paginated in the storefront. - -The BitBag SyliusCmsPlugin allows administrators to add and display questions and answers within the FAQ section on various pages, including the product page. - -This feature enables the easy management and presentation of frequently asked questions, providing valuable information to customers within a dedicated FAQ section. - -**Note.** If you haven't implemented the FAQ properly in your code yet, please visit [FAQ](faqs.md) tech doc. - -## The process of creating an FAQ - -1. Please access the administrator panel of the Sylius e-commerce system. -2. Navigate to the CMS section or the specific area designated for managing FAQs. -3. Locate the option to add a new FAQ entry or question. -4. Enter the question in the provided field. -5. Add the corresponding answer to the question in the designated space. -6. Save the newly created FAQ entry. -7. Repeat the process for additional questions and answers as needed. -8. After refreshing the store page, the newly implemented changes should now be visible. - -The mentioned form: - -![Screenshot showing content management config in admin](faq_create_cms.png) - -## Result on the front of the store: - -The image below displays a rendered FAQ on your Sylius Store: - -![Screenshot showing content management config in admin](faq_cms_result.png) diff --git a/doc/use_case_media.md b/doc/use_case_media.md index 3bcacc8ae..9197014a8 100644 --- a/doc/use_case_media.md +++ b/doc/use_case_media.md @@ -2,7 +2,7 @@ In this plugin, media represents digital assets, for instance, an image, a video, or a simple PDF file. -The BitBag SyliusCmsPlugin enables administrators to add and display various types of media, such as images, videos, and files, in desired locations throughout the website. +The Sylius CMS Plugin enables administrators to add and display various types of media, such as images, videos, and files, in desired locations throughout the website. This functionality allows for the seamless integration of media elements using HTML tags, providing a visually engaging experience for users. @@ -16,7 +16,7 @@ Currently, it supports the following media types: ## The process of creating a Media -By following these steps bellow, administrators can easily add media items and customize their associations with products and sections. This provides control over where the media is displayed, ensuring it appears in the desired locations throughout the website. +By following these steps bellow, administrators can easily add and manage media. 1. Please access the administrator panel of the Sylius e-commerce system. 2. Navigate to the CMS section or the designated area for managing media. @@ -30,8 +30,11 @@ By following these steps bellow, administrators can easily add media items and c In the form, you will find additional fields, which will help you with your e-commerce related content: -- Products - You can select specific products to associate with the media item. This ensures that the media will be displayed on the product pages of the selected products. -- Sections - You can choose the sections where the media should be placed. This allows for precise positioning and organization of the media within the relevant sections of the website. +- Collections - You can choose the collections where the media should be placed. This allows for precise positioning and organization of the media within the relevant collections of the website. +- Translations: + - Alt - The alternative text for the media item. + - Link - The URL in which the media item should redirect to. + - Link content - Description of the media item link. The mentioned form: @@ -39,7 +42,4 @@ The mentioned form: ## Result possible to achieve on the front of the store: -The image below presents you a sample result of [Section](sections.md) rendered on the product page, which contains [Blocks](blocks.md) and Media (image, video and downloadable PDF file): - -![Screenshot showing content management config in admin](media_cms_result.png) - +![Screenshot showing media result in front page](media_cms_result.png) diff --git a/doc/use_case_pages.md b/doc/use_case_pages.md index c6c8e703e..bb17773c9 100644 --- a/doc/use_case_pages.md +++ b/doc/use_case_pages.md @@ -2,12 +2,9 @@ Pages represent a customizable web page, you can adjust them to your needs in the admin panel. -With the BitBag SyliusCmsPlugin, administrators can associate related products with CMS pages, displaying them in the designated section. +With the Sylius CMS Plugin, administrators can create page content using content elements section. -This feature allows for targeted product recommendations and cross-selling opportunities within the content. - -Additionally, administrators can incorporate media elements, such as images and videos, into the pages, -enriching the visual presentation and engaging users. +Additionally, administrators can set teaser image, title and content to be displayed on the pages collection listing. The flexibility of the plugin empowers administrators to create compelling CMS pages that seamlessly integrate product information and multimedia content, enhancing the overall user experience. @@ -16,22 +13,24 @@ information and multimedia content, enhancing the overall user experience. ## The process of creating a Page -By following the steps below, administrators can add pages and associate them with products, allowing the pages to display relevant product information. This integration enhances the browsing experience by providing seamless access to product details directly from the associated pages. +By following the steps below, administrators can add pages. 1. Please access the administrator panel of the Sylius e-commerce system. 2. Navigate to the CMS section or the designated area for managing pages. 3. Select the option to create a new page. -4. Fill in the required fields in the page creation form, such as the name, content, and slug. -5. Save the page after filling in the necessary details and selecting any desired associations. +4. Fill in the required fields in the page creation form, such as the name, code and slug. +5. Save the page after filling in the necessary details. 6. Repeat the process to add additional pages, as needed. 7. After refreshing the store page, the newly implemented changes should now be visible. -### Optional configuration +### Additional configuration -In the form, you will find fields, which will help you with your e-commerce related content: +In the form, you can also set SEO settings for the page: +- Meta title +- Meta keywords +- Meta description -- Products - You can associate specific products with the page. This means that the page will display and provide information related to the selected products. -- Sections - You can choose the sections where the page should be placed, ensuring proper organization and positioning of the page within the website's structure. +Additionally, you can set the page teaser image, title and content to be displayed on the pages collection listing. The mentioned form: @@ -39,11 +38,11 @@ The mentioned form: ## Result possible to achieve on the front of the store: -The image below displays a [Section](sections.md), to which we have attached two pages: +The image below displays a simple Blog page with listing of posts: ![Screenshot showing content management config in admin](pages_cms_result_1.png) -Additionally, every page has its own slug, so you can access its all contents by visiting it by a full URL: +The image below displays a simple Blog post: ![Screenshot showing content management config in admin](pages_cms_result_2.png) diff --git a/doc/use_case_sections.md b/doc/use_case_sections.md deleted file mode 100644 index 0f5405eba..000000000 --- a/doc/use_case_sections.md +++ /dev/null @@ -1,39 +0,0 @@ -# Sections - -With sections, you can organize your blocks and pages under specific categories. -For instance, you can create a Blog section and display pages and blocks under it. - -Sections in the BitBag SyliusCmsPlugin serve as containers where various elements, such as content blocks, CMS pages, -and media, can be placed. These sections allow administrators to organize and manage the layout and presentation of content on pages. - -The ability to place blocks, pages, and media within sections provides full control over the appearance and structure of CMS pages, -enabling the creation of visually appealing and cohesive content layouts. Sections offer flexibility in designing pages, -allowing for customization and adaptation of displayed content to user preferences and marketing strategies. - -**Note.** If you haven't implemented the section properly in your code yet, please visit the [Sections](sections.md) tech doc. - -## The process of creating a Section: - -By following the steps below, administrators can add sections by providing the code and name for each section. These sections can be then utilized within the CMS pages for organizing and structuring content. - -1. Please access the administrator panel of the Sylius e-commerce system. -2. Navigate to the CMS section or the designated area for managing sections. -3. Select the option to create a new section. -4. Fill in the required fields in the section creation form, such as the code and name of the section. -5. Save the section after providing the necessary details. -6. Repeat the process to add additional sections, as needed. -7. After refreshing the store page, the newly implemented changes should now be visible. - -The mentioned form: - -![Screenshot showing content management config in admin](sections_create_cms.png) - -## Result possible to achieve on the front of the store: - -It's possible to attach [Blocks](use_case_blocks.md), [Media](use_case_media.md) and [Pages](use_case_pages.md) to the Sections. This makes you able to [display all](sections.md) the content attached to the single Section. - -The image below presents you a sample result of Section rendered on the product page, to which we attached Pages to get the simple Blog result: - -![Screenshot showing content management config in admin](section_cms_result.png) - - diff --git a/doc/wysiwyg.md b/doc/wysiwyg.md index a8991eb7b..399a76ca1 100644 --- a/doc/wysiwyg.md +++ b/doc/wysiwyg.md @@ -9,9 +9,6 @@ is being created. You can use a custom [WysiwygType](../src/Form/Type/WysiwygType.php) any place you want the CKEditor to appear in. Take [the BlockTranslationType](../src/Form/Type/Translation/BlockTranslationType.php) as an example. -**Note:** -*In the WYSIWYG fields, you can use Twig function nesting. Read more [here](twig-functions-in-admin.md).* - ## Configuration If you want to customize any behavior of the CKEditor, you have to override one of these files: [CKEditor config](../src/Resources/config/fos_ck_editor/fos_ck_editor.yml) or [CKEditor js config](../src/Resources/views/Form/ckeditor_widget.html.twig) diff --git a/src/Resources/public/build/bitbag-cms-shop.js b/etc/build/.gitkeep similarity index 100% rename from src/Resources/public/build/bitbag-cms-shop.js rename to etc/build/.gitkeep diff --git a/features/admin/adding_block.feature b/features/admin/adding_block.feature index 0b15eb814..b7c72bb3f 100644 --- a/features/admin/adding_block.feature +++ b/features/admin/adding_block.feature @@ -12,20 +12,153 @@ Feature: Adding blocks Scenario: Adding block When I go to the create block page And I fill the code with "store_description" - And I fill the content with "

We have the best candies on the internet!

" + And I fill the name with "Store Description" And I add it Then I should be notified that the block has been created @ui @javascript - Scenario: Adding block with sections - Given there are existing sections named "Blog" and "Homepage" + Scenario: Adding block with collections + Given there are existing collections named "Blog" and "Homepage" When I go to the create block page And I fill the code with "intro" - And I add "Blog" and "Homepage" sections to it - And I fill the content with "Hello world!" + And I fill the name with "Intro" + And I add "Blog" and "Homepage" collections to it And I add it Then I should be notified that the block has been created + @ui @javascript + Scenario: Adding block with textarea content element + When I go to the create block page + And I fill the code with "intro" + And I fill the name with "Intro" + And I click on Add button in Content elements section + And I select "Textarea" content element + And I add a textarea content element with "Welcome to our store" content + And I add it + Then I should be notified that the block has been created + And I should see newly created "Textarea" content element in Content elements section + + @ui @javascript + Scenario: Adding block with single media content element + Given there is an existing media with "image_1" code and name "Image 1" + When I go to the create block page + And I fill the code with "intro" + And I fill the name with "Intro" + And I click on Add button in Content elements section + And I select "Single media" content element + And I add a single media content element with name "Image 1" + And I add it + Then I should be notified that the block has been created + And I should see newly created "Single media" content element in Content elements section + + @ui @javascript + Scenario: Adding block with multiple media content element + Given there is an existing media with names "Image 1" and "Image 2" + When I go to the create block page + And I fill the code with "intro" + And I fill the name with "Intro" + And I click on Add button in Content elements section + And I select "Multiple media" content element + And I add a multiple media content element with names "Image 1" and "Image 2" + And I add it + Then I should be notified that the block has been created + And I should see newly created "Single media" content element in Content elements section + + @ui @javascript + Scenario: Adding block with heading content element + When I go to the create block page + And I fill the code with "intro" + And I fill the name with "Intro" + And I click on Add button in Content elements section + And I select "Heading" content element + And I add a heading content element with type "H3" and "Welcome to our store" content + And I add it + Then I should be notified that the block has been created + And I should see newly created "Heading" content element in Content elements section + + @ui @javascript + Scenario: Adding block with products carousel content element + Given the store has "iPhone 8" and "iPhone X" products + When I go to the create block page + And I fill the code with "intro" + And I fill the name with "Intro" + And I click on Add button in Content elements section + And I select "Products carousel" content element + And I add a products carousel content element with "iPhone 8" and "iPhone X" products + And I add it + Then I should be notified that the block has been created + And I should see newly created "Products carousel" content element in Content elements section + + @ui @javascript + Scenario: Adding block with products carousel by taxon content element + Given the store has "Smartphones" taxonomy + When I go to the create block page + And I fill the code with "intro" + And I fill the name with "Intro" + And I click on Add button in Content elements section + And I select "Products carousel by Taxon" content element + And I add a products carousel by taxon content element with "Smartphones" taxonomy + And I add it + Then I should be notified that the block has been created + And I should see newly created "Products carousel by Taxon" content element in Content elements section + + @ui @javascript + Scenario: Adding block with products grid content element + Given the store has "iPhone 8" and "iPhone X" products + When I go to the create block page + And I fill the code with "intro" + And I fill the name with "Intro" + And I click on Add button in Content elements section + And I select "Products grid" content element + And I add a products grid content element with "iPhone 8" and "iPhone X" products + And I add it + Then I should be notified that the block has been created + And I should see newly created "Products grid" content element in Content elements section + + @ui @javascript + Scenario: Adding block with products grid by taxon content element + Given the store has "Smartphones" taxonomy + When I go to the create block page + And I fill the code with "intro" + And I fill the name with "Intro" + And I click on Add button in Content elements section + And I select "Products grid by Taxon" content element + And I add a products grid by taxon content element with "Smartphones" taxonomy + And I add it + Then I should be notified that the block has been created + And I should see newly created "Products grid by Taxon" content element in Content elements section + + @ui @javascript + Scenario: Adding block with taxons list content element + Given the store classifies its products as "Smartphones" and "Laptops" + When I go to the create block page + And I fill the code with "intro" + And I fill the name with "Intro" + And I click on Add button in Content elements section + And I select "Taxons list" content element + And I add a taxons list content element with "Smartphones" and "Laptops" taxonomy + And I add it + Then I should be notified that the block has been created + And I should see newly created "Taxons list" content element in Content elements section + + @ui @javascript + Scenario: Adding block with two content elements + Given there is an existing media with names "Image 1" and "Image 2" + And the store classifies its products as "Smartphones" and "Laptops" + When I go to the create block page + And I fill the code with "intro" + And I fill the name with "Intro" + And I click on Add button in Content elements section + And I select "Taxons list" content element + And I add a taxons list content element with "Smartphones" and "Laptops" taxonomy + And I click on Add button in Content elements section + And I select "Multiple media" content element + And I add a multiple media content element with names "Image 1" and "Image 2" + And I add it + Then I should be notified that the block has been created + And I should see newly created "Taxons list" content element in Content elements section + And I should see newly created "Multiple media" content element in Content elements section + @ui Scenario: Trying to add block with existing code Given there is an existing block with "homepage_image" code @@ -43,7 +176,19 @@ Feature: Adding blocks @ui Scenario: Trying to add block with too long data When I go to the create block page - And I fill "Code, Name, Content" fields with 251 characters + And I fill "Code, Name" fields with 251 characters And I try to add it Then I should be notified that "Code, Name" fields are too long + @ui @javascript + Scenario: Adding block with content template + Given there is an existing content template named "Homepage" with "Block" type that contains "Textarea, Single media" content elements + When I go to the create block page + And I fill the code with "intro" + And I fill the name with "Intro" + And I select "Homepage" content template + And I confirm that I want to use this template + And I add it + Then I should be notified that the block has been created + And I should see newly created "Textarea" content element in Content elements section + And I should see newly created "Single media" content element in Content elements section diff --git a/features/admin/adding_section.feature b/features/admin/adding_collection.feature similarity index 53% rename from features/admin/adding_section.feature rename to features/admin/adding_collection.feature index 142cabcf7..6001473c2 100644 --- a/features/admin/adding_section.feature +++ b/features/admin/adding_collection.feature @@ -1,45 +1,45 @@ -@managing_sections -Feature: Adding new section +@managing_collections +Feature: Adding new collection In order to present more sophisticated content As an Administrator - I want to be able to add new CMS sections to the store + I want to be able to add new CMS collections to the store Background: Given the store operates on a single channel in "United States" And I am logged in as an administrator @ui - Scenario: Adding new section - When I go to the create section page + Scenario: Adding new collection + When I go to the create collection page And I fill the code with "blog" And I fill the name with "Blog" And I add it - Then I should be notified that new section has been created + Then I should be notified that new collection has been created @ui - Scenario: Trying to add a section with an existing code - Given there is an existing section with "blog" code - When I go to the create section page + Scenario: Trying to add a collection with an existing code + Given there is an existing collection with "blog" code + When I go to the create collection page And I fill the code with "blog" And I try to add it - Then I should be notified that there is already an existing section with provided code + Then I should be notified that there is already an existing collection with provided code @ui - Scenario: Trying to add section with blank data - When I go to the create section page + Scenario: Trying to add collection with blank data + When I go to the create collection page And I try to add it Then I should be notified that "Code, Name" fields cannot be blank @ui - Scenario: Trying to add section with too short data - When I go to the create section page + Scenario: Trying to add collection with too short data + When I go to the create collection page And I fill "Code, Name" fields with 1 character And I try to add it Then I should be notified that "Code, Name" fields are too short @ui - Scenario: Trying to add section with too long data - When I go to the create section page + Scenario: Trying to add collection with too long data + When I go to the create collection page And I fill "Code, Name" fields with 251 characters And I try to add it Then I should be notified that "Code, Name" fields are too long diff --git a/features/admin/adding_content_template.feature b/features/admin/adding_content_template.feature new file mode 100644 index 000000000..b6fdb411e --- /dev/null +++ b/features/admin/adding_content_template.feature @@ -0,0 +1,67 @@ +@managing_content_templates +Feature: Adding cms templates + In order to create templates + As an Administrator + I want to be able to add new templates + + Background: + Given the store operates on a single channel in "United States" + And I am logged in as an administrator + + @ui + Scenario: Creating template with type page + When I go to the create template page + And I fill the name with "Test template" + And I choose "Page" in Type field + And I add it + Then I should be notified that the template has been created + + @ui + Scenario: Creating template with type block + When I go to the create template page + And I fill the name with "Test template" + And I choose "Block" in Type field + And I add it + Then I should be notified that the template has been created + + @ui @javascript + Scenario: Creating template with content elements + When I go to the create template page + And I fill the name with "Test template" + And I choose "Page" in Type field + And I click on Add button in Content elements section + And I select "Textarea" content element + And I click on Add button in Content elements section + And I select "Single media" content element + And I add it + Then I should be notified that the template has been created + And I should see newly created "Textarea" content element in Content elements section + And I should see newly created "Single media" content element in Content elements section + + @ui + Scenario: Trying to add template with existing name + Given there is a template in the store with "New template" name + When I go to the create template page + And I fill the name with "New template" + And I try to add it + Then I should be notified that there is already existing template with provided name + + @ui + Scenario: Adding new template with blank data + When I go to the create template page + And I add it + And I should be notified that "Name" field cannot be blank + + @ui + Scenario: Trying to add a template with too short data + When I go to the create template page + And I fill the name with "X" + And I try to add it + Then I should be notified that "Name" field is too short + + @ui + Scenario: Trying to add a template with too long data + When I go to the create template page + And I fill "Name" field with 251 characters + And I try to add it + Then I should be notified that "Name" field is too long diff --git a/features/admin/adding_frequently_asked_question.feature b/features/admin/adding_frequently_asked_question.feature deleted file mode 100644 index 8dc1d4adc..000000000 --- a/features/admin/adding_frequently_asked_question.feature +++ /dev/null @@ -1,57 +0,0 @@ -@managing_frequently_asked_questions -Feature: Adding frequently asked question - In order to present frequently asked questions and answers in my store - As an Administrator - I want to be able to add new frequently asked question with answer - - Background: - Given I am logged in as an administrator - And the store operates on a single channel in "United States" - - @ui - Scenario: Adding frequently asked question - When I go to the create frequently asked question page - And I fill the code with "each_order_payment" - And I set the position to 1 - And I fill the question with "Should I pay for each order?" - And I set the answer to "Yes" - And I add it - Then I should be notified that a new frequently asked question has been created - - @ui @unstable - Scenario: Adding new frequently asked question with long data - When I go to the create frequently asked question page - And I fill the code with "whats_the_js_framework_of_the_week" - And I set the position to 1 - And I fill "Question, Answer" fields with 1500 characters - And I add it - Then I should be notified that a new frequently asked question has been created - - @ui - Scenario: Trying to add frequently asked question with existing code - Given there is an existing frequently asked question with "stupid_question" code - When I go to the create frequently asked question page - And I fill the code with "stupid_question" - And I try to add it - Then I should be notified that there is already an existing frequently asked question with provided code - - @ui - Scenario: Trying to add new frequently asked question with blank data - When I go to the create frequently asked question page - And I add it - Then I should be notified that "Code, Position, Question, Answer" fields cannot be blank - - @ui - Scenario: Trying to add new frequently asked question with too short data - When I go to the create frequently asked question page - And I fill "Question, Answer" fields with 1 character - And I add it - Then I should be notified that "Question, Answer" fields are too short - - @ui - Scenario: Trying to add new frequently asked question with existing position - Given there is an existing frequently asked question with 1 position - When I go to the create frequently asked question page - And I set the position to 1 - And I try to add it - Then I should be notified that there is already an existing frequently asked question with selected position diff --git a/features/admin/adding_media.feature b/features/admin/adding_media.feature index 4b518c67f..0ee4fe3c5 100644 --- a/features/admin/adding_media.feature +++ b/features/admin/adding_media.feature @@ -13,7 +13,6 @@ Feature: Adding new media When I go to the create media page And I fill the code with "image" And I fill the name with "Image" - And I fill the content with "Main image" And I upload the "aston_martin_db_11.jpg" image And I add it Then I should be notified that new media has been created diff --git a/features/admin/adding_page.feature b/features/admin/adding_page.feature index 042a1962c..552fe2072 100644 --- a/features/admin/adding_page.feature +++ b/features/admin/adding_page.feature @@ -14,7 +14,6 @@ Feature: Adding new page And I fill the code with "page_with_title" And I fill the slug with "page_with_title" And I fill the name with "page_with_title" - And I fill the content with "This is a page with a title set by us." And I add it Then I should be notified that the page has been created @@ -26,21 +25,6 @@ Feature: Adding new page And I fill the name with "Top 5 outfits for this summer" And I fill the meta keywords with "TOP 5 summer outfit trends, outfits, Ralph Lauren" And I fill the meta description with "This summer is going to be hot like a pizza." - And I fill the content with "The best looks, trends, inspiration, and shopping picks for summer style." - And I add it - Then I should be notified that the page has been created - - @ui @javascript - Scenario: Adding page with page image - And there is an existing "image" media with "aston-martin" code - When I go to the create page page - And I fill the code with "aston_martin_is_amazing_car" - And I fill the slug with "aston_martin_is_amazing_car" - And I fill the name with "Aston Martin is amazing car" - And I fill the meta keywords with "Aston Martin is amazing car" - And I fill the meta description with "Aston Martin is amazing car for this summer." - And I fill the content with "Aston Martin is amazing car for this summer. Buy it." - And I choose "aston-martin" media as image And I add it Then I should be notified that the page has been created @@ -56,14 +40,14 @@ Feature: Adding new page Scenario: Adding new page with blank data When I go to the create page page And I add it - And I should be notified that "Code, Name, Slug, Content" fields cannot be blank + And I should be notified that "Code, Name" fields cannot be blank @ui Scenario: Trying to add a page with too short data When I go to the create page page - And I fill "Code, Name, Slug, Meta keywords, Meta description, Content" fields with 1 character + And I fill "Code, Name, Slug, Meta keywords, Meta description" fields with 1 character And I try to add it - Then I should be notified that "Code, Name, Slug, Meta keywords, Meta description, Content" fields are too short + Then I should be notified that "Code, Name, Slug, Meta keywords, Meta description" fields are too short @ui @unstable Scenario: Trying to add a page with too long data @@ -74,12 +58,182 @@ Feature: Adding new page @ui @javascript Scenario: Adding page with sections - Given there are existing sections named "Blog" and "Homepage" + Given there are existing collections named "Blog" and "Homepage" When I go to the create page page And I fill the code with "best_day_ever" - And I add "Blog" and "Homepage" sections to it + And I add "Blog" and "Homepage" collections to it And I fill the slug with "Slug" And I fill the name with "Best day ever" - And I fill the content with "This was the best day of my life" And I add it Then I should be notified that the page has been created + + @ui @javascript + Scenario: Adding page with textarea content element + When I go to the create page page + And I fill the code with "my_page" + And I fill the slug with "my_page" + And I fill the name with "My page" + And I click on Add button in Content elements section + And I select "Textarea" content element + And I add a textarea content element with "Welcome to our store" content + And I add it + Then I should be notified that the page has been created + And I should see newly created "Textarea" content element in Content elements section + + @ui @javascript + Scenario: Adding page with single media content element + Given there is an existing media with "image_1" code and name "Image 1" + When I go to the create page page + And I fill the code with "my_page" + And I fill the slug with "my_page" + And I fill the name with "My page" + And I click on Add button in Content elements section + And I select "Single media" content element + And I add a single media content element with name "Image 1" + And I add it + Then I should be notified that the page has been created + And I should see newly created "Single media" content element in Content elements section + + @ui @javascript + Scenario: Adding page with multiple media content element + Given there is an existing media with names "Image 1" and "Image 2" + When I go to the create page page + And I fill the code with "my_page" + And I fill the slug with "my_page" + And I fill the name with "My page" + And I click on Add button in Content elements section + And I select "Multiple media" content element + And I add a multiple media content element with names "Image 1" and "Image 2" + And I add it + Then I should be notified that the page has been created + And I should see newly created "Multiple media" content element in Content elements section + + @ui @javascript + Scenario: Adding page with heading content element + When I go to the create page page + And I fill the code with "my_page" + And I fill the slug with "my_page" + And I fill the name with "My page" + And I click on Add button in Content elements section + And I select "Heading" content element + And I add a heading content element with type "H3" and "Welcome to our store" content + And I add it + Then I should be notified that the page has been created + And I should see newly created "Heading" content element in Content elements section + + @ui @javascript + Scenario: Adding page with products carousel content element + Given the store has "iPhone 8" and "iPhone X" products + When I go to the create page page + And I fill the code with "my_page" + And I fill the slug with "my_page" + And I fill the name with "My page" + And I click on Add button in Content elements section + And I select "Products carousel" content element + And I add a products carousel content element with "iPhone 8" and "iPhone X" products + And I add it + Then I should be notified that the page has been created + And I should see newly created "Products carousel" content element in Content elements section + + @ui @javascript + Scenario: Adding page with products carousel by taxon content element + Given the store has "Smartphones" taxonomy + When I go to the create page page + And I fill the code with "my_page" + And I fill the slug with "my_page" + And I fill the name with "My page" + And I click on Add button in Content elements section + And I select "Products carousel by Taxon" content element + And I add a products carousel by taxon content element with "Smartphones" taxonomy + And I add it + Then I should be notified that the page has been created + And I should see newly created "Products carousel by Taxon" content element in Content elements section + + @ui @javascript + Scenario: Adding page with products grid content element + Given the store has "iPhone 8" and "iPhone X" products + When I go to the create page page + And I fill the code with "my_page" + And I fill the slug with "my_page" + And I fill the name with "My page" + And I click on Add button in Content elements section + And I select "Products grid" content element + And I add a products grid content element with "iPhone 8" and "iPhone X" products + And I add it + Then I should be notified that the page has been created + And I should see newly created "Products grid" content element in Content elements section + + @ui @javascript + Scenario: Adding page with products grid by taxon content element + Given the store has "Smartphones" taxonomy + When I go to the create page page + And I fill the code with "my_page" + And I fill the slug with "my_page" + And I fill the name with "My page" + And I click on Add button in Content elements section + And I select "Products grid by Taxon" content element + And I add a products grid by taxon content element with "Smartphones" taxonomy + And I add it + Then I should be notified that the page has been created + And I should see newly created "Products grid by Taxon" content element in Content elements section + + @ui @javascript + Scenario: Adding page with taxons list content element + Given the store classifies its products as "Smartphones" and "Laptops" + When I go to the create page page + And I fill the code with "my_page" + And I fill the slug with "my_page" + And I fill the name with "My page" + And I click on Add button in Content elements section + And I select "Taxons list" content element + And I add a taxons list content element with "Smartphones" and "Laptops" taxonomy + And I add it + Then I should be notified that the page has been created + And I should see newly created "Taxons list" content element in Content elements section + + @ui @javascript + Scenario: Adding page with two content elements + Given there is an existing media with names "Image 1" and "Image 2" + When I go to the create page page + And I fill the code with "my_page" + And I fill the slug with "my_page" + And I fill the name with "My page" + And I click on Add button in Content elements section + And I select "Single media" content element + And I add a single media content element with name "Image 1" + And I click on Add button in Content elements section + And I select "Multiple media" content element + And I add a multiple media content element with names "Image 1" and "Image 2" + And I add it + Then I should be notified that the page has been created + And I should see newly created "Single media" content element in Content elements section + And I should see newly created "Multiple media" content element in Content elements section + + @ui @javascript + Scenario: Adding page with content template + Given there is an existing content template named "Homepage" with "Page" type that contains "Textarea, Single media" content elements + When I go to the create page page + And I fill the code with "my_page" + And I fill the slug with "my_page" + And I fill the name with "My page" + And I select "Homepage" content template + And I confirm that I want to use this template + And I add it + Then I should be notified that the page has been created + And I should see newly created "Textarea" content element in Content elements section + And I should see newly created "Single media" content element in Content elements section + + @ui @javascript + Scenario: Adding page with with a custom template + Given there is an existing template with "@SyliusCmsPlugin/Shop/Page/custom.html.twig" value + When I go to the create page page + And I fill the code with "my_page" + And I fill the slug with "my-page" + And I fill the name with "My page" + And I select "United States" channel + And I select "@SyliusCmsPlugin/Shop/Page/custom.html.twig" template + And I add it + Then I should be notified that the page has been created + And I go to the "my-page" page + And The rendered page should contain custom layout code + diff --git a/features/admin/managing_blocks.feature b/features/admin/managing_blocks.feature index 22c4b0a44..78aaf6d43 100644 --- a/features/admin/managing_blocks.feature +++ b/features/admin/managing_blocks.feature @@ -18,16 +18,37 @@ Feature: Managing cms blocks @ui @javascript Scenario: Updating block - Given there is a block with "store_phone_number" code and "123456789" content + Given there is a block with "store_phone_number" code When I go to the update "store_phone_number" block page - And I fill the content with "987654321" + And I fill the name with "Store phone number" if the name field is empty And I update it Then I should be notified that the block has been successfully updated + @ui + Scenario: Updating block textarea content element + Given there is a block with "store_phone_number" code and "Textarea" content element + When I go to the update "store_phone_number" block page + And I fill the name with "Store phone number" if the name field is empty + And I change textarea content element value to "New content" + And I update it + Then I should be notified that the block has been successfully updated + And I should see "New content" in the textarea content element + + @ui @javascript + Scenario: Deleting content element in block + Given there is a block with "store_phone_number" code and "Textarea" content element + When I go to the update "store_phone_number" block page + And I fill the name with "Store phone number" if the name field is empty + And I delete the content element + And I update it + Then I should be notified that the block has been successfully updated + And I should not see "Textarea" content element in the Content elements section + @ui Scenario: Disabling block - Given there is an existing block with "bitbag_quote" code - When I go to the update "bitbag_quote" block page + Given there is an existing block with "sylius_quote" code + When I go to the update "sylius_quote" block page + And I fill the name with "BitBag quote" if the name field is empty And I disable it And I update it Then I should be notified that the block has been successfully updated diff --git a/features/admin/managing_collections.feature b/features/admin/managing_collections.feature new file mode 100644 index 000000000..45f15b18f --- /dev/null +++ b/features/admin/managing_collections.feature @@ -0,0 +1,23 @@ +@managing_collections +Feature: Managing collections + In order to present the content in specific collections in my store + As an Administrator + I want to be able to edit and remove existing collections + + Background: + Given the store operates on a single channel in "United States" + Given I am logged in as an administrator + + @ui + Scenario: Deleting collection + Given there is a collection in the store + When I go to the collections page + And I delete this collection + Then I should be notified that the collection has been deleted + And I should see empty list of collections + + @ui + Scenario: Seeing disabled code field while editing a collection + Given there is a collection in the store + When I want to edit this collection + Then the code field should be disabled diff --git a/features/admin/managing_content_templates.feature b/features/admin/managing_content_templates.feature new file mode 100644 index 000000000..7da7d5ae6 --- /dev/null +++ b/features/admin/managing_content_templates.feature @@ -0,0 +1,35 @@ +@managing_content_templates +Feature: Managing cms templates + In order to manage existing templates + As an Administrator + I want to be able to edit and remove existing templates + + Background: + Given the store operates on a single channel in "United States" + And I am logged in as an administrator + + @ui + Scenario: Deleting template + Given there is a template in the store with "Test template" name + When I go to the templates page + And I delete this template + Then I should be notified that the template has been deleted + And I should see empty list of templates + + @ui + Scenario: Updating template + Given there is a template in the store with "Test template" name + When I go to the update "Test template" template page + And I fill the name with "New template" + And I update it + Then I should be notified that the template has been successfully updated + + @ui @javascript + Scenario: Updating template with content elements + Given there is a template in the store with "Test template" name + And there are "Textarea" and "Single media" content elements in this template + When I go to the update "Test template" template page + And I delete "Textarea" content element + And I update it + Then I should be notified that the template has been successfully updated + And I should see only "Single media" content element in Content elements section diff --git a/features/admin/managing_frequently_asked_questions.feature b/features/admin/managing_frequently_asked_questions.feature deleted file mode 100644 index 393be7045..000000000 --- a/features/admin/managing_frequently_asked_questions.feature +++ /dev/null @@ -1,23 +0,0 @@ -@managing_frequently_asked_questions -Feature: Managing frequently asked questions - In order to present frequently asked questions and answers in my store - As an Administrator - I want to be able update and remove existing frequently asked questions - - Background: - Given I am logged in as an administrator - And the store operates on a single channel in "United States" - - @ui - Scenario: Removing frequently asked question - Given the store has a frequently asked question - When I go to the frequently asked questions page - And I delete this frequently asked question - Then I should be notified that the frequently asked question has been deleted - And I should see empty list of frequently asked questions - - @ui - Scenario: Seeing disabled code field while editing frequently asked question - Given the store has a frequently asked question - When I want to edit this frequently asked question - Then the code field should be disabled diff --git a/features/admin/managing_pages.feature b/features/admin/managing_pages.feature index f66310f29..6e02852b2 100644 --- a/features/admin/managing_pages.feature +++ b/features/admin/managing_pages.feature @@ -11,7 +11,7 @@ Feature: Managing cms pages @ui Scenario: Deleting page Given there is a page in the store - When I go to the pages page + When I go to the cms pages page And I delete this page Then I should be notified that the page has been deleted And I should see empty list of pages @@ -26,16 +26,25 @@ Feature: Managing cms pages Scenario: Updating page Given there is a page in the store When I want to edit this page - And I fill "Code, Content" fields + And I fill "Code, Name" fields And I update it Then I should be notified that the page was updated @ui - Scenario: Updating page with image - Given there is a page in the store - And there is an existing "image" media with "aston-martin" code + Scenario: Updating page with textarea content element + Given there is a page in the store with "Textarea" content element + When I want to edit this page + And I fill "Code, Name" fields + And I change textarea content element value to "New content" + And I update it + Then I should be notified that the page was updated + And I should see "New content" in the textarea content element + + @ui @javascript + Scenario: Deleting content element in page + Given there is a page in the store with "Textarea" content element When I want to edit this page - And I fill "Code, Content" fields - And I choose "aston-martin" media as image + And I delete the content element And I update it Then I should be notified that the page was updated + And I should not see "Textarea" content element in the Content elements section diff --git a/features/admin/managing_sections.feature b/features/admin/managing_sections.feature deleted file mode 100644 index ae881ce0b..000000000 --- a/features/admin/managing_sections.feature +++ /dev/null @@ -1,23 +0,0 @@ -@managing_sections -Feature: Managing sections - In order to present the content in specific sections in my store - As an Administrator - I want to be able to edit and remove existing sections - - Background: - Given the store operates on a single channel in "United States" - Given I am logged in as an administrator - - @ui - Scenario: Deleting section - Given there is a section in the store - When I go to the sections page - And I delete this section - Then I should be notified that the section has been deleted - And I should see empty list of sections - - @ui - Scenario: Seeing disabled code field while editing a section - Given there is a section in the store - When I want to edit this section - Then the code field should be disabled diff --git a/features/api/viewing_blocks.feature b/features/api/viewing_blocks.feature index de2888844..cb9bc508c 100644 --- a/features/api/viewing_blocks.feature +++ b/features/api/viewing_blocks.feature @@ -7,7 +7,7 @@ Feature: Getting data from cms blocks Background: Given the store operates on a single channel in "United States" And there is a block in the store - And there is a block with "block-1" code and "Hi there!" content + And there is a block with "block-1" code @api Scenario: Browsing blocks @@ -19,5 +19,4 @@ Feature: Getting data from cms blocks Scenario: Displaying block Given I view block with code "block-1" Then I should see block name - And I should see block content diff --git a/features/api/viewing_collections.feature b/features/api/viewing_collections.feature new file mode 100644 index 000000000..f3ab234ea --- /dev/null +++ b/features/api/viewing_collections.feature @@ -0,0 +1,21 @@ +@shop_collections +Feature: Getting data from cms collections + In order to present dynamic content in my store + As an API user + I want to be able to display collections + + Background: + Given the store operates on a single channel in "United States" + And there is a collection in the store + And there is an existing collection with "collection-1" code + + @api + Scenario: Browsing collections + Given I want to browse collections + Then I should see 2 collections in the list + And I should see collection with code "collection-1" + + @api + Scenario: Displaying collection + Given I view collection with code "collection-1" + Then I should see collection name diff --git a/features/api/viewing_frequently_asked_questions.feature b/features/api/viewing_frequently_asked_questions.feature deleted file mode 100644 index 6a7ab7c7c..000000000 --- a/features/api/viewing_frequently_asked_questions.feature +++ /dev/null @@ -1,23 +0,0 @@ -@shop_frequently_asked_questions -Feature: Getting data from cms faq - In order to present dynamic content in my store - As an API user - I want to be able to display FAQ - - Background: - Given the store operates on a single channel in "United States" - And there are 10 FAQs in the store - And there is an existing frequently asked question with "faq-1" code - - @api - Scenario: Browsing FAQs - Given I want to browse FAQs - Then I should see 11 questions in the list - And I should see the "faq-1" question - - @api - Scenario: Displaying question - Given I view faq with code "faq-1" - Then I should see question with random text - And I should see answer with random text - diff --git a/features/api/viewing_pages.feature b/features/api/viewing_pages.feature index 7eb5c23d3..9a1027405 100644 --- a/features/api/viewing_pages.feature +++ b/features/api/viewing_pages.feature @@ -9,13 +9,11 @@ Feature: Getting data from cms pages And there are 10 pages in the store And the store has "iPhone 8" and "iPhone X" products And there is a page in the store - And this page has these products associated with it - And there are existing sections named "Blog" and "General" - And this page has these sections associated with it + And there are existing collections named "Blog" and "General" + And this page has these collections associated with it And this page has "About us" name And this page has "about" code And this page also has "about-us" slug - And this page also has "We are the best!" content @api Scenario: Browsing defined pages @@ -25,6 +23,5 @@ Feature: Getting data from cms pages @api Scenario: Viewing a detailed page - Given I view page with code "about" + When I view page with code "about" Then I should see the page name "About us" - And I should see the page content "We are the best!" diff --git a/features/api/viewing_sections.feature b/features/api/viewing_sections.feature deleted file mode 100644 index 9362fb35b..000000000 --- a/features/api/viewing_sections.feature +++ /dev/null @@ -1,21 +0,0 @@ -@shop_sections -Feature: Getting data from cms sections - In order to present dynamic content in my store - As an API user - I want to be able to display sections - - Background: - Given the store operates on a single channel in "United States" - And there is a section in the store - And there is an existing section with "section-1" code - - @api - Scenario: Browsing sections - Given I want to browse sections - Then I should see 2 sections in the list - And I should see section with code "section-1" - - @api - Scenario: Displaying section - Given I view section with code "section-1" - Then I should see section name diff --git a/features/shop/browsing_frequently_asked_questions.feature b/features/shop/browsing_frequently_asked_questions.feature deleted file mode 100644 index c1fcb4ed0..000000000 --- a/features/shop/browsing_frequently_asked_questions.feature +++ /dev/null @@ -1,14 +0,0 @@ -@shop_frequently_asked_questions -Feature: Browsing FAQs - In order to get answer to the my questions ASAP - As a Customer - I want to browse through all FAQs - - Background: - Given the store operates on a single channel in "United States" - - @ui - Scenario: Browsing FAQs - Given there are 10 FAQs in the store - When I go to the frequently asked questions list page - Then I should see 10 FAQs ordered by position diff --git a/features/shop/browsing_pages_by_section.feature b/features/shop/browsing_pages_by_section.feature deleted file mode 100644 index 8672b3971..000000000 --- a/features/shop/browsing_pages_by_section.feature +++ /dev/null @@ -1,16 +0,0 @@ -@shop_pages -Feature: Browsing pages by section - In order to read content like articles or blog posts - As a Customer - I want to browse pages by specific sections - - Background: - Given the store operates on a single channel in "United States" - - @ui - Scenario: Browsing pages by section - Given there is a "Blog" section in the store - And there are 15 pages in the store - And these pages have this section associated with it - When I go to the section pages list for the "blog" section - Then I should see 10 pages on the page diff --git a/features/shop/displaying_homepage_block.feature b/features/shop/displaying_homepage_block.feature deleted file mode 100644 index b269cd4f5..000000000 --- a/features/shop/displaying_homepage_block.feature +++ /dev/null @@ -1,14 +0,0 @@ -@shop_blocks -Feature: Displaying blocks - In order to buy more items in the store - As a Customer - I want to display content blocks on the homepage - - Background: - Given the store operates on a single channel in "United States" - - @ui - Scenario: Displaying homepage blocks - Given there is a block with "homepage_intro" code and "Hello world!" content - When I go to the homepage - And I want to see a text block with "Hello world!" content diff --git a/features/shop/displaying_media.feature b/features/shop/displaying_media.feature deleted file mode 100644 index 91c16f6e1..000000000 --- a/features/shop/displaying_media.feature +++ /dev/null @@ -1,17 +0,0 @@ -@shop_media -Feature: Displaying media - - Background: - Given the store operates on a single channel in "United States" - - @ui - Scenario: Displaying media - And there is an existing "image" media with "homepage_pdf" code - When I go to the homepage - And I want to see a media with code "homepage_pdf" - - @ui - Scenario: Displaying media no standard template - And there is an existing "image" media with "media_with_parameters" code - When I go to the homepage - And I want to see a media with code "media_with_parameters" diff --git a/features/shop/displaying_page.feature b/features/shop/displaying_page.feature index 2edb83b53..b42dd8b82 100644 --- a/features/shop/displaying_page.feature +++ b/features/shop/displaying_page.feature @@ -11,43 +11,13 @@ Feature: Displaying pages Scenario: Displaying page Given there is a page in the store And the store has "iPhone 8" and "iPhone X" products - And this page has these products associated with it - And there are existing sections named "Blog" and "General" - And this page has these sections associated with it + And there are existing collections named "Blog" and "General" + And this page has these collections associated with it And this page has "About us" name And this page also has "about-us" slug - And this page also has "Lorem ipsum" content When I go to the "about-us" page Then I should see a page with "About us" name - And I should also see "Lorem ipsum" content - And I should also see "iPhone 8" and "iPhone X" products associated with this page - And I should also see "Blog" and "General" sections associated with this page - - @ui - Scenario: Displaying page link - Given there is a page in the store - And this page has "about" code - And this page has "About" name - When I go to this page - Then I should see the "About" page link in the header - - @ui @javascript - Scenario: Displaying page with image - Given there is a page in the store - And the store has "iPhone 8" and "iPhone X" products - And this page has these products associated with it - And there are existing sections named "Blog" and "General" - And this page has these sections associated with it - And this page has "About us" name - And this page also has "about-us" slug - And this page also has "Lorem ipsum" content - And this page also has "homepage_main.jpeg" image - When I go to the "about-us" page - Then I should see a page with "About us" name - And I should also see "Lorem ipsum" content - And I should also see "iPhone 8" and "iPhone X" products associated with this page - And I should also see "Blog" and "General" sections associated with this page - And I should also see page image + And I should also see "Blog" and "General" collections associated with this page @ui @javascript @title Scenario: Displaying page with title @@ -55,7 +25,6 @@ Feature: Displaying pages And this page has "some_page_with_title" code And this page has "some_page_with_title" name And this page also has "some_page_with_title" slug - And this page also has "Lorem ipsum" content And this page also has "title" title When I go to this page Then I should see page title "title" @@ -66,6 +35,5 @@ Feature: Displaying pages And this page has "title" code And this page has "Title" name And this page also has "title" slug - And this page also has "Lorem ipsum" content When I go to this page Then I should see page title "Sylius" diff --git a/phpspec.yml.dist b/phpspec.yml.dist index 510348697..767848352 100755 --- a/phpspec.yml.dist +++ b/phpspec.yml.dist @@ -1,4 +1,4 @@ suites: main: - namespace: BitBag\SyliusCmsPlugin - psr4_prefix: BitBag\SyliusCmsPlugin + namespace: Sylius\CmsPlugin + psr4_prefix: Sylius\CmsPlugin diff --git a/phpunit.xml.dist b/phpunit.xml.dist index aa1bc1a44..29597412f 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -6,13 +6,13 @@ colors="true" bootstrap="tests/Application/config/bootstrap.php"> - + tests - + diff --git a/public/build/cms/admin/entrypoints.json b/public/build/cms/admin/entrypoints.json new file mode 100644 index 000000000..d9e189cf2 --- /dev/null +++ b/public/build/cms/admin/entrypoints.json @@ -0,0 +1,12 @@ +{ + "entrypoints": { + "sylius-cms-admin": { + "css": [ + "/build/cms/admin/sylius-cms-admin.css" + ], + "js": [ + "/build/cms/admin/sylius-cms-admin.js" + ] + } + } +} \ No newline at end of file diff --git a/public/build/cms/admin/manifest.json b/public/build/cms/admin/manifest.json new file mode 100644 index 000000000..3d79b2d55 --- /dev/null +++ b/public/build/cms/admin/manifest.json @@ -0,0 +1,4 @@ +{ + "build/cms/admin/sylius-cms-admin.css": "/build/cms/admin/sylius-cms-admin.css", + "build/cms/admin/sylius-cms-admin.js": "/build/cms/admin/sylius-cms-admin.js" +} \ No newline at end of file diff --git a/public/build/cms/admin/sylius-cms-admin.css b/public/build/cms/admin/sylius-cms-admin.css new file mode 100644 index 000000000..49fef1082 --- /dev/null +++ b/public/build/cms/admin/sylius-cms-admin.css @@ -0,0 +1 @@ +#cms-resource-preview-modal{height:100%}#cms-resource-preview-modal iframe{height:100vh;width:100%}#cms-resource-preview-modal .ui.header{padding-bottom:0}.cms-import .ui.action.input input[type=file]{display:none}.cms-import .ui.action.input input[type=text]{width:auto}.media-list{grid-gap:20px;display:grid;grid-template-columns:repeat(6,150px);margin:0 auto}.media-list__item{align-items:flex-start;display:flex;flex-direction:column;justify-content:space-between;max-width:150px;position:relative!important}.media-list__item__label,.media-list__item__label>strong{word-wrap:break-word!important;white-space:-moz-pre-wrap!important;white-space:-webkit-pre-wrap!important;white-space:-pre-wrap!important;white-space:-o-pre-wrap!important;white-space:pre-wrap!important;white-space:normal!important;word-break:break-all!important}.media-list__item__label>strong{display:block!important}.media-list__item__input{bottom:10px;position:absolute!important;right:10px;z-index:99}.media-list__item__input:hover{cursor:pointer}.media-list__item__img{height:150px!important;width:150px!important}.btn{display:inline-block!important;font-size:1.4em!important}.btn:hover{cursor:pointer}.page-number{font-size:1.4em!important}.btn-delete{color:#db2828;cursor:pointer;font-weight:700;height:20px;position:absolute;right:30px;width:20px;z-index:5}.btn-delete.is-hidden{opacity:.2;pointer-events:none}.cms-media-autocomplete .dropdown.icon{pointer-events:none}.cms-media-autocomplete .search{cursor:pointer!important}.bb-collection-item{margin-bottom:1em}.bb-collection-item-delete{margin-top:5px!important}.cke_notifications_area{display:none}.help-text{font-size:12px;margin-top:-10px;opacity:.5} \ No newline at end of file diff --git a/public/build/cms/admin/sylius-cms-admin.js b/public/build/cms/admin/sylius-cms-admin.js new file mode 100644 index 000000000..e1bee5273 --- /dev/null +++ b/public/build/cms/admin/sylius-cms-admin.js @@ -0,0 +1,2 @@ +/*! For license information please see sylius-cms-admin.js.LICENSE.txt */ +(()=>{var t={461:()=>{$(document).ready((function(){$(".bitbag-media-autocomplete, .sylius-autocomplete").each((function(t,e){$(e).autoComplete()}));var t="#sylius_cms_page_contentElements",e=$(t).length?t:"#sylius_cms_block_contentElements";$(e).length&&($(document).on("collection-form-add",(function(){$(".bitbag-media-autocomplete, .sylius-autocomplete").each((function(t,e){void 0===$._data($(e).get(0),"events")&&$(e).autoComplete()})),$("".concat(e,' [data-form-collection="item"]')).each((function(t,e){$(document).loadContentConfiguration(e)}))})),$.fn.extend({loadContentConfiguration:function(t){t.querySelector("".concat(e,' select[name*="type"]')).onchange=function(){var t=this.parentElement,e=document.createElement("div"),r=this.selectedOptions[0];e.innerHTML=r.getAttribute("data-configuration");var n=t.nextElementSibling;t.parentElement.replaceChild(e,n);var o=n.querySelector("input");o||(o=n.querySelector("textarea"));var i=o.getAttribute("name"),a=e.querySelectorAll("input");a.length||(a=e.querySelectorAll("textarea")),a.forEach((function(t){var r=t.getAttribute("name");r&&(r=i.replace(i.substring(i.indexOf("[configuration]")+15),r.substring(r.indexOf("configuration")+13)),$(t).attr("name",r),$(e).find(".bitbag-media-autocomplete").autoComplete(),$(e).find(".sylius-autocomplete").autoComplete())}))}}}),$("".concat(e,' [data-form-collection="item"]')).each((function(t,e){$(document).loadContentConfiguration(e)})),$(document).loadContentConfiguration(document.querySelector("".concat(e,' [data-form-collection="item"]'))))}))}},e={};function r(n){var o=e[n];if(void 0!==o)return o.exports;var i=e[n]={exports:{}};return t[n](i,i.exports,r),i.exports}(()=>{"use strict";r(461);function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}function e(t,e){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:{textField:"data-bb-cms-text",fileField:"data-bb-cms-file"};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.config=e,this.textField=document.querySelector("[".concat(e.textField,"]")),this.fileField=document.querySelector("[".concat(e.fileField,"]"))},n=[{key:"init",value:function(){if("object"!==t(this.config))throw new Error("Bitbag CMS Plugin - HandleCsvUpload class config is not a valid object");this._handleFields()}},{key:"_handleFields",value:function(){this._handleTextField(),this._handleFileField()}},{key:"_handleTextField",value:function(){var t=this;this.textField.addEventListener("click",(function(){t.fileField.click()}))}},{key:"_handleFileField",value:function(){var t=this;this.fileField.addEventListener("change",(function(e){t.textField.value=e.target.files[0].name}))}}],n&&e(r.prototype,n),o&&e(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}();const i=function(t,e,r){var n=new CustomEvent("".concat("bb",".").concat(e),{detail:r});return t.dispatchEvent(n),t};function a(){a=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},i="function"==typeof Symbol?Symbol:{},c=i.iterator||"@@iterator",u=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function f(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{f({},"")}catch(t){f=function(t,e,r){return t[e]=r}}function h(t,e,r,n){var i=e&&e.prototype instanceof b?e:b,a=Object.create(i.prototype),c=new I(n||[]);return o(a,"_invoke",{value:O(t,r,c)}),a}function d(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=h;var p="suspendedStart",y="suspendedYield",v="executing",m="completed",g={};function b(){}function w(){}function S(){}var _={};f(_,c,(function(){return this}));var E=Object.getPrototypeOf,L=E&&E(E(F([])));L&&L!==r&&n.call(L,c)&&(_=L);var x=S.prototype=b.prototype=Object.create(_);function k(t){["next","throw","return"].forEach((function(e){f(t,e,(function(t){return this._invoke(e,t)}))}))}function j(t,e){function r(o,i,a,c){var u=d(t[o],t,i);if("throw"!==u.type){var s=u.arg,f=s.value;return f&&"object"==l(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,c)}),(function(t){r("throw",t,a,c)})):e.resolve(f).then((function(t){s.value=t,a(s)}),(function(t){return r("throw",t,a,c)}))}c(u.arg)}var i;o(this,"_invoke",{value:function(t,n){function o(){return new e((function(e,o){r(t,n,e,o)}))}return i=i?i.then(o,o):o()}})}function O(e,r,n){var o=p;return function(i,a){if(o===v)throw Error("Generator is already running");if(o===m){if("throw"===i)throw a;return{value:t,done:!0}}for(n.method=i,n.arg=a;;){var c=n.delegate;if(c){var u=P(c,n);if(u){if(u===g)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===p)throw o=m,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=v;var l=d(e,r,n);if("normal"===l.type){if(o=n.done?m:y,l.arg===g)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(o=m,n.method="throw",n.arg=l.arg)}}}function P(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,P(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var i=d(o,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,g;var a=i.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,g):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,g)}function T(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function C(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(T,this),this.reset(!0)}function F(e){if(e||""===e){var r=e[c];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,i=function r(){for(;++o=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),l=n.call(a,"finallyLoc");if(u&&l){if(this.prev=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),C(r),g}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;C(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:F(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),g}},e}function c(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function u(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){c(i,n,o,a,u,"next",t)}function u(t){c(i,n,o,a,u,"throw",t)}a(void 0)}))}}function l(t){return l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},l(t)}function s(t,e){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:{wrappersIndicator:"data-bb-cms-wrapper",lockFieldIndicator:"data-bb-cms-toggle-slug",bbTarget:"sylius_cms_page",nameField:"sylius_cms_page_name"};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.wrappers=document.querySelectorAll("[".concat(e.wrappersIndicator,"]")),this.lockFieldIndicator="[".concat(e.lockFieldIndicator,"]"),this.bbTarget=e.bbTarget,this.config=e,this.nameField=document.getElementById("".concat(e.nameField))},e=[{key:"init",value:function(){if("object"!==l(this.config))throw new Error("Bitbag CMS Plugin - HandleSlugUpdate class config is not a valid object");if("string"!=typeof this.lockFieldIndicator||"string"!=typeof this.bbTarget)throw new Error("Bitbag CMS Plugin - HandleSlugUpdate class config key values are not valid strings");if(!this.nameField)throw new Error("Bitbag CMS Plugin - HandleSlugUpdate name field not found");this._handleFields()}},{key:"_handleFields",value:function(){var t=this;this.wrappers.forEach((function(e){var r=e.dataset.locale,n=e.querySelector("#".concat(t.bbTarget,"_translations_").concat(r,"_slug"));if(n||(n=e.querySelector("#".concat(t.bbTarget,"_slug"))),n){var o;t.nameField.addEventListener("input",(function(e){e.preventDefault(),n.readOnly||(clearTimeout(o),o=setTimeout((function(){t._updateSlug(n,t.nameField.value)}),1e3))}));var i=e.querySelector(t.lockFieldIndicator);i&&i.addEventListener("click",(function(e){e.preventDefault(),t._toggleSlugModification(n,i)}))}}))}},{key:"_updateSlug",value:(o=u(a().mark((function t(e,r){return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i(e,"cms.slug.update.start"),e.parentNode.classList.add("loading"),t.next=4,this._getValidSlug(e.dataset.url,r);case 4:e.value=t.sent,e.parentNode.classList.remove("loading"),i(e,"cms.slug.update.end");case 7:case"end":return t.stop()}}),t,this)}))),function(t,e){return o.apply(this,arguments)})},{key:"_getValidSlug",value:(n=u(a().mark((function t(e,r){var n,o;return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,fetch("".concat(e,"?name=").concat(encodeURIComponent(r)));case 3:return n=t.sent,t.next=6,n.json();case 6:return o=t.sent,t.abrupt("return",o.slug);case 10:t.prev=10,t.t0=t.catch(0),console.error("BitBag CMS Plugin - HandleSlugUpdate class error : ".concat(t.t0));case 13:case"end":return t.stop()}}),t,null,[[0,10]])}))),function(t,e){return n.apply(this,arguments)})},{key:"_toggleSlugModification",value:function(t,e){t.readOnly=!t.readOnly;var r=e.querySelector("i");r.classList.toggle("lock"),r.classList.toggle("unlock")}}],e&&s(t.prototype,e),r&&s(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r,n,o}();function d(){d=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function l(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{l({},"")}catch(t){l=function(t,e,r){return t[e]=r}}function s(t,e,r,n){var i=e&&e.prototype instanceof b?e:b,a=Object.create(i.prototype),c=new I(n||[]);return o(a,"_invoke",{value:O(t,r,c)}),a}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=s;var h="suspendedStart",p="suspendedYield",y="executing",v="completed",g={};function b(){}function w(){}function S(){}var _={};l(_,a,(function(){return this}));var E=Object.getPrototypeOf,L=E&&E(E(F([])));L&&L!==r&&n.call(L,a)&&(_=L);var x=S.prototype=b.prototype=Object.create(_);function k(t){["next","throw","return"].forEach((function(e){l(t,e,(function(t){return this._invoke(e,t)}))}))}function j(t,e){function r(o,i,a,c){var u=f(t[o],t,i);if("throw"!==u.type){var l=u.arg,s=l.value;return s&&"object"==m(s)&&n.call(s,"__await")?e.resolve(s.__await).then((function(t){r("next",t,a,c)}),(function(t){r("throw",t,a,c)})):e.resolve(s).then((function(t){l.value=t,a(l)}),(function(t){return r("throw",t,a,c)}))}c(u.arg)}var i;o(this,"_invoke",{value:function(t,n){function o(){return new e((function(e,o){r(t,n,e,o)}))}return i=i?i.then(o,o):o()}})}function O(e,r,n){var o=h;return function(i,a){if(o===y)throw Error("Generator is already running");if(o===v){if("throw"===i)throw a;return{value:t,done:!0}}for(n.method=i,n.arg=a;;){var c=n.delegate;if(c){var u=P(c,n);if(u){if(u===g)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===h)throw o=v,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=y;var l=f(e,r,n);if("normal"===l.type){if(o=n.done?v:p,l.arg===g)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(o=v,n.method="throw",n.arg=l.arg)}}}function P(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,P(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var i=f(o,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,g;var a=i.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,g):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,g)}function T(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function C(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(T,this),this.reset(!0)}function F(e){if(e||""===e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,i=function r(){for(;++o=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),l=n.call(a,"finallyLoc");if(u&&l){if(this.prev=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),C(r),g}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;C(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:F(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),g}},e}function p(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function y(t){return function(t){if(Array.isArray(t))return v(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return v(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?v(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r0&&void 0!==arguments[0]?arguments[0]:{previewButton:"data-bb-cms-preview-btn",previewModal:"data-bb-cms-preview-modal",channelSwitch:"data-bb-cms-channel",localeSwitch:"data-bb-cms-locale"};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.config=e,this.button=document.querySelector("[".concat(e.previewButton,"]")),this.modal=document.querySelector("[".concat(e.previewModal,"]")),this.modalSelector=e.previewModal,this.channelSelector=e.channelSwitch,this.localeSelector=e.localeSwitch},e=[{key:"init",value:function(){if("object"!==m(this.config))throw new Error("Bitbag CMS Plugin - HandlePreview class config is not a valid object");if("string"!=typeof this.localeSelector||"string"!=typeof this.channelSelector||"string"!=typeof this.modalSelector)throw new Error("Bitbag CMS Plugin - HandlePreview class config key values are not valid strings");this._resourcePreview()}},{key:"_$_CKEDITOR_MODAL_SHOW",value:function(){return $("[".concat(this.modalSelector,"]")).modal("show")}},{key:"_$_CKEDITOR_UPDATE_INSTANCES",value:function(){y(CKEDITOR.instances).forEach((function(t){return t.updateElement()}))}},{key:"_resourcePreview",value:function(){var t=this;this.button.addEventListener("click",(function(e){e.preventDefault(),t._$_CKEDITOR_UPDATE_INSTANCES,t._createPreview(),t._$_CKEDITOR_MODAL_SHOW()})),document.querySelector("[".concat(this.channelSelector,"]")).addEventListener("change",(function(e){e.preventDefault(),t._$_CKEDITOR_UPDATE_INSTANCES,t._createPreview(),t._$_CKEDITOR_MODAL_SHOW()})),document.querySelector("[".concat(this.localeSelector,"]")).addEventListener("change",(function(e){e.preventDefault(),t._$_CKEDITOR_UPDATE_INSTANCES,t._createPreview(),t._$_CKEDITOR_MODAL_SHOW()}))}},{key:"_createPreview",value:(n=d().mark((function t(){var e,r,n,o,a,c,u,l,s;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.modal.querySelector(".ui.loadable").classList.add("loading"),this.modal.disabled=!0,e=document.querySelector("[".concat(this.channelSelector,"]")).value,r=document.querySelector("[".concat(this.localeSelector,"]")).value,n=this.button.dataset.url,o=this.button.closest("form"),a={method:"POST",body:new FormData(o)},t.prev=7,i(this.modal,"cms.create.preview.start"),t.next=11,fetch("".concat(n,"?_channel_code=").concat(e,"&_locale=").concat(r),a);case 11:return c=t.sent,t.next=14,c.text();case 14:u=t.sent,l=new Blob([u],{type:"text/html",charset:"utf-8"}),s=window.URL.createObjectURL(l),this.modal.querySelector("iframe").src=s,i(this.modal,"cms.create.preview.completed",u),t.next=25;break;case 21:t.prev=21,t.t0=t.catch(7),console.error("BitBag CMS Plugin - HandlePreview class error : ".concat(t.t0)),i(this.modal,"cms.create.preview.error",t.t0);case 25:return t.prev=25,this.modal.querySelector(".ui.loadable").classList.remove("loading"),this.modal.disabled=!1,i(this.modal,"cms.create.preview.end"),t.finish(25);case 30:case"end":return t.stop()}}),t,this,[[7,21,25,30]])})),o=function(){var t=this,e=arguments;return new Promise((function(r,o){var i=n.apply(t,e);function a(t){p(i,r,o,a,c,"next",t)}function c(t){p(i,r,o,a,c,"throw",t)}a(void 0)}))},function(){return o.apply(this,arguments)})}],e&&g(t.prototype,e),r&&g(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r,n,o}();function S(){S=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function l(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{l({},"")}catch(t){l=function(t,e,r){return t[e]=r}}function s(t,e,r,n){var i=e&&e.prototype instanceof m?e:m,a=Object.create(i.prototype),c=new I(n||[]);return o(a,"_invoke",{value:O(t,r,c)}),a}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=s;var h="suspendedStart",d="suspendedYield",p="executing",y="completed",v={};function m(){}function g(){}function b(){}var w={};l(w,a,(function(){return this}));var _=Object.getPrototypeOf,E=_&&_(_(F([])));E&&E!==r&&n.call(E,a)&&(w=E);var L=b.prototype=m.prototype=Object.create(w);function x(t){["next","throw","return"].forEach((function(e){l(t,e,(function(t){return this._invoke(e,t)}))}))}function j(t,e){function r(o,i,a,c){var u=f(t[o],t,i);if("throw"!==u.type){var l=u.arg,s=l.value;return s&&"object"==k(s)&&n.call(s,"__await")?e.resolve(s.__await).then((function(t){r("next",t,a,c)}),(function(t){r("throw",t,a,c)})):e.resolve(s).then((function(t){l.value=t,a(l)}),(function(t){return r("throw",t,a,c)}))}c(u.arg)}var i;o(this,"_invoke",{value:function(t,n){function o(){return new e((function(e,o){r(t,n,e,o)}))}return i=i?i.then(o,o):o()}})}function O(e,r,n){var o=h;return function(i,a){if(o===p)throw Error("Generator is already running");if(o===y){if("throw"===i)throw a;return{value:t,done:!0}}for(n.method=i,n.arg=a;;){var c=n.delegate;if(c){var u=P(c,n);if(u){if(u===v)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===h)throw o=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=p;var l=f(e,r,n);if("normal"===l.type){if(o=n.done?y:d,l.arg===v)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(o=y,n.method="throw",n.arg=l.arg)}}}function P(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,P(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),v;var i=f(o,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,v;var a=i.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function T(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function C(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(T,this),this.reset(!0)}function F(e){if(e||""===e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,i=function r(){for(;++o=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),l=n.call(a,"finallyLoc");if(u&&l){if(this.prev=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),C(r),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;C(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:F(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),v}},e}function _(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return E(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?E(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}function E(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r0&&void 0!==arguments[0]?arguments[0]:{bbMediaContainer:"data-bb-cms-autocomplete",choiceName:"data-bb-cms-choice-name",choiceValue:"data-bb-cms-choice-value",criteriaType:"data-bb-cms-criteria-type",criteriaName:"data-bb-cms-criteria-name",editUrl:"data-bb-cms-load-edit-url",nameMessage:"data-bb-cms-name-message",deleteButton:"data-bb-cms-delete-selected",choosenPreview:"data-bb-cms-selected-image",selectMenu:"data-bb-cms-selection-menu",selectInput:"data-bb-cms-image-select",placeholder:"data-bb-cms-placeholder",limit:30};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.config=e,this.mediaContainers=document.querySelectorAll("[".concat(e.bbMediaContainer,"]")),this.deleteButton="[".concat(e.deleteButton,"]"),this.selectMenu="[".concat(e.selectMenu,"]"),this.selectInput="[".concat(e.selectInput,"]"),this.placeholder="[".concat(e.placeholder,"]")},e=[{key:"init",value:function(){var t=this;if("object"!==k(this.config))throw new Error("Bitbag CMS Plugin - HandleAutoComplete class config is not a valid object");this.mediaContainers.forEach((function(e){t._handleSavedValue(e),t._handleImageChoice(e),t._handleResetBtn(e)}))}},{key:"_handleResetBtn",value:function(t){var e=this,r=t.querySelector(this.deleteButton);""!==t.querySelector("input[type=hidden]").value?(r.classList.remove("is-hidden"),r.addEventListener("click",(function(){e._resetValues(t)}))):r.classList.add("is-hidden")}},{key:"_handleImageChoice",value:function(t){var e,r=this;t.querySelector(this.selectInput).addEventListener("click",(function(e){e.preventDefault(),r._getMediaImages(t)})),t.querySelector(this.selectInput).addEventListener("input",(function(n){n.preventDefault(),clearTimeout(e),e=setTimeout((function(){r._getMediaImages(t,n.target.value)}),500)})),t.querySelector("input[type=hidden]").addEventListener("change",(function(e){e.preventDefault(),r._handleResetBtn(t)}))}},{key:"_handleSavedValue",value:(o=x(S().mark((function t(e){var r,n,o,a,c,u,l;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(""!==e.querySelector("input[type=hidden]").value){t.next=2;break}return t.abrupt("return");case 2:return r="".concat(e.dataset.bbCmsLoadEditUrl,"?").concat(e.querySelector("input[type=hidden]").value.split(",").filter(String).map((function(t){return"code[]=".concat(t)})).join("&")),t.prev=3,i(e,"cms.media.saved.reload.start"),e.classList.add("loading"),t.next=8,fetch(r);case 8:return n=t.sent,t.next=11,n.json();case 11:o=t.sent,this._addToSelectMenu(o,e),a=[],null!==(c=e.querySelector(this.selectMenu))&&(a=c.children),u=_(a);try{for(u.s();!(l=u.n()).done;)l.value.click()}catch(t){u.e(t)}finally{u.f()}i(e,"cms.media.saved.reload.completed",o),t.next=25;break;case 21:t.prev=21,t.t0=t.catch(3),console.error("BitBag CMS Plugin - HandleAutoComplete class error : ".concat(t.t0)),i(e,"cms.media.saved.reload.error",t.t0);case 25:return t.prev=25,e.classList.remove("loading"),i(e,"cms.media.saved.reload.end"),t.finish(25);case 29:case"end":return t.stop()}}),t,this,[[3,21,25,29]])}))),function(t){return o.apply(this,arguments)})},{key:"_getMediaImages",value:(n=x(S().mark((function t(e){var r,n,o,a,c,u,l,s,f=arguments;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=f.length>1&&void 0!==f[1]&&f[1],n=e.dataset.bbCmsUrl,o=e.dataset.bbCmsCriteriaType,a=r?"&criteria[search][value]=".concat(r):"",c="".concat(n,"&limit=").concat(this.config.limit,"&criteria[search][type]=").concat(o,"&criteria[search][value]=").concat(a),t.prev=5,i(e,"cms.media.display.start"),e.classList.add("loading"),t.next=10,fetch(c);case 10:return u=t.sent,t.next=13,u.json();case 13:l=t.sent,s=l._embedded.items,this._addToSelectMenu(s,e),i(e,"cms.media.display.completed",l),t.next=23;break;case 19:t.prev=19,t.t0=t.catch(5),console.error("BitBag CMS Plugin - HandleAutoComplete class error : ".concat(t.t0)),i(e,"cms.media.display.error",t.t0);case 23:return t.prev=23,e.classList.remove("loading"),i(e,"cms.media.display.end"),t.finish(23);case 27:case"end":return t.stop()}}),t,this,[[5,19,23,27]])}))),function(t){return n.apply(this,arguments)})},{key:"_resetValues",value:function(t){i(t,"cms.media.reset.start"),t.querySelector("input[type=hidden]").value="",t.querySelector(this.selectMenu).innerHTML="",t.querySelector(this.placeholder).innerHTML="",i(t,"cms.media.reset.end")}},{key:"_addToSelectMenu",value:function(t,e){var r=this;i(e,"cms.media.display.update.start");var n=e.querySelector(this.selectMenu);n.innerHTML="",null!==t&&t.forEach((function(t){n.insertAdjacentHTML("beforeend",r._itemTemplate(t.path,t.code.trim()))})),i(e,"cms.media.display.update.end")}},{key:"_itemTemplate",value:function(t,e){return'
').concat(e,"
")}}],e&&j(t.prototype,e),r&&j(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r,n,o}();function T(t){return T="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},T(t)}function C(t,e){for(var r=0;r0&&(new h).init(),document.querySelectorAll("[data-bb-cms-preview-btn]").length>0&&(new w).init(),document.querySelector('[data-bb-target="cms-handle-autocomplete"]')&&(new P).init(),document.querySelector(".collection-type-items")&&(new F).init(),document.querySelector("[data-bb-cms-load-template]")&&(new N).init()})()})(); \ No newline at end of file diff --git a/src/Resources/public/build/bitbag-cms-admin.js.LICENSE.txt b/public/build/cms/admin/sylius-cms-admin.js.LICENSE.txt similarity index 100% rename from src/Resources/public/build/bitbag-cms-admin.js.LICENSE.txt rename to public/build/cms/admin/sylius-cms-admin.js.LICENSE.txt diff --git a/public/build/cms/shop/entrypoints.json b/public/build/cms/shop/entrypoints.json new file mode 100644 index 000000000..583631555 --- /dev/null +++ b/public/build/cms/shop/entrypoints.json @@ -0,0 +1,12 @@ +{ + "entrypoints": { + "sylius-cms-shop": { + "css": [ + "/build/cms/shop/sylius-cms-shop.css" + ], + "js": [ + "/build/cms/shop/sylius-cms-shop.js" + ] + } + } +} \ No newline at end of file diff --git a/public/build/cms/shop/manifest.json b/public/build/cms/shop/manifest.json new file mode 100644 index 000000000..11b62d10f --- /dev/null +++ b/public/build/cms/shop/manifest.json @@ -0,0 +1,4 @@ +{ + "build/cms/shop/sylius-cms-shop.css": "/build/cms/shop/sylius-cms-shop.css", + "build/cms/shop/sylius-cms-shop.js": "/build/cms/shop/sylius-cms-shop.js" +} \ No newline at end of file diff --git a/public/build/cms/shop/sylius-cms-shop.css b/public/build/cms/shop/sylius-cms-shop.css new file mode 100644 index 000000000..fa24c6ec9 --- /dev/null +++ b/public/build/cms/shop/sylius-cms-shop.css @@ -0,0 +1 @@ +.cms-block{margin-bottom:20px}.cms-block img{max-width:100%}.carousel-wrapper{position:relative}.carousel-wrapper .carousel{margin:0 -1em}.carousel-wrapper .carousel-nav .carousel-left{left:30px}.carousel-wrapper .carousel-nav .carousel-right{right:30px}.carousel-wrapper .carousel-nav .carousel-left,.carousel-wrapper .carousel-nav .carousel-right{position:absolute;top:50%;transform:translateY(-50%)}.carousel-wrapper .carousel-item{padding:5px 1em}.teaser__content{margin-top:10px}.teaser__description{margin-top:5px}.teaser__read-more{display:block;margin-top:20px}[class^=cms_content_element__]:not(:last-child){margin-bottom:1rem} \ No newline at end of file diff --git a/public/build/cms/shop/sylius-cms-shop.js b/public/build/cms/shop/sylius-cms-shop.js new file mode 100644 index 000000000..e69de29bb diff --git a/spec/Assigner/ChannelsAssignerSpec.php b/spec/Assigner/ChannelsAssignerSpec.php index 3bcb6e409..5fc38fc80 100644 --- a/spec/Assigner/ChannelsAssignerSpec.php +++ b/spec/Assigner/ChannelsAssignerSpec.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace spec\BitBag\SyliusCmsPlugin\Assigner; +namespace spec\Sylius\CmsPlugin\Assigner; -use BitBag\SyliusCmsPlugin\Assigner\ChannelsAssigner; -use BitBag\SyliusCmsPlugin\Assigner\ChannelsAssignerInterface; use PhpSpec\ObjectBehavior; +use Sylius\CmsPlugin\Assigner\ChannelsAssigner; +use Sylius\CmsPlugin\Assigner\ChannelsAssignerInterface; use Sylius\Component\Channel\Model\ChannelsAwareInterface; use Sylius\Component\Channel\Repository\ChannelRepositoryInterface; use Sylius\Component\Core\Model\ChannelInterface; @@ -32,10 +32,9 @@ public function it_assigns_channels( ChannelRepositoryInterface $channelRepository, ChannelInterface $webChannel, ChannelInterface $posChannel, - ChannelsAwareInterface $channelsAware + ChannelsAwareInterface $channelsAware, ): void { - $channelRepository->findOneBy(['code' => 'web'])->willReturn($webChannel); - $channelRepository->findOneBy(['code' => 'pos'])->willReturn($posChannel); + $channelRepository->findBy(['code' => ['web', 'pos']])->willReturn([$webChannel, $posChannel]); $channelsAware->addChannel($webChannel)->shouldBeCalled(); $channelsAware->addChannel($posChannel)->shouldBeCalled(); diff --git a/spec/Assigner/CollectionsAssignerSpec.php b/spec/Assigner/CollectionsAssignerSpec.php new file mode 100644 index 000000000..0e95b878e --- /dev/null +++ b/spec/Assigner/CollectionsAssignerSpec.php @@ -0,0 +1,44 @@ +beConstructedWith($collectionRepository); + } + + public function it_is_initializable(): void + { + $this->shouldHaveType(CollectionsAssigner::class); + } + + public function it_implements_collections_assigner_interface(): void + { + $this->shouldHaveType(CollectionsAssignerInterface::class); + } + + public function it_assigns_collections( + CollectionRepositoryInterface $collectionRepository, + CollectionInterface $aboutCollection, + CollectionInterface $blogCollection, + CollectibleInterface $collectionsAware, + ): void { + $collectionRepository->findBy(['code' => ['about', 'blog']])->willReturn([$aboutCollection, $blogCollection]); + + $collectionsAware->addCollection($aboutCollection)->shouldBeCalled(); + $collectionsAware->addCollection($blogCollection)->shouldBeCalled(); + + $this->assign($collectionsAware, ['about', 'blog']); + } +} diff --git a/spec/Assigner/LocalesAssignerSpec.php b/spec/Assigner/LocalesAssignerSpec.php new file mode 100644 index 000000000..7e2da73fb --- /dev/null +++ b/spec/Assigner/LocalesAssignerSpec.php @@ -0,0 +1,47 @@ +beConstructedWith($localeRepository); + } + + public function it_is_initializable() + { + $this->shouldHaveType(LocalesAssigner::class); + } + + public function it_implements_locales_assigner_interface() + { + $this->shouldImplement(LocalesAssignerInterface::class); + } + + public function it_assigns_locales_to_locale_aware_entity( + RepositoryInterface $localeRepository, + LocaleAwareInterface $localesAware, + LocaleInterface $locale1, + LocaleInterface $locale2, + ) { + $locale1->getCode()->willReturn('en_US'); + $locale2->getCode()->willReturn('fr_FR'); + + $localeRepository->findBy(['code' => ['en_US', 'fr_FR']])->willReturn([$locale1, $locale2]); + + $localesAware->addLocale($locale1)->shouldBeCalled(); + $localesAware->addLocale($locale2)->shouldBeCalled(); + + $this->assign($localesAware, ['en_US', 'fr_FR']); + } +} diff --git a/spec/Assigner/ProductsAssignerSpec.php b/spec/Assigner/ProductsAssignerSpec.php index e1b999612..e79e07ee3 100644 --- a/spec/Assigner/ProductsAssignerSpec.php +++ b/spec/Assigner/ProductsAssignerSpec.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace spec\BitBag\SyliusCmsPlugin\Assigner; +namespace spec\Sylius\CmsPlugin\Assigner; -use BitBag\SyliusCmsPlugin\Assigner\ProductsAssigner; -use BitBag\SyliusCmsPlugin\Assigner\ProductsAssignerInterface; -use BitBag\SyliusCmsPlugin\Entity\ProductsAwareInterface; use PhpSpec\ObjectBehavior; +use Sylius\CmsPlugin\Assigner\ProductsAssigner; +use Sylius\CmsPlugin\Assigner\ProductsAssignerInterface; +use Sylius\CmsPlugin\Entity\ProductsAwareInterface; use Sylius\Component\Core\Model\ProductInterface; use Sylius\Component\Core\Repository\ProductRepositoryInterface; @@ -32,10 +32,9 @@ public function it_assigns_products( ProductRepositoryInterface $productRepository, ProductInterface $mugProduct, ProductInterface $tshirtProduct, - ProductsAwareInterface $productsAware + ProductsAwareInterface $productsAware, ): void { - $productRepository->findOneBy(['code' => 'mug'])->willReturn($mugProduct); - $productRepository->findOneBy(['code' => 't-shirt'])->willReturn($tshirtProduct); + $productRepository->findBy(['code' => ['mug', 't-shirt']])->willReturn([$mugProduct, $tshirtProduct]); $productsAware->addProduct($mugProduct)->shouldBeCalled(); $productsAware->addProduct($tshirtProduct)->shouldBeCalled(); diff --git a/spec/Assigner/ProductsInTaxonsAssignerSpec.php b/spec/Assigner/ProductsInTaxonsAssignerSpec.php new file mode 100644 index 000000000..4b98ad9ce --- /dev/null +++ b/spec/Assigner/ProductsInTaxonsAssignerSpec.php @@ -0,0 +1,47 @@ +beConstructedWith($taxonRepository); + } + + public function it_is_initializable() + { + $this->shouldHaveType(ProductsInTaxonsAssigner::class); + } + + public function it_implements_products_in_taxons_assigner_interface() + { + $this->shouldImplement(ProductsInTaxonsAssignerInterface::class); + } + + public function it_assigns_taxons_to_products_in_taxons_aware_entity( + TaxonRepositoryInterface $taxonRepository, + ProductsInTaxonsAwareInterface $productsInTaxonsAware, + TaxonInterface $taxon1, + TaxonInterface $taxon2, + ) { + $taxon1->getCode()->willReturn('taxon_code_1'); + $taxon2->getCode()->willReturn('taxon_code_2'); + + $taxonRepository->findBy(['code' => ['taxon_code_1', 'taxon_code_2']])->willReturn([$taxon1, $taxon2]); + + $productsInTaxonsAware->addProductsInTaxon($taxon1)->shouldBeCalled(); + $productsInTaxonsAware->addProductsInTaxon($taxon2)->shouldBeCalled(); + + $this->assign($productsInTaxonsAware, ['taxon_code_1', 'taxon_code_2']); + } +} diff --git a/spec/Assigner/SectionsAssignerSpec.php b/spec/Assigner/SectionsAssignerSpec.php deleted file mode 100644 index 1f26784cd..000000000 --- a/spec/Assigner/SectionsAssignerSpec.php +++ /dev/null @@ -1,45 +0,0 @@ -beConstructedWith($sectionRepository); - } - - public function it_is_initializable(): void - { - $this->shouldHaveType(SectionsAssigner::class); - } - - public function it_implements_sections_assigner_interface(): void - { - $this->shouldHaveType(SectionsAssignerInterface::class); - } - - public function it_assigns_sections( - SectionRepositoryInterface $sectionRepository, - SectionInterface $aboutSection, - SectionInterface $blogSection, - SectionableInterface $sectionsAware - ): void { - $sectionRepository->findOneBy(['code' => 'about'])->willReturn($aboutSection); - $sectionRepository->findOneBy(['code' => 'blog'])->willReturn($blogSection); - - $sectionsAware->addSection($aboutSection)->shouldBeCalled(); - $sectionsAware->addSection($blogSection)->shouldBeCalled(); - - $this->assign($sectionsAware, ['about', 'blog']); - } -} diff --git a/spec/Assigner/TaxonsAssignerSpec.php b/spec/Assigner/TaxonsAssignerSpec.php index 7eade976e..b8933ff98 100644 --- a/spec/Assigner/TaxonsAssignerSpec.php +++ b/spec/Assigner/TaxonsAssignerSpec.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace spec\BitBag\SyliusCmsPlugin\Assigner; +namespace spec\Sylius\CmsPlugin\Assigner; -use BitBag\SyliusCmsPlugin\Assigner\TaxonsAssigner; -use BitBag\SyliusCmsPlugin\Assigner\TaxonsAssignerInterface; -use BitBag\SyliusCmsPlugin\Entity\TaxonAwareInterface; use PhpSpec\ObjectBehavior; +use Sylius\CmsPlugin\Assigner\TaxonsAssigner; +use Sylius\CmsPlugin\Assigner\TaxonsAssignerInterface; +use Sylius\CmsPlugin\Entity\TaxonAwareInterface; use Sylius\Component\Core\Model\TaxonInterface; use Sylius\Component\Taxonomy\Repository\TaxonRepositoryInterface; @@ -32,10 +32,9 @@ public function it_assigns_taxons( TaxonRepositoryInterface $taxonRepository, TaxonInterface $mugsTaxon, TaxonInterface $stickersTaxon, - TaxonAwareInterface $taxonsAware + TaxonAwareInterface $taxonsAware, ): void { - $taxonRepository->findOneBy(['code' => 'mugs'])->willReturn($mugsTaxon); - $taxonRepository->findOneBy(['code' => 'stickers'])->willReturn($stickersTaxon); + $taxonRepository->findBy(['code' => ['mugs', 'stickers']])->willReturn([$mugsTaxon, $stickersTaxon]); $taxonsAware->addTaxon($mugsTaxon)->shouldBeCalled(); $taxonsAware->addTaxon($stickersTaxon)->shouldBeCalled(); diff --git a/spec/Controller/Action/Admin/UploadEditorImageActionSpec.php b/spec/Controller/Action/Admin/UploadEditorImageActionSpec.php index 380016d16..23ab783fc 100644 --- a/spec/Controller/Action/Admin/UploadEditorImageActionSpec.php +++ b/spec/Controller/Action/Admin/UploadEditorImageActionSpec.php @@ -1,21 +1,15 @@ beConstructedWith($mediaProviderResolver, $mediaRepository, $mediaFactory); } @@ -43,7 +37,7 @@ public function it_uploads_media( FileBag $fileBag, MediaProviderResolverInterface $mediaProviderResolver, ProviderInterface $provider, - MediaRepositoryInterface $mediaRepository + MediaRepositoryInterface $mediaRepository, ): void { $uploadedFile = new UploadedFile(__DIR__ . '/../../../../tests/Behat/Resources/images/aston_martin_db_11.jpg', 'aston_martin_db_11.jpg'); diff --git a/spec/Entity/BlockSpec.php b/spec/Entity/BlockSpec.php index 782b9f5e0..50835cf1b 100755 --- a/spec/Entity/BlockSpec.php +++ b/spec/Entity/BlockSpec.php @@ -1,22 +1,14 @@ isEnabled()->shouldReturn(false); } - public function it_associates_products(ProductInterface $firstProduct, ProductInterface $secondProduct): void - { - $this->addProduct($firstProduct); - $this->hasProduct($firstProduct)->shouldReturn(true); - - $this->hasProduct($secondProduct)->shouldReturn(false); - - $this->removeProduct($firstProduct); - - $this->hasProduct($firstProduct)->shouldReturn(false); - } - - public function it_associates_sections(SectionInterface $firstSection, SectionInterface $secondSection): void + public function it_associates_collections(CollectionInterface $firstCollection, CollectionInterface $secondCollection): void { - $this->addSection($firstSection); - $this->hasSection($firstSection)->shouldReturn(true); + $this->addCollection($firstCollection); + $this->hasCollection($firstCollection)->shouldReturn(true); - $this->hasSection($secondSection)->shouldReturn(false); + $this->hasCollection($secondCollection)->shouldReturn(false); - $this->removeSection($firstSection); + $this->removeCollection($firstCollection); - $this->hasSection($firstSection)->shouldReturn(false); + $this->hasCollection($firstCollection)->shouldReturn(false); } public function it_associates_channels(ChannelInterface $firstChannel, ChannelInterface $secondChannel): void @@ -80,16 +60,4 @@ public function it_associates_channels(ChannelInterface $firstChannel, ChannelIn $this->hasChannel($firstChannel)->shouldReturn(false); } - - public function it_associates_taxons(TaxonInterface $firstTaxon, TaxonInterface $secondTaxon): void - { - $this->addTaxon($firstTaxon); - $this->hasTaxon($firstTaxon)->shouldReturn(true); - - $this->hasTaxon($secondTaxon)->shouldReturn(false); - - $this->removeTaxon($firstTaxon); - - $this->hasTaxon($secondTaxon)->shouldReturn(false); - } } diff --git a/spec/Entity/BlockTranslationSpec.php b/spec/Entity/BlockTranslationSpec.php deleted file mode 100755 index 2bc57c894..000000000 --- a/spec/Entity/BlockTranslationSpec.php +++ /dev/null @@ -1,47 +0,0 @@ -shouldHaveType(ResourceInterface::class); - } - - public function it_is_a_resource(): void - { - $this->shouldHaveType(ResourceInterface::class); - } - - public function it_implements_block_translation_interface(): void - { - $this->shouldHaveType(BlockTranslationInterface::class); - $this->shouldHaveType(TranslationInterface::class); - } - - public function it_allows_access_via_properties(): void - { - $this->setName('Escobar favorite quote'); - $this->getName()->shouldReturn('Escobar favorite quote'); - - $this->setLink('https://en.wikipedia.org/wiki/Pablo_Escobar'); - $this->getLink()->shouldReturn('https://en.wikipedia.org/wiki/Pablo_Escobar'); - - $this->setContent('Plata o plomo'); - $this->getContent()->shouldReturn('Plata o plomo'); - } -} diff --git a/spec/Entity/CollectionSpec.php b/spec/Entity/CollectionSpec.php new file mode 100755 index 000000000..33f6e6ac1 --- /dev/null +++ b/spec/Entity/CollectionSpec.php @@ -0,0 +1,34 @@ +shouldHaveType(Collection::class); + } + + public function it_is_a_resource(): void + { + $this->shouldHaveType(ResourceInterface::class); + } + + public function it_implements_collection_interface(): void + { + $this->shouldHaveType(CollectionInterface::class); + } + + public function it_allows_access_via_properties(): void + { + $this->setCode('blog'); + $this->getCode()->shouldReturn('blog'); + } +} diff --git a/spec/Entity/FrequentlyAskedQuestionSpec.php b/spec/Entity/FrequentlyAskedQuestionSpec.php deleted file mode 100755 index ceee3b218..000000000 --- a/spec/Entity/FrequentlyAskedQuestionSpec.php +++ /dev/null @@ -1,68 +0,0 @@ -shouldHaveType(FrequentlyAskedQuestion::class); - } - - public function it_is_a_resource(): void - { - $this->shouldHaveType(ResourceInterface::class); - } - - public function it_implements_frequently_asked_question_interface(): void - { - $this->shouldHaveType(FrequentlyAskedQuestionInterface::class); - } - - public function it_allows_access_via_properties(): void - { - $this->setCode('delivery_charges_for_orders'); - $this->getCode()->shouldReturn('delivery_charges_for_orders'); - - $this->setPosition(2); - $this->getPosition()->shouldReturn(2); - - $this->setEnabled(true); - $this->isEnabled()->shouldReturn(true); - } - - public function it_toggles(): void - { - $this->enable(); - $this->isEnabled()->shouldReturn(true); - - $this->disable(); - $this->isEnabled()->shouldReturn(false); - } - - public function it_associates_channels(ChannelInterface $firstChannel, ChannelInterface $secondChannel): void - { - $this->addChannel($firstChannel); - $this->hasChannel($firstChannel)->shouldReturn(true); - - $this->hasChannel($secondChannel)->shouldReturn(false); - - $this->removeChannel($firstChannel); - - $this->hasChannel($firstChannel)->shouldReturn(false); - } -} diff --git a/spec/Entity/FrequentlyAskedQuestionTranslationSpec.php b/spec/Entity/FrequentlyAskedQuestionTranslationSpec.php deleted file mode 100755 index 5f7ad21e4..000000000 --- a/spec/Entity/FrequentlyAskedQuestionTranslationSpec.php +++ /dev/null @@ -1,45 +0,0 @@ -shouldHaveType(FrequentlyAskedQuestionTranslation::class); - } - - public function it_is_a_resource() - { - $this->shouldHaveType(ResourceInterface::class); - } - - public function it_implements_frequently_asked_question_translation_interface() - { - $this->shouldHaveType(FrequentlyAskedQuestionTranslationInterface::class); - $this->shouldHaveType(TranslationInterface::class); - } - - public function it_allows_access_via_properties() - { - $this->setQuestion('What are the delivery charges for orders from the Online Shop?'); - $this->getQuestion()->shouldReturn('What are the delivery charges for orders from the Online Shop?'); - - $this->setAnswer('$20'); - $this->getAnswer()->shouldReturn('$20'); - } -} diff --git a/spec/Entity/MediaSpec.php b/spec/Entity/MediaSpec.php index 7ff608c2d..81cc7970c 100755 --- a/spec/Entity/MediaSpec.php +++ b/spec/Entity/MediaSpec.php @@ -1,21 +1,14 @@ setCode('file'); $this->getCode()->shouldReturn('file'); + $this->setName('Video'); + $this->getName()->shouldReturn('Video'); + $this->setType('video'); $this->getType()->shouldReturn('video'); @@ -65,28 +61,16 @@ public function it_toggles(): void $this->isEnabled()->shouldReturn(false); } - public function it_associates_products(ProductInterface $firstProduct, ProductInterface $secondProduct): void - { - $this->addProduct($firstProduct); - $this->hasProduct($firstProduct)->shouldReturn(true); - - $this->hasProduct($secondProduct)->shouldReturn(false); - - $this->removeProduct($firstProduct); - - $this->hasProduct($firstProduct)->shouldReturn(false); - } - - public function it_associates_sections(SectionInterface $firstSection, SectionInterface $secondSection): void + public function it_associates_collections(CollectionInterface $firstCollection, CollectionInterface $secondCollection): void { - $this->addSection($firstSection); - $this->hasSection($firstSection)->shouldReturn(true); + $this->addCollection($firstCollection); + $this->hasCollection($firstCollection)->shouldReturn(true); - $this->hasSection($secondSection)->shouldReturn(false); + $this->hasCollection($secondCollection)->shouldReturn(false); - $this->removeSection($firstSection); + $this->removeCollection($firstCollection); - $this->hasSection($firstSection)->shouldReturn(false); + $this->hasCollection($firstCollection)->shouldReturn(false); } public function it_associates_channels(ChannelInterface $firstChannel, ChannelInterface $secondChannel): void diff --git a/spec/Entity/MediaTranslationSpec.php b/spec/Entity/MediaTranslationSpec.php index 66f53fd4e..3e67ed87b 100755 --- a/spec/Entity/MediaTranslationSpec.php +++ b/spec/Entity/MediaTranslationSpec.php @@ -1,18 +1,12 @@ setName('Video'); - $this->getName()->shouldReturn('Video'); - $this->setContent('Lorem ipsum'); $this->getContent()->shouldReturn('Lorem ipsum'); diff --git a/spec/Entity/PageSpec.php b/spec/Entity/PageSpec.php index 0618b8c9b..ba0d211a0 100755 --- a/spec/Entity/PageSpec.php +++ b/spec/Entity/PageSpec.php @@ -1,21 +1,14 @@ isEnabled()->shouldReturn(false); } - public function it_associates_products(ProductInterface $firstProduct, ProductInterface $secondProduct): void - { - $this->addProduct($firstProduct); - $this->hasProduct($firstProduct)->shouldReturn(true); - - $this->hasProduct($secondProduct)->shouldReturn(false); - - $this->removeProduct($firstProduct); - - $this->hasProduct($firstProduct)->shouldReturn(false); - } - - public function it_associates_sections(SectionInterface $firstSection, SectionInterface $secondSection): void + public function it_associates_collections(CollectionInterface $firstCollection, CollectionInterface $secondCollection): void { - $this->addSection($firstSection); - $this->hasSection($firstSection)->shouldReturn(true); + $this->addCollection($firstCollection); + $this->hasCollection($firstCollection)->shouldReturn(true); - $this->hasSection($secondSection)->shouldReturn(false); + $this->hasCollection($secondCollection)->shouldReturn(false); - $this->removeSection($firstSection); + $this->removeCollection($firstCollection); - $this->hasSection($firstSection)->shouldReturn(false); + $this->hasCollection($firstCollection)->shouldReturn(false); } public function it_associates_channels(ChannelInterface $firstChannel, ChannelInterface $secondChannel): void diff --git a/spec/Entity/PageTranslationSpec.php b/spec/Entity/PageTranslationSpec.php index 75ecd391b..08ffb5eff 100755 --- a/spec/Entity/PageTranslationSpec.php +++ b/spec/Entity/PageTranslationSpec.php @@ -1,19 +1,13 @@ setName('Homepage'); - $this->getName()->shouldReturn('Homepage'); - $this->setSlug('homepage'); $this->getSlug()->shouldReturn('homepage'); - $this->setContent('

Homepage

'); - $this->getContent()->shouldReturn('

Homepage

'); - $this->setMetaKeywords('homepage'); $this->getMetaKeywords()->shouldReturn('homepage'); $this->setMetaDescription('Description'); $this->getMetaDescription()->shouldReturn('Description'); - $this->setImage($pageImage); - $this->getImage()->shouldReturn($pageImage); - - $this->setNameWhenLinked('name linked'); - $this->getNameWhenLinked()->shouldReturn('name linked'); - - $this->setBreadcrumb('name breadcrumb'); - $this->getBreadcrumb()->shouldReturn('name breadcrumb'); - - $this->setDescriptionWhenLinked('description linked'); - $this->getDescriptionWhenLinked()->shouldReturn('description linked'); - $this->setTitle('title'); $this->getTitle()->shouldReturn('title'); } diff --git a/spec/Entity/SectionSpec.php b/spec/Entity/SectionSpec.php deleted file mode 100755 index 99930c980..000000000 --- a/spec/Entity/SectionSpec.php +++ /dev/null @@ -1,40 +0,0 @@ -shouldHaveType(Section::class); - } - - public function it_is_a_resource(): void - { - $this->shouldHaveType(ResourceInterface::class); - } - - public function it_implements_section_interface(): void - { - $this->shouldHaveType(SectionInterface::class); - } - - public function it_allows_access_via_properties(): void - { - $this->setCode('blog'); - $this->getCode()->shouldReturn('blog'); - } -} diff --git a/spec/Entity/SectionTranslationSpec.php b/spec/Entity/SectionTranslationSpec.php deleted file mode 100755 index ea503732c..000000000 --- a/spec/Entity/SectionTranslationSpec.php +++ /dev/null @@ -1,42 +0,0 @@ -shouldHaveType(SectionTranslation::class); - } - - public function it_is_a_resource() - { - $this->shouldHaveType(ResourceInterface::class); - } - - public function it_implements_frequently_asked_question_translation_interface() - { - $this->shouldHaveType(SectionTranslationInterface::class); - $this->shouldHaveType(TranslationInterface::class); - } - - public function it_allows_access_via_properties() - { - $this->setName('Blog'); - $this->getName()->shouldReturn('Blog'); - } -} diff --git a/spec/EventListener/MediaUploadListenerSpec.php b/spec/EventListener/MediaUploadListenerSpec.php index c2017ce8e..ffd61455d 100755 --- a/spec/EventListener/MediaUploadListenerSpec.php +++ b/spec/EventListener/MediaUploadListenerSpec.php @@ -1,22 +1,16 @@ getSubject()->willReturn(Argument::any()); @@ -44,7 +38,7 @@ public function it_uploads_media( ResourceControllerEvent $event, MediaInterface $media, MediaProviderResolverInterface $mediaProviderResolver, - ProviderInterface $provider + ProviderInterface $provider, ): void { $event->getSubject()->willReturn($media); $mediaProviderResolver->resolveProvider($media)->willReturn($provider); diff --git a/spec/Exception/ImportFailedExceptionSpec.php b/spec/Exception/ImportFailedExceptionSpec.php index 15597534d..5f06c02e1 100755 --- a/spec/Exception/ImportFailedExceptionSpec.php +++ b/spec/Exception/ImportFailedExceptionSpec.php @@ -1,17 +1,11 @@ beConstructedWith($mediaRepository); + } + + public function it_is_initializable(): void + { + $this->shouldHaveType(MultipleMediaToCodesTransformer::class); + } + + public function it_transforms_null_value_to_empty_collection(): void + { + $this->transform(null)->shouldBeAnInstanceOf(ArrayCollection::class); + $this->transform(null)->count()->shouldBe(0); + } + + public function it_transforms_empty_array_to_empty_collection(): void + { + $this->transform([])->shouldBeAnInstanceOf(ArrayCollection::class); + $this->transform([])->count()->shouldBe(0); + } + + public function it_transforms_non_empty_array_to_collection( + MediaRepositoryInterface $mediaRepository, + MediaInterface $media1, + MediaInterface $media2, + ): void { + $mediaCodes = ['code1', 'code2']; + $mediaRepository->findBy(['code' => $mediaCodes])->willReturn([$media1, $media2]); + + $this->transform($mediaCodes)->shouldBeAnInstanceOf(ArrayCollection::class); + $this->transform($mediaCodes)->shouldHaveCount(2); + $this->transform($mediaCodes)->toArray()->shouldBe([$media1, $media2]); + } + + public function it_reverse_transforms_empty_collection_to_empty_array(): void + { + $collection = new ArrayCollection(); + $this->reverseTransform($collection)->shouldBeArray(); + $this->reverseTransform($collection)->shouldBe([]); + } + + public function it_reverse_transforms_collection_to_array_of_media_codes( + MediaInterface $media1, + MediaInterface $media2, + ): void { + $media1->getCode()->willReturn('code1'); + $media2->getCode()->willReturn('code2'); + + $collection = new ArrayCollection([$media1->getWrappedObject(), $media2->getWrappedObject()]); + + $this->reverseTransform($collection)->shouldBe(['code1', 'code2']); + } +} diff --git a/spec/Importer/BlockImporterSpec.php b/spec/Importer/BlockImporterSpec.php index 8801d74c7..9c6566908 100644 --- a/spec/Importer/BlockImporterSpec.php +++ b/spec/Importer/BlockImporterSpec.php @@ -1,23 +1,21 @@ beConstructedWith( $blockResourceResolver, - $localeContext, - $importerSectionsResolver, + $importerCollectionsResolver, $importerChannelsResolver, $importerProductsResolver, + $importerTaxonsResolver, + $importerProductsInTaxonsResolver, $validator, - $blockRepository + $blockRepository, ); } public function it_is_initializable() { - $this->shouldHaveType(\BitBag\SyliusCmsPlugin\Importer\BlockImporter::class); - $this->shouldImplement(\BitBag\SyliusCmsPlugin\Importer\BlockImporterInterface::class); + $this->shouldHaveType(BlockImporter::class); + $this->shouldImplement(BlockImporterInterface::class); } public function it_imports_block( ResourceResolverInterface $blockResourceResolver, - LocaleContextInterface $localeContext, - ImporterSectionsResolverInterface $importerSectionsResolver, + ImporterCollectionsResolverInterface $importerCollectionsResolver, ImporterChannelsResolverInterface $importerChannelsResolver, ImporterProductsResolverInterface $importerProductsResolver, + ImporterTaxonsResolverInterface $importerTaxonsResolver, + ImporterProductsInTaxonsResolverInterface $importerProductsInTaxonsResolver, ValidatorInterface $validator, BlockRepositoryInterface $blockRepository, - BlockInterface $block + BlockInterface $block, ) { - $row = ['name_pl' => 'name', 'content_pl' => 'content', 'link_pl' => 'link', 'code' => 'block_code']; + $row = ['name' => 'block_name', 'code' => 'block_code', 'enabled' => '1']; $blockResourceResolver->getResource('block_code')->willReturn($block); - $localeContext->getLocaleCode()->willReturn('en_US'); - $block->setCode('block_code')->shouldBeCalled(); - $block->setFallbackLocale('en_US')->shouldBeCalled(); - $block->setCurrentLocale('pl')->shouldBeCalled(); - $block->setName('name')->shouldBeCalled(); - $block->setLink('link')->shouldBeCalled(); - $block->setContent('content')->shouldBeCalled(); + $block->setName('block_name')->shouldBeCalled(); + $block->setEnabled(true)->shouldBeCalled(); - $importerSectionsResolver->resolve($block, null)->shouldBeCalled(); + $importerCollectionsResolver->resolve($block, null)->shouldBeCalled(); $importerChannelsResolver->resolve($block, null)->shouldBeCalled(); $importerProductsResolver->resolve($block, null)->shouldBeCalled(); + $importerTaxonsResolver->resolve($block, null)->shouldBeCalled(); + $importerProductsInTaxonsResolver->resolve($block, null)->shouldBeCalled(); - $validator->validate($block, null, ['bitbag'])->willReturn(new ConstraintViolationList()); + $validator->validate($block, null, ['cms'])->willReturn(new ConstraintViolationList()); $blockRepository->add($block)->shouldBeCalled(); diff --git a/spec/Importer/MediaImporterSpec.php b/spec/Importer/MediaImporterSpec.php index 2b8171d85..14df2cda1 100644 --- a/spec/Importer/MediaImporterSpec.php +++ b/spec/Importer/MediaImporterSpec.php @@ -1,21 +1,14 @@ beConstructedWith( $mediaResourceResolver, $localeContext, - $importerSectionsResolver, - $importerProductsResolver, + $importerCollectionsResolver, $validator, $mediaRepository, ); @@ -42,18 +33,17 @@ public function let( public function it_is_initializable() { - $this->shouldHaveType(\BitBag\SyliusCmsPlugin\Importer\MediaImporter::class); - $this->shouldImplement(\BitBag\SyliusCmsPlugin\Importer\MediaImporterInterface::class); + $this->shouldHaveType(\Sylius\CmsPlugin\Importer\MediaImporter::class); + $this->shouldImplement(\Sylius\CmsPlugin\Importer\MediaImporterInterface::class); } public function it_imports_media( ResourceResolverInterface $mediaResourceResolver, LocaleContextInterface $localeContext, - ImporterSectionsResolverInterface $importerSectionsResolver, - ImporterProductsResolverInterface $importerProductsResolver, + ImporterCollectionsResolverInterface $importerCollectionsResolver, ValidatorInterface $validator, MediaRepositoryInterface $mediaRepository, - MediaInterface $media + MediaInterface $media, ) { $row = ['name_pl' => 'name', 'content_pl' => 'content', 'alt_pl' => 'alt', 'code' => 'media_code']; @@ -68,10 +58,9 @@ public function it_imports_media( $media->setContent('content')->shouldBeCalled(); $media->setAlt('alt')->shouldBeCalled(); - $importerSectionsResolver->resolve($media, null)->shouldBeCalled(); - $importerProductsResolver->resolve($media, null)->shouldBeCalled(); + $importerCollectionsResolver->resolve($media, null)->shouldBeCalled(); - $validator->validate($media, null, ['bitbag'])->willReturn(new ConstraintViolationList()); + $validator->validate($media, null, ['cms'])->willReturn(new ConstraintViolationList()); $mediaRepository->add($media)->shouldBeCalled(); diff --git a/spec/Importer/PageImporterSpec.php b/spec/Importer/PageImporterSpec.php index 2a014971d..6be306720 100644 --- a/spec/Importer/PageImporterSpec.php +++ b/spec/Importer/PageImporterSpec.php @@ -1,26 +1,16 @@ beConstructedWith( $pageResourceResolver, $localeContext, - $imageDownloader, - $mediaFactory, - $mediaProviderResolver, - $importerSectionsResolver, + $importerCollectionsResolver, $importerChannelsResolver, - $importerProductsResolver, $validator, $entityManager, ); @@ -54,35 +36,29 @@ public function let( public function it_is_initializable() { - $this->shouldHaveType(\BitBag\SyliusCmsPlugin\Importer\PageImporter::class); - $this->shouldImplement(\BitBag\SyliusCmsPlugin\Importer\PageImporterInterface::class); + $this->shouldHaveType(\Sylius\CmsPlugin\Importer\PageImporter::class); + $this->shouldImplement(\Sylius\CmsPlugin\Importer\PageImporterInterface::class); } public function it_imports_page_no_url( ResourceResolverInterface $pageResourceResolver, LocaleContextInterface $localeContext, - ImporterSectionsResolverInterface $importerSectionsResolver, + ImporterCollectionsResolverInterface $importerCollectionsResolver, ImporterChannelsResolverInterface $importerChannelsResolver, - ImporterProductsResolverInterface $importerProductsResolver, ValidatorInterface $validator, EntityManagerInterface $entityManager, PageInterface $page, - ) { + ) { $row = [ 'code' => 'page_code', + 'name' => 'page_name', + 'enabled' => '1', 'slug_pl' => 'slug', - 'name_pl' => 'name', - 'image_pl' => null, - 'imagecode_pl' => 'imagecode', - 'metakeywords_pl' => 'metakeywords', - 'metadescription_pl' => 'metadescription', - 'content_pl' => 'content', - 'breadcrumb_pl' => 'breadcrumb', - 'namewhenlinked_pl' => 'namewhenlinked', - 'descriptionwhenlinked_pl' => 'descriptionwhenlinked', - 'sections' => 'sections', + 'meta_title_pl' => 'metatitle', + 'meta_keywords_pl' => 'metakeywords', + 'meta_description_pl' => 'metadescription', + 'collections' => 'collections', 'channels' => 'channels', - 'products' => 'products', ]; $pageResourceResolver->getResource('page_code')->willReturn($page); @@ -90,24 +66,21 @@ public function it_imports_page_no_url( $localeContext->getLocaleCode()->willReturn('en_US'); $page->setCode('page_code')->shouldBeCalled(); + $page->setName('page_name')->shouldBeCalled(); + $page->setEnabled(true)->shouldBeCalled(); $page->setFallbackLocale('en_US')->shouldBeCalled(); $page->setCurrentLocale('pl')->shouldBeCalled(); $page->setSlug('slug')->shouldBeCalled(); - $page->setName('name')->shouldBeCalled(); + $page->setTitle('metatitle')->shouldBeCalled(); $page->setMetaKeywords('metakeywords')->shouldBeCalled(); $page->setMetaDescription('metadescription')->shouldBeCalled(); - $page->setContent('content')->shouldBeCalled(); - $page->setBreadcrumb('breadcrumb')->shouldBeCalled(); - $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(); - $validator->validate($page, null, ['bitbag'])->willReturn(new ConstraintViolationList()); + $validator->validate($page, null, ['cms'])->willReturn(new ConstraintViolationList()); $entityManager->persist($page)->shouldBeCalled(); $entityManager->flush()->shouldBeCalled(); diff --git a/spec/MediaProvider/FilenameHelperSpec.php b/spec/MediaProvider/FilenameHelperSpec.php index dd9312bbe..80bdba551 100644 --- a/spec/MediaProvider/FilenameHelperSpec.php +++ b/spec/MediaProvider/FilenameHelperSpec.php @@ -1,18 +1,11 @@ beConstructedWith($uploader, $twigEngine, '@Template', '/media/'); } diff --git a/spec/MediaProvider/GenericProviderSpec.php~refs/remotes/origin/master b/spec/MediaProvider/GenericProviderSpec.php~refs/remotes/origin/master index 098d51d65..c7b9e5dc7 100644 --- a/spec/MediaProvider/GenericProviderSpec.php~refs/remotes/origin/master +++ b/spec/MediaProvider/GenericProviderSpec.php~refs/remotes/origin/master @@ -1,19 +1,13 @@ beConstructedWith($menuReorder); + } + public function it_is_initializable(): void { $this->shouldHaveType(ContentManagementMenuBuilder::class); @@ -25,46 +25,51 @@ public function it_is_initializable(): void public function it_build_menu( MenuBuilderEvent $menuBuilderEvent, ItemInterface $menu, - ItemInterface $cmsRootMenuItem + ItemInterface $cmsRootMenuItem, ): void { $menuBuilderEvent->getMenu()->willReturn($menu); - $menu->addChild('bitbag_cms')->willReturn($cmsRootMenuItem); - $cmsRootMenuItem->setLabel('bitbag_sylius_cms_plugin.ui.cms')->willReturn($cmsRootMenuItem); + $menu->addChild('sylius_cms')->willReturn($cmsRootMenuItem); + $cmsRootMenuItem->setLabel('sylius_cms.ui.cms')->willReturn($cmsRootMenuItem); $cmsRootMenuItem - ->addChild('blocks', ['route' => 'bitbag_sylius_cms_plugin_admin_block_index']) + ->addChild('blocks', ['route' => 'sylius_cms_admin_block_index']) ->willReturn($cmsRootMenuItem) ; - $cmsRootMenuItem->setLabel('bitbag_sylius_cms_plugin.ui.blocks')->willReturn($cmsRootMenuItem); + $cmsRootMenuItem->setLabel('sylius_cms.ui.blocks')->willReturn($cmsRootMenuItem); $cmsRootMenuItem->setLabelAttribute('icon', 'block layout')->shouldBeCalled(); $cmsRootMenuItem - ->addChild('pages', ['route' => 'bitbag_sylius_cms_plugin_admin_page_index']) + ->addChild('pages', ['route' => 'sylius_cms_admin_page_index']) ->willReturn($cmsRootMenuItem) ; - $cmsRootMenuItem->setLabel('bitbag_sylius_cms_plugin.ui.pages')->willReturn($cmsRootMenuItem); + $cmsRootMenuItem->setLabel('sylius_cms.ui.pages')->willReturn($cmsRootMenuItem); $cmsRootMenuItem->setLabelAttribute('icon', 'sticky note')->shouldBeCalled(); $cmsRootMenuItem - ->addChild('faq', ['route' => 'bitbag_sylius_cms_plugin_admin_frequently_asked_question_index']) + ->addChild('collections', ['route' => 'sylius_cms_admin_collection_index']) ->willReturn($cmsRootMenuItem) ; - $cmsRootMenuItem->setLabel('bitbag_sylius_cms_plugin.ui.faq')->willReturn($cmsRootMenuItem); - $cmsRootMenuItem->setLabelAttribute('icon', 'help')->shouldBeCalled(); + $cmsRootMenuItem->setLabel('sylius_cms.ui.collections')->willReturn($cmsRootMenuItem); + $cmsRootMenuItem->setLabelAttribute('icon', 'grid layout')->shouldBeCalled(); $cmsRootMenuItem - ->addChild('sections', ['route' => 'bitbag_sylius_cms_plugin_admin_section_index']) + ->addChild('templates', ['route' => 'sylius_cms_admin_template_index']) ->willReturn($cmsRootMenuItem) ; - $cmsRootMenuItem->setLabel('bitbag_sylius_cms_plugin.ui.sections')->willReturn($cmsRootMenuItem); - $cmsRootMenuItem->setLabelAttribute('icon', 'grid layout')->shouldBeCalled(); + $cmsRootMenuItem->setLabel('sylius_cms.ui.content_templates')->willReturn($cmsRootMenuItem); + $cmsRootMenuItem->setLabelAttribute('icon', 'clone')->shouldBeCalled(); $cmsRootMenuItem - ->addChild('media', ['route' => 'bitbag_sylius_cms_plugin_admin_media_index']) + ->addChild('media', ['route' => 'sylius_cms_admin_media_index']) ->willReturn($cmsRootMenuItem) ; - $cmsRootMenuItem->setLabel('bitbag_sylius_cms_plugin.ui.media')->willReturn($cmsRootMenuItem); + $cmsRootMenuItem->setLabel('sylius_cms.ui.media')->willReturn($cmsRootMenuItem); $cmsRootMenuItem->setLabelAttribute('icon', 'file')->shouldBeCalled(); + $menu->getChildren()->willReturn(['marketing' => $cmsRootMenuItem]); + $menu->getChild('sylius_cms')->willReturn($cmsRootMenuItem); + + $menu->setChildren(['marketing' => $cmsRootMenuItem, 'sylius_cms' => $cmsRootMenuItem])->willReturn($menu); + $this->buildMenu($menuBuilderEvent); } } diff --git a/spec/Menu/MenuReorderSpec.php b/spec/Menu/MenuReorderSpec.php new file mode 100644 index 000000000..b992e9166 --- /dev/null +++ b/spec/Menu/MenuReorderSpec.php @@ -0,0 +1,96 @@ +shouldHaveType(MenuReorder::class); + } + + public function it_implements_menu_reorder_interface(): void + { + $this->shouldImplement(MenuReorderInterface::class); + } + + public function it_reorders_menu_items( + ItemInterface $menu, + ItemInterface $item1, + ItemInterface $item2, + ItemInterface $item3, + ): void { + $menu->getChildren()->willReturn([ + 'item1' => $item1, + 'item2' => $item2, + 'item3' => $item3, + ]); + + $menu->getChild('item2')->willReturn($item2); + + $menu->setChildren([ + 'item1' => $item1, + 'item3' => $item3, + 'item2' => $item2, + ])->shouldBeCalled(); + + $this->reorder($menu, 'item2', 'item3'); + } + + public function it_does_not_reorder_if_new_item_is_not_found( + ItemInterface $menu, + ItemInterface $item1, + ItemInterface $item3, + ): void { + $menu->getChildren()->willReturn([ + 'item1' => $item1, + 'item3' => $item3, + ]); + + $menu->getChild('item2')->willReturn(null); + $menu->setChildren(Argument::any())->shouldNotBeCalled(); + + $this->reorder($menu, 'item2', 'item3'); + } + + public function it_does_not_reorder_if_target_item_is_not_found( + ItemInterface $menu, + ItemInterface $item1, + ItemInterface $item2, + ): void { + $menu->getChildren()->willReturn([ + 'item1' => $item1, + 'item2' => $item2, + ]); + + $menu->getChild('item1')->willReturn($item1); + $menu->setChildren(Argument::any())->shouldNotBeCalled(); + + $this->reorder($menu, 'item1', 'item3'); + } + + public function it_does_not_modify_menu_when_no_reorder_is_needed( + ItemInterface $menu, + ItemInterface $item1, + ItemInterface $item2, + ): void { + $menu->getChildren()->willReturn([ + 'item1' => $item1, + 'item2' => $item2, + ]); + + $menu->getChild('item1')->willReturn($item1); + $menu->getChild('item2')->willReturn($item2); + $menu->setChildren(Argument::any())->shouldNotBeCalled(); + + $this->reorder($menu, 'item1', 'item1'); + } +} diff --git a/spec/Processor/ImportProcessorSpec.php b/spec/Processor/ImportProcessorSpec.php index b1129d087..9d584c298 100644 --- a/spec/Processor/ImportProcessorSpec.php +++ b/spec/Processor/ImportProcessorSpec.php @@ -1,30 +1,23 @@ beConstructedWith($importerChain, $reader, $entityManager); } @@ -38,7 +31,7 @@ public function it_processes_import_data( ImporterChainInterface $importerChain, ReaderInterface $reader, EntityManagerInterface $entityManager, - ImporterInterface $importer + ImporterInterface $importer, ) { $resourceCode = 'some_resource'; $filePath = 'path/to/file.csv'; @@ -65,7 +58,7 @@ public function it_throws_exception_when_import_fails( ImporterChainInterface $importerChain, ReaderInterface $reader, EntityManagerInterface $entityManager, - ImporterInterface $importer + ImporterInterface $importer, ) { $resourceCode = 'some_resource'; $filePath = 'path/to/file.csv'; diff --git a/spec/Provider/ResourceTemplateProviderSpec.php b/spec/Provider/ResourceTemplateProviderSpec.php new file mode 100644 index 000000000..42660386d --- /dev/null +++ b/spec/Provider/ResourceTemplateProviderSpec.php @@ -0,0 +1,52 @@ +get('sylius_cms.templates.pages')->willReturn([ + '@CustomTemplate/Page.html.twig' => '@CustomTemplate/Page.html.twig', + ]); + + $parameterBag->get('sylius_cms.templates.blocks')->willReturn([ + '@CustomTemplate/Block.html.twig' => '@CustomTemplate/Block.html.twig', + ]); + + $this->beConstructedWith($parameterBag); + } + + public function it_is_initializable(): void + { + $this->shouldHaveType(ResourceTemplateProvider::class); + } + + public function it_implements_resource_template_provider_interface(): void + { + $this->shouldImplement(ResourceTemplateProviderInterface::class); + } + + public function it_returns_default_and_custom_page_templates(): void + { + $this->getPageTemplates()->shouldReturn([ + 'sylius.ui.default' => '@SyliusCmsPlugin/Shop/Page/show.html.twig', + '@CustomTemplate/Page.html.twig' => '@CustomTemplate/Page.html.twig', + ]); + } + + public function it_returns_default_and_custom_block_templates(): void + { + $this->getBlockTemplates()->shouldReturn([ + 'sylius.ui.default' => '@SyliusCmsPlugin/Shop/Block/show.html.twig', + '@CustomTemplate/Block.html.twig' => '@CustomTemplate/Block.html.twig', + ]); + } +} diff --git a/spec/Renderer/Collection/CollectionBlocksRendererSpec.php b/spec/Renderer/Collection/CollectionBlocksRendererSpec.php new file mode 100644 index 000000000..af03a76c6 --- /dev/null +++ b/spec/Renderer/Collection/CollectionBlocksRendererSpec.php @@ -0,0 +1,89 @@ +beConstructedWith($contentElementRendererStrategy); + } + + public function it_is_initializable(): void + { + $this->shouldHaveType(CollectionBlocksRenderer::class); + } + + public function it_implements_collection_renderer_interface(): void + { + $this->shouldImplement(CollectionRendererInterface::class); + } + + public function it_renders_blocks_from_collection( + ContentElementRendererStrategyInterface $contentElementRendererStrategy, + CollectionInterface $collection, + BlockInterface $block1, + BlockInterface $block2, + ): void { + $blocks = new ArrayCollection([$block1->getWrappedObject(), $block2->getWrappedObject()]); + $collection->getBlocks()->willReturn($blocks); + + $contentElementRendererStrategy->render($block1)->willReturn('block1_content'); + $contentElementRendererStrategy->render($block2)->willReturn('block2_content'); + + $this->render($collection)->shouldReturn('block1_contentblock2_content'); + } + + public function it_limits_number_of_rendered_blocks( + ContentElementRendererStrategyInterface $contentElementRendererStrategy, + CollectionInterface $collection, + BlockInterface $block1, + BlockInterface $block2, + ): void { + $blocks = new ArrayCollection([$block1->getWrappedObject(), $block2->getWrappedObject()]); + $collection->getBlocks()->willReturn($blocks); + + $contentElementRendererStrategy->render($block1)->willReturn('block1_content'); + $contentElementRendererStrategy->render($block2)->willReturn('block2_content'); + + $this->render($collection, 1)->shouldReturn('block1_content'); + } + + public function it_supports_collections_with_blocks( + CollectionInterface $collection, + BlockInterface $block, + ): void { + $blocks = new ArrayCollection([$block]); + $collection->getBlocks()->willReturn($blocks); + + $this->supports($collection)->shouldReturn(true); + } + + public function it_does_not_support_empty_collections( + CollectionInterface $collection, + ): void { + $collection->getBlocks()->willReturn(new ArrayCollection()); + + $this->supports($collection)->shouldReturn(false); + } + + public function it_throws_exception_when_blocks_are_null( + ContentElementRendererStrategyInterface $contentElementRendererStrategy, + CollectionInterface $collection, + ): void { + $collection->getBlocks()->willReturn(null); + + $this->shouldThrow(\InvalidArgumentException::class) + ->during('render', [$collection]); + } +} diff --git a/spec/Renderer/Collection/CollectionMediaRendererSpec.php b/spec/Renderer/Collection/CollectionMediaRendererSpec.php new file mode 100644 index 000000000..84ba0b334 --- /dev/null +++ b/spec/Renderer/Collection/CollectionMediaRendererSpec.php @@ -0,0 +1,72 @@ +beConstructedWith($renderMediaRuntime); + } + + function it_is_initializable() + { + $this->shouldHaveType(CollectionMediaRenderer::class); + $this->shouldImplement(CollectionRendererInterface::class); + } + + function it_renders_media_collection(RenderMediaRuntimeInterface $renderMediaRuntime, CollectionInterface $collection, MediaInterface $media1, MediaInterface $media2) + { + $media1->getId()->willReturn(1); + $media2->getId()->willReturn(2); + + $media1->getCode()->willReturn('media_code_1'); + $media2->getCode()->willReturn('media_code_2'); + + $collection->getMedia()->willReturn(new ArrayCollection([$media1->getWrappedObject(), $media2->getWrappedObject()])); + + $renderMediaRuntime->renderMedia('media_code_1')->willReturn('media1'); + $renderMediaRuntime->renderMedia('media_code_2')->willReturn('media2'); + + $this->render($collection)->shouldReturn('media1media2'); + } + + function it_renders_limited_number_of_media(RenderMediaRuntimeInterface $renderMediaRuntime, CollectionInterface $collection, MediaInterface $media1, MediaInterface $media2) + { + $media1->getId()->willReturn(1); + $media2->getId()->willReturn(2); + + $media1->getCode()->willReturn('media_code_1'); + $media2->getCode()->willReturn('media_code_2'); + + $collection->getMedia()->willReturn(new ArrayCollection([$media1->getWrappedObject(), $media2->getWrappedObject()])); + + $renderMediaRuntime->renderMedia('media_code_1')->willReturn('media1'); + + $this->render($collection, 1)->shouldReturn('media1'); + } + + function it_supports_collections_with_media(CollectionInterface $collection, MediaInterface $media1) + { + $collection->getMedia()->willReturn(new ArrayCollection([$media1])); + + $this->supports($collection)->shouldReturn(true); + } + + function it_does_not_support_collections_without_media(CollectionInterface $collection) + { + $collection->getMedia()->willReturn(new ArrayCollection()); + + $this->supports($collection)->shouldReturn(false); + } +} diff --git a/spec/Renderer/Collection/CollectionPagesRendererSpec.php b/spec/Renderer/Collection/CollectionPagesRendererSpec.php new file mode 100644 index 000000000..f98bc1b34 --- /dev/null +++ b/spec/Renderer/Collection/CollectionPagesRendererSpec.php @@ -0,0 +1,82 @@ +beConstructedWith($pageLinkRenderer); + } + + public function it_is_initializable(): void + { + $this->shouldHaveType(CollectionPagesRenderer::class); + } + + public function it_implements_collection_renderer_interface(): void + { + $this->shouldImplement(CollectionRendererInterface::class); + } + + public function it_renders_pages_from_collection( + PageLinkRendererInterface $pageLinkRenderer, + CollectionInterface $collection, + PageInterface $page1, + PageInterface $page2, + ): void { + $page1->getId()->willReturn(2); + $page2->getId()->willReturn(1); + + $collection->getPages()->willReturn(new ArrayCollection([$page1->getWrappedObject(), $page2->getWrappedObject()])); + + $pageLinkRenderer->render($page1)->willReturn('page1_content'); + $pageLinkRenderer->render($page2)->willReturn('page2_content'); + + $this->render($collection)->shouldReturn('page1_contentpage2_content'); + } + + public function it_limits_number_of_rendered_pages( + PageLinkRendererInterface $pageLinkRenderer, + CollectionInterface $collection, + PageInterface $page1, + PageInterface $page2, + ): void { + $page1->getId()->willReturn(2); + $page2->getId()->willReturn(1); + + $collection->getPages()->willReturn(new ArrayCollection([$page1->getWrappedObject(), $page2->getWrappedObject()])); + + $pageLinkRenderer->render($page1)->willReturn('page1_content'); + $pageLinkRenderer->render($page2)->willReturn('page2_content'); + + $this->render($collection, 1)->shouldReturn('page1_content'); + } + + public function it_supports_collections_with_pages( + CollectionInterface $collection, + PageInterface $page, + ): void { + $collection->getPages()->willReturn(new ArrayCollection([$page])); + + $this->supports($collection)->shouldReturn(true); + } + + public function it_does_not_support_empty_collections( + CollectionInterface $collection, + ): void { + $collection->getPages()->willReturn(new ArrayCollection()); + + $this->supports($collection)->shouldReturn(false); + } +} diff --git a/spec/Renderer/CollectionRendererStrategySpec.php b/spec/Renderer/CollectionRendererStrategySpec.php new file mode 100644 index 000000000..38e250271 --- /dev/null +++ b/spec/Renderer/CollectionRendererStrategySpec.php @@ -0,0 +1,64 @@ +beConstructedWith([$renderer1, $renderer2]); + } + + public function it_is_initializable(): void + { + $this->shouldHaveType(CollectionRendererStrategy::class); + } + + public function it_implements_collection_renderer_strategy_interface(): void + { + $this->shouldImplement(CollectionRendererStrategyInterface::class); + } + + public function it_renders_collection_using_supported_renderer( + CollectionRendererInterface $renderer1, + CollectionRendererInterface $renderer2, + CollectionInterface $collection, + ): void { + $renderer1->supports($collection)->willReturn(false); + $renderer2->supports($collection)->willReturn(true); + $renderer2->render($collection, null)->willReturn('rendered content'); + + $this->render($collection)->shouldReturn('rendered content'); + } + + public function it_renders_collection_with_count_to_render( + CollectionRendererInterface $renderer1, + CollectionRendererInterface $renderer2, + CollectionInterface $collection, + ): void { + $renderer1->supports($collection)->willReturn(false); + $renderer2->supports($collection)->willReturn(true); + $renderer2->render($collection, 5)->willReturn('rendered content with count'); + + $this->render($collection, 5)->shouldReturn('rendered content with count'); + } + + public function it_returns_empty_string_when_no_renderer_supports_collection( + CollectionRendererInterface $renderer1, + CollectionRendererInterface $renderer2, + CollectionInterface $collection, + ): void { + $renderer1->supports($collection)->willReturn(false); + $renderer2->supports($collection)->willReturn(false); + + $this->render($collection)->shouldReturn(''); + } +} diff --git a/spec/Renderer/ContentElement/HeadingContentElementRendererSpec.php b/spec/Renderer/ContentElement/HeadingContentElementRendererSpec.php new file mode 100644 index 000000000..63e3d71c9 --- /dev/null +++ b/spec/Renderer/ContentElement/HeadingContentElementRendererSpec.php @@ -0,0 +1,53 @@ +shouldHaveType(HeadingContentElementRenderer::class); + $this->shouldBeAnInstanceOf(AbstractContentElement::class); + } + + public function it_supports_heading_content_element_type(ContentConfigurationInterface $contentConfiguration): void + { + $contentConfiguration->getType()->willReturn(HeadingContentElementType::TYPE); + $this->supports($contentConfiguration)->shouldReturn(true); + } + + public function it_does_not_support_other_content_element_types(ContentConfigurationInterface $contentConfiguration): void + { + $contentConfiguration->getType()->willReturn('other_type'); + $this->supports($contentConfiguration)->shouldReturn(false); + } + + public function it_renders_heading_content_element(Environment $twig, ContentConfigurationInterface $contentConfiguration): void + { + $template = 'custom_template'; + $this->setTemplate($template); + $this->setTwigEnvironment($twig); + + $contentConfiguration->getConfiguration()->willReturn([ + 'heading_type' => 'h1', + 'heading' => 'Sample Heading', + ]); + + $twig->render('@SyliusCmsPlugin/Shop/ContentElement/index.html.twig', [ + 'content_element' => $template, + 'heading_type' => 'h1', + 'heading_content' => 'Sample Heading', + ])->willReturn('rendered template'); + + $this->render($contentConfiguration)->shouldReturn('rendered template'); + } +} diff --git a/spec/Renderer/ContentElement/MultipleMediaContentElementRendererSpec.php b/spec/Renderer/ContentElement/MultipleMediaContentElementRendererSpec.php new file mode 100644 index 000000000..bbfae8d24 --- /dev/null +++ b/spec/Renderer/ContentElement/MultipleMediaContentElementRendererSpec.php @@ -0,0 +1,84 @@ +beConstructedWith($renderMediaRuntime, $mediaRepository); + } + + public function it_is_initializable(): void + { + $this->shouldHaveType(MultipleMediaContentElementRenderer::class); + $this->shouldBeAnInstanceOf(AbstractContentElement::class); + } + + public function it_supports_multiple_media_content_element_type(ContentConfigurationInterface $contentConfiguration): void + { + $contentConfiguration->getType()->willReturn(MultipleMediaContentElementType::TYPE); + $this->supports($contentConfiguration)->shouldReturn(true); + } + + public function it_does_not_support_other_content_element_types(ContentConfigurationInterface $contentConfiguration): void + { + $contentConfiguration->getType()->willReturn('other_type'); + $this->supports($contentConfiguration)->shouldReturn(false); + } + + public function it_renders_multiple_media_content_element( + Environment $twig, + RenderMediaRuntimeInterface $renderMediaRuntime, + MediaRepositoryInterface $mediaRepository, + ContentConfigurationInterface $contentConfiguration, + MediaInterface $media1, + MediaInterface $media2, + ): void { + $template = 'custom_template'; + $this->setTemplate($template); + $this->setTwigEnvironment($twig); + + $contentConfiguration->getConfiguration()->willReturn([ + 'multiple_media' => ['code1', 'code2'], + ]); + + $mediaRepository->findBy(['code' => ['code1', 'code2']])->willReturn([$media1, $media2]); + + $media1->getCode()->willReturn('code1'); + $media2->getCode()->willReturn('code2'); + + $renderMediaRuntime->renderMedia('code1')->willReturn('rendered media 1'); + $renderMediaRuntime->renderMedia('code2')->willReturn('rendered media 2'); + + $twig->render('@SyliusCmsPlugin/Shop/ContentElement/index.html.twig', [ + 'content_element' => $template, + 'media' => [ + [ + 'renderedContent' => 'rendered media 1', + 'entity' => $media1, + ], + [ + 'renderedContent' => 'rendered media 2', + 'entity' => $media2, + ], + ], + ])->willReturn('rendered template'); + + $this->render($contentConfiguration)->shouldReturn('rendered template'); + } +} diff --git a/spec/Renderer/ContentElement/PagesCollectionContentElementRendererSpec.php b/spec/Renderer/ContentElement/PagesCollectionContentElementRendererSpec.php new file mode 100644 index 000000000..a44bea055 --- /dev/null +++ b/spec/Renderer/ContentElement/PagesCollectionContentElementRendererSpec.php @@ -0,0 +1,68 @@ +beConstructedWith($collectionRepository); + } + + public function it_is_initializable(): void + { + $this->shouldHaveType(PagesCollectionContentElementRenderer::class); + $this->shouldBeAnInstanceOf(AbstractContentElement::class); + } + + public function it_supports_pages_collection_content_element_type(ContentConfigurationInterface $contentConfiguration): void + { + $contentConfiguration->getType()->willReturn(PagesCollectionContentElementType::TYPE); + $this->supports($contentConfiguration)->shouldReturn(true); + } + + public function it_does_not_support_other_content_element_types(ContentConfigurationInterface $contentConfiguration): void + { + $contentConfiguration->getType()->willReturn('other_type'); + $this->supports($contentConfiguration)->shouldReturn(false); + } + + public function it_renders_pages_collection_content_element( + Environment $twig, + CollectionRepositoryInterface $collectionRepository, + ContentConfigurationInterface $contentConfiguration, + CollectionInterface $collection, + ): void { + $template = 'custom_template'; + $this->setTemplate($template); + $this->setTwigEnvironment($twig); + + $contentConfiguration->getConfiguration()->willReturn([ + 'pages_collection' => 'collection_code', + ]); + + $collectionRepository->findOneBy(['code' => 'collection_code'])->willReturn($collection); + + $pagesCollection = new ArrayCollection(['page1', 'page2']); + $collection->getPages()->willReturn($pagesCollection); + + $twig->render('@SyliusCmsPlugin/Shop/ContentElement/index.html.twig', [ + 'content_element' => $template, + 'collection' => $pagesCollection, + ])->willReturn('rendered_output'); + + $this->render($contentConfiguration)->shouldReturn('rendered_output'); + } +} diff --git a/spec/Renderer/ContentElement/ProductsCarouselByTaxonContentElementRendererSpec.php b/spec/Renderer/ContentElement/ProductsCarouselByTaxonContentElementRendererSpec.php new file mode 100644 index 000000000..b79c1ff64 --- /dev/null +++ b/spec/Renderer/ContentElement/ProductsCarouselByTaxonContentElementRendererSpec.php @@ -0,0 +1,70 @@ +beConstructedWith($productRepository, $taxonRepository); + } + + public function it_is_initializable(): void + { + $this->shouldHaveType(ProductsCarouselByTaxonContentElementRenderer::class); + $this->shouldBeAnInstanceOf(AbstractContentElement::class); + } + + public function it_supports_products_carousel_by_taxon_content_element_type(ContentConfigurationInterface $contentConfiguration): void + { + $contentConfiguration->getType()->willReturn(ProductsCarouselByTaxonContentElementType::TYPE); + $this->supports($contentConfiguration)->shouldReturn(true); + } + + public function it_does_not_support_other_content_element_types(ContentConfigurationInterface $contentConfiguration): void + { + $contentConfiguration->getType()->willReturn('other_type'); + $this->supports($contentConfiguration)->shouldReturn(false); + } + + public function it_renders_products_carousel_by_taxon_content_element( + Environment $twig, + ProductRepositoryInterface $productRepository, + TaxonRepositoryInterface $taxonRepository, + ContentConfigurationInterface $contentConfiguration, + TaxonInterface $taxon, + Product $product1, + Product $product2, + ): void { + $template = 'custom_template'; + $this->setTemplate($template); + $this->setTwigEnvironment($twig); + + $contentConfiguration->getConfiguration()->willReturn([ + 'products_carousel_by_taxon' => 'taxon_code', + ]); + + $taxonRepository->findOneBy(['code' => 'taxon_code'])->willReturn($taxon); + $productRepository->findByTaxon($taxon)->willReturn([$product1, $product2]); + + $twig->render('@SyliusCmsPlugin/Shop/ContentElement/index.html.twig', [ + 'content_element' => $template, + 'products' => [$product1, $product2], + ])->willReturn('rendered template'); + + $this->render($contentConfiguration)->shouldReturn('rendered template'); + } +} diff --git a/spec/Renderer/ContentElement/ProductsCarouselContentElementRendererSpec.php b/spec/Renderer/ContentElement/ProductsCarouselContentElementRendererSpec.php new file mode 100644 index 000000000..91a25d747 --- /dev/null +++ b/spec/Renderer/ContentElement/ProductsCarouselContentElementRendererSpec.php @@ -0,0 +1,65 @@ +beConstructedWith($productRepository); + } + + public function it_is_initializable(): void + { + $this->shouldHaveType(ProductsCarouselContentElementRenderer::class); + $this->shouldBeAnInstanceOf(AbstractContentElement::class); + } + + public function it_supports_products_carousel_content_element_type(ContentConfigurationInterface $contentConfiguration): void + { + $contentConfiguration->getType()->willReturn(ProductsCarouselContentElementType::TYPE); + $this->supports($contentConfiguration)->shouldReturn(true); + } + + public function it_does_not_support_other_content_element_types(ContentConfigurationInterface $contentConfiguration): void + { + $contentConfiguration->getType()->willReturn('other_type'); + $this->supports($contentConfiguration)->shouldReturn(false); + } + + public function it_renders_products_carousel_content_element( + Environment $twig, + ProductRepositoryInterface $productRepository, + ContentConfigurationInterface $contentConfiguration, + Product $product1, + Product $product2, + ): void { + $template = 'custom_template'; + $this->setTemplate($template); + $this->setTwigEnvironment($twig); + + $contentConfiguration->getConfiguration()->willReturn([ + 'products_carousel' => ['products' => ['code1', 'code2']], + ]); + + $productRepository->findBy(['code' => ['code1', 'code2']])->willReturn([$product1, $product2]); + + $twig->render('@SyliusCmsPlugin/Shop/ContentElement/index.html.twig', [ + 'content_element' => $template, + 'products' => [$product1, $product2], + ])->willReturn('rendered template'); + + $this->render($contentConfiguration)->shouldReturn('rendered template'); + } +} diff --git a/spec/Renderer/ContentElement/ProductsGridByTaxonContentElementRendererSpec.php b/spec/Renderer/ContentElement/ProductsGridByTaxonContentElementRendererSpec.php new file mode 100644 index 000000000..000108a5a --- /dev/null +++ b/spec/Renderer/ContentElement/ProductsGridByTaxonContentElementRendererSpec.php @@ -0,0 +1,70 @@ +beConstructedWith($productRepository, $taxonRepository); + } + + public function it_is_initializable(): void + { + $this->shouldHaveType(ProductsGridByTaxonContentElementRenderer::class); + $this->shouldBeAnInstanceOf(AbstractContentElement::class); + } + + public function it_supports_products_grid_by_taxon_content_element_type(ContentConfigurationInterface $contentConfiguration): void + { + $contentConfiguration->getType()->willReturn(ProductsGridByTaxonContentElementType::TYPE); + $this->supports($contentConfiguration)->shouldReturn(true); + } + + public function it_does_not_support_other_content_element_types(ContentConfigurationInterface $contentConfiguration): void + { + $contentConfiguration->getType()->willReturn('other_type'); + $this->supports($contentConfiguration)->shouldReturn(false); + } + + public function it_renders_products_grid_by_taxon_content_element( + Environment $twig, + ProductRepositoryInterface $productRepository, + TaxonRepositoryInterface $taxonRepository, + ContentConfigurationInterface $contentConfiguration, + TaxonInterface $taxon, + Product $product1, + Product $product2, + ): void { + $template = 'custom_template'; + $this->setTemplate($template); + $this->setTwigEnvironment($twig); + + $contentConfiguration->getConfiguration()->willReturn([ + 'products_grid_by_taxon' => 'taxon_code', + ]); + + $taxonRepository->findOneBy(['code' => 'taxon_code'])->willReturn($taxon); + $productRepository->findByTaxon($taxon)->willReturn([$product1, $product2]); + + $twig->render('@SyliusCmsPlugin/Shop/ContentElement/index.html.twig', [ + 'content_element' => $template, + 'products' => [$product1, $product2], + ])->willReturn('rendered template'); + + $this->render($contentConfiguration)->shouldReturn('rendered template'); + } +} diff --git a/spec/Renderer/ContentElement/ProductsGridContentElementRendererSpec.php b/spec/Renderer/ContentElement/ProductsGridContentElementRendererSpec.php new file mode 100644 index 000000000..0c237bd47 --- /dev/null +++ b/spec/Renderer/ContentElement/ProductsGridContentElementRendererSpec.php @@ -0,0 +1,65 @@ +beConstructedWith($productRepository); + } + + public function it_is_initializable(): void + { + $this->shouldHaveType(ProductsGridContentElementRenderer::class); + $this->shouldBeAnInstanceOf(AbstractContentElement::class); + } + + public function it_supports_products_grid_content_element_type(ContentConfigurationInterface $contentConfiguration): void + { + $contentConfiguration->getType()->willReturn(ProductsGridContentElementType::TYPE); + $this->supports($contentConfiguration)->shouldReturn(true); + } + + public function it_does_not_support_other_content_element_types(ContentConfigurationInterface $contentConfiguration): void + { + $contentConfiguration->getType()->willReturn('other_type'); + $this->supports($contentConfiguration)->shouldReturn(false); + } + + public function it_renders_products_grid_content_element( + Environment $twig, + ProductRepositoryInterface $productRepository, + ContentConfigurationInterface $contentConfiguration, + Product $product1, + Product $product2, + ): void { + $template = 'custom_template'; + $this->setTemplate($template); + $this->setTwigEnvironment($twig); + + $contentConfiguration->getConfiguration()->willReturn([ + 'products_grid' => ['products' => ['code1', 'code2']], + ]); + + $productRepository->findBy(['code' => ['code1', 'code2']])->willReturn([$product1, $product2]); + + $twig->render('@SyliusCmsPlugin/Shop/ContentElement/index.html.twig', [ + 'content_element' => $template, + 'products' => [$product1, $product2], + ])->willReturn('rendered template'); + + $this->render($contentConfiguration)->shouldReturn('rendered template'); + } +} diff --git a/spec/Renderer/ContentElement/SingleMediaContentElementRendererSpec.php b/spec/Renderer/ContentElement/SingleMediaContentElementRendererSpec.php new file mode 100644 index 000000000..d9a08cc23 --- /dev/null +++ b/spec/Renderer/ContentElement/SingleMediaContentElementRendererSpec.php @@ -0,0 +1,70 @@ +beConstructedWith($renderMediaRuntime, $mediaRepository); + } + + public function it_is_initializable(): void + { + $this->shouldHaveType(SingleMediaContentElementRenderer::class); + $this->shouldBeAnInstanceOf(AbstractContentElement::class); + } + + public function it_supports_single_media_content_element_type(ContentConfigurationInterface $contentConfiguration): void + { + $contentConfiguration->getType()->willReturn(SingleMediaContentElementType::TYPE); + $this->supports($contentConfiguration)->shouldReturn(true); + } + + public function it_does_not_support_other_content_element_types(ContentConfigurationInterface $contentConfiguration): void + { + $contentConfiguration->getType()->willReturn('other_type'); + $this->supports($contentConfiguration)->shouldReturn(false); + } + + public function it_renders_single_media_content_element( + Environment $twig, + RenderMediaRuntimeInterface $renderMediaRuntime, + MediaRepositoryInterface $mediaRepository, + ContentConfigurationInterface $contentConfiguration, + MediaInterface $media, + ): void { + $template = 'custom_template'; + $this->setTemplate($template); + $this->setTwigEnvironment($twig); + + $contentConfiguration->getConfiguration()->willReturn([ + 'single_media' => 'media_code', + ]); + + $renderMediaRuntime->renderMedia('media_code')->willReturn('rendered media'); + $mediaRepository->findOneBy(['code' => 'media_code'])->willReturn($media); + + $twig->render('@SyliusCmsPlugin/Shop/ContentElement/index.html.twig', [ + 'content_element' => $template, + 'media' => [ + 'renderedContent' => 'rendered media', + 'entity' => $media, + ], + ])->willReturn('rendered template'); + + $this->render($contentConfiguration)->shouldReturn('rendered template'); + } +} diff --git a/spec/Renderer/ContentElement/SpacerContentElementRendererSpec.php b/spec/Renderer/ContentElement/SpacerContentElementRendererSpec.php new file mode 100644 index 000000000..79c8acc47 --- /dev/null +++ b/spec/Renderer/ContentElement/SpacerContentElementRendererSpec.php @@ -0,0 +1,51 @@ +shouldHaveType(SpacerContentElementRenderer::class); + $this->shouldBeAnInstanceOf(AbstractContentElement::class); + } + + public function it_supports_spacer_content_element_type(ContentConfigurationInterface $contentConfiguration): void + { + $contentConfiguration->getType()->willReturn(SpacerContentElementType::TYPE); + $this->supports($contentConfiguration)->shouldReturn(true); + } + + public function it_does_not_support_other_content_element_types(ContentConfigurationInterface $contentConfiguration): void + { + $contentConfiguration->getType()->willReturn('other_type'); + $this->supports($contentConfiguration)->shouldReturn(false); + } + + public function it_renders_spacer_content_element(Environment $twig, ContentConfigurationInterface $contentConfiguration): void + { + $template = 'custom_template'; + $this->setTemplate($template); + $this->setTwigEnvironment($twig); + + $contentConfiguration->getConfiguration()->willReturn([ + 'spacer' => '40', + ]); + + $twig->render('@SyliusCmsPlugin/Shop/ContentElement/index.html.twig', [ + 'content_element' => $template, + 'spacer_height' => '40', + ])->willReturn('rendered template'); + + $this->render($contentConfiguration)->shouldReturn('rendered template'); + } +} diff --git a/spec/Renderer/ContentElement/TaxonsListContentElementRendererSpec.php b/spec/Renderer/ContentElement/TaxonsListContentElementRendererSpec.php new file mode 100644 index 000000000..96fd44ea9 --- /dev/null +++ b/spec/Renderer/ContentElement/TaxonsListContentElementRendererSpec.php @@ -0,0 +1,65 @@ +beConstructedWith($taxonRepository); + } + + public function it_is_initializable(): void + { + $this->shouldHaveType(TaxonsListContentElementRenderer::class); + $this->shouldBeAnInstanceOf(AbstractContentElement::class); + } + + public function it_supports_taxons_list_content_element_type(ContentConfigurationInterface $contentConfiguration): void + { + $contentConfiguration->getType()->willReturn(TaxonsListContentElementType::TYPE); + $this->supports($contentConfiguration)->shouldReturn(true); + } + + public function it_does_not_support_other_content_element_types(ContentConfigurationInterface $contentConfiguration): void + { + $contentConfiguration->getType()->willReturn('other_type'); + $this->supports($contentConfiguration)->shouldReturn(false); + } + + public function it_renders_taxons_list_content_element( + Environment $twig, + TaxonRepositoryInterface $taxonRepository, + ContentConfigurationInterface $contentConfiguration, + Taxon $taxon1, + Taxon $taxon2, + ): void { + $template = 'custom_template'; + $this->setTemplate($template); + $this->setTwigEnvironment($twig); + + $contentConfiguration->getConfiguration()->willReturn([ + 'taxons_list' => ['taxons' => ['code1', 'code2']], + ]); + + $taxonRepository->findBy(['code' => ['code1', 'code2']])->willReturn([$taxon1, $taxon2]); + + $twig->render('@SyliusCmsPlugin/Shop/ContentElement/index.html.twig', [ + 'content_element' => $template, + 'taxons' => [$taxon1, $taxon2], + ])->willReturn('rendered template'); + + $this->render($contentConfiguration)->shouldReturn('rendered template'); + } +} diff --git a/spec/Renderer/ContentElement/TextareaContentElementRendererSpec.php b/spec/Renderer/ContentElement/TextareaContentElementRendererSpec.php new file mode 100644 index 000000000..208ae2807 --- /dev/null +++ b/spec/Renderer/ContentElement/TextareaContentElementRendererSpec.php @@ -0,0 +1,53 @@ +shouldHaveType(TextareaContentElementRenderer::class); + $this->shouldBeAnInstanceOf(AbstractContentElement::class); + } + + public function it_supports_textarea_content_element_type(ContentConfigurationInterface $contentConfiguration): void + { + $contentConfiguration->getType()->willReturn(TextareaContentElementType::TYPE); + $this->supports($contentConfiguration)->shouldReturn(true); + } + + public function it_does_not_support_other_content_element_types(ContentConfigurationInterface $contentConfiguration): void + { + $contentConfiguration->getType()->willReturn('other_type'); + $this->supports($contentConfiguration)->shouldReturn(false); + } + + public function it_renders_textarea_content_element( + Environment $twig, + ContentConfigurationInterface $contentConfiguration, + ): void { + $template = 'custom_template'; + $this->setTemplate($template); + $this->setTwigEnvironment($twig); + + $contentConfiguration->getConfiguration()->willReturn([ + 'textarea' => 'Textarea content', + ]); + + $twig->render('@SyliusCmsPlugin/Shop/ContentElement/index.html.twig', [ + 'content_element' => $template, + 'content' => 'Textarea content', + ])->willReturn('rendered template'); + + $this->render($contentConfiguration)->shouldReturn('rendered template'); + } +} diff --git a/spec/Renderer/ContentElementRendererStrategySpec.php b/spec/Renderer/ContentElementRendererStrategySpec.php new file mode 100644 index 000000000..961471325 --- /dev/null +++ b/spec/Renderer/ContentElementRendererStrategySpec.php @@ -0,0 +1,87 @@ +beConstructedWith($contentParser, $localeContext, [$renderer]); + } + + public function it_implements_content_element_renderer_strategy_interface(): void + { + $this->shouldImplement(ContentElementRendererStrategyInterface::class); + } + + public function it_renders_a_page_content_element_correctly( + PageInterface $page, + ContentConfigurationInterface $contentElement, + LocaleContextInterface $localeContext, + ContentElementRendererInterface $renderer, + ContentParserInterface $contentParser, + ): void { + $page->getContentElements()->willReturn(new ArrayCollection([$contentElement->getWrappedObject()])); + $localeContext->getLocaleCode()->willReturn('en_US'); + $contentElement->getLocale()->willReturn('en_US'); + + $renderer->supports($contentElement)->willReturn(true); + $renderer->render($contentElement)->willReturn('<p>Hello World</p>'); + + $contentParser->parse('

Hello World

')->willReturn('

Hello World

'); + + $this->render($page)->shouldReturn('

Hello World

'); + } + + public function it_skips_content_element_with_non_matching_locale( + BlockInterface $block, + ContentConfigurationInterface $contentElement, + LocaleContextInterface $localeContext, + ContentParserInterface $contentParser, + ): void { + $block->getContentElements()->willReturn(new ArrayCollection([$contentElement])); + $localeContext->getLocaleCode()->willReturn('en_US'); + $contentElement->getLocale()->willReturn('fr_FR'); + + $contentParser->parse('')->willReturn(''); + + $this->render($block)->shouldReturn(''); + } + + public function it_renders_only_supported_content_elements( + BlockInterface $block, + ContentConfigurationInterface $supportedElement, + ContentConfigurationInterface $unsupportedElement, + LocaleContextInterface $localeContext, + ContentElementRendererInterface $renderer, + ContentParserInterface $contentParser, + ): void { + $block->getContentElements()->willReturn(new ArrayCollection([$supportedElement->getWrappedObject(), $unsupportedElement->getWrappedObject()])); + $localeContext->getLocaleCode()->willReturn('en_US'); + $supportedElement->getLocale()->willReturn('en_US'); + $unsupportedElement->getLocale()->willReturn('en_US'); + + $renderer->supports($supportedElement)->willReturn(true); + $renderer->render($supportedElement)->willReturn('<p>Supported</p>'); + $renderer->supports($unsupportedElement)->willReturn(false); + + $contentParser->parse('

Supported

')->willReturn('

Supported

'); + + $this->render($block)->shouldReturn('

Supported

'); + } +} diff --git a/spec/Renderer/PageLinkRendererSpec.php b/spec/Renderer/PageLinkRendererSpec.php new file mode 100644 index 000000000..f7d3debf6 --- /dev/null +++ b/spec/Renderer/PageLinkRendererSpec.php @@ -0,0 +1,82 @@ +beConstructedWith($urlGenerator, $twig); + } + + public function it_is_initializable(): void + { + $this->shouldHaveType(PageLinkRenderer::class); + } + + public function it_implements_page_link_renderer_interface(): void + { + $this->shouldImplement(PageLinkRendererInterface::class); + } + + public function it_renders_page_link_with_default_template( + UrlGeneratorInterface $urlGenerator, + Environment $twig, + PageInterface $page, + ): void { + $page->getSlug()->willReturn('page-slug'); + $page->getName()->willReturn('Page Name'); + + $urlGenerator->generate( + 'sylius_cms_shop_page_show', + ['slug' => 'page-slug'], + UrlGeneratorInterface::ABSOLUTE_URL, + )->willReturn('http://example.com/page-slug'); + + $twig->render( + '@SyliusCmsPlugin/Shop/Page/link.html.twig', + [ + 'link' => 'http://example.com/page-slug', + 'name' => 'Page Name', + ], + )->willReturn('Page Name'); + + $this->render($page)->shouldReturn('Page Name'); + } + + public function it_renders_page_link_with_custom_template( + UrlGeneratorInterface $urlGenerator, + Environment $twig, + PageInterface $page, + ): void { + $page->getSlug()->willReturn('page-slug'); + $page->getName()->willReturn('Page Name'); + + $urlGenerator->generate( + 'sylius_cms_shop_page_show', + ['slug' => 'page-slug'], + UrlGeneratorInterface::ABSOLUTE_URL, + )->willReturn('http://example.com/page-slug'); + + $twig->render( + 'custom_template.html.twig', + [ + 'link' => 'http://example.com/page-slug', + 'name' => 'Page Name', + ], + )->willReturn('Page Name'); + + $this->render($page, 'custom_template.html.twig')->shouldReturn('Page Name'); + } +} diff --git a/spec/Resolver/BlockResourceResolverSpec.php b/spec/Resolver/BlockResourceResolverSpec.php index 1f9af7155..b87eb2060 100755 --- a/spec/Resolver/BlockResourceResolverSpec.php +++ b/spec/Resolver/BlockResourceResolverSpec.php @@ -1,32 +1,30 @@ beConstructedWith($blockRepository, $logger, $channelContext); + $this->beConstructedWith($blockRepository, $logger, $channelContext, $localeContext, $localeRepository); } public function it_is_initializable(): void @@ -39,32 +37,11 @@ public function it_implements_block_resource_resolver_interface(): void $this->shouldHaveType(BlockResourceResolverInterface::class); } - public function it_logs_warning_if_block_was_not_found( - BlockRepositoryInterface $blockRepository, - LoggerInterface $logger, - ChannelContextInterface $channelContext, - ChannelInterface $channel - ) { - $channel->getCode()->willReturn('WEB'); - $channelContext->getChannel()->willReturn($channel); - $blockRepository->findEnabledByCode('homepage_banner', 'WEB')->willReturn(null); - - $logger - ->warning(sprintf( - 'Block with "%s" code was not found in the database.', - 'homepage_banner' - )) - ->shouldBeCalled() - ; - - $this->findOrLog('homepage_banner'); - } - public function it_returns_block_if_found_in_database( BlockRepositoryInterface $blockRepository, BlockInterface $block, ChannelContextInterface $channelContext, - ChannelInterface $channel + ChannelInterface $channel, ) { $channel->getCode()->willReturn('WEB'); $channelContext->getChannel()->willReturn($channel); diff --git a/spec/Resolver/ImporterChannelsResolverSpec.php b/spec/Resolver/Importer/ImporterChannelsResolverSpec.php similarity index 67% rename from spec/Resolver/ImporterChannelsResolverSpec.php rename to spec/Resolver/Importer/ImporterChannelsResolverSpec.php index c4ac903af..38cd5d130 100644 --- a/spec/Resolver/ImporterChannelsResolverSpec.php +++ b/spec/Resolver/Importer/ImporterChannelsResolverSpec.php @@ -1,19 +1,13 @@ beConstructedWith($collectionsAssigner); + } + + public function it_is_initializable() + { + $this->shouldHaveType(ImporterCollectionsResolver::class); + } + + public function it_resolves_collections_for_collectionable_entity( + CollectionsAssignerInterface $collectionsAssigner, + CollectibleInterface $collectionable, + ) { + $collectionsRow = 'collection1, collection2, collection3'; + $collectionsCodes = ['collection1', 'collection2', 'collection3']; + + $collectionsAssigner->assign($collectionable, $collectionsCodes)->shouldBeCalled(); + + $this->resolve($collectionable, $collectionsRow); + } + + public function it_skips_resolution_when_collections_row_is_null( + CollectionsAssignerInterface $collectionsAssigner, + CollectibleInterface $collectionable, + ) { + $collectionsRow = null; + + $collectionsAssigner->assign($collectionable, Argument::any())->shouldNotBeCalled(); + + $this->resolve($collectionable, $collectionsRow); + } +} diff --git a/spec/Resolver/Importer/ImporterLocalesResolverSpec.php b/spec/Resolver/Importer/ImporterLocalesResolverSpec.php new file mode 100644 index 000000000..83d2ca4c7 --- /dev/null +++ b/spec/Resolver/Importer/ImporterLocalesResolverSpec.php @@ -0,0 +1,42 @@ +beConstructedWith($localesAssigner); + } + + public function it_is_initializable() + { + $this->shouldHaveType(ImporterLocalesResolver::class); + } + + public function it_resolves_locales_for_locale_aware_entity( + LocalesAssignerInterface $localesAssigner, + LocaleAwareInterface $localesAware, + ) { + $localesRow = 'en_US, fr_FR'; + $localesAssigner->assign($localesAware, ['en_US', 'fr_FR'])->shouldBeCalled(); + + $this->resolve($localesAware, $localesRow); + } + + public function it_does_not_assign_locales_when_locales_row_is_empty( + LocalesAssignerInterface $localesAssigner, + LocaleAwareInterface $localesAware, + ) { + $localesAssigner->assign($localesAware, [])->shouldNotBeCalled(); + + $this->resolve($localesAware, ''); + } +} diff --git a/spec/Resolver/Importer/ImporterProductsInTaxonsResolverSpec.php b/spec/Resolver/Importer/ImporterProductsInTaxonsResolverSpec.php new file mode 100644 index 000000000..77fd7b8d5 --- /dev/null +++ b/spec/Resolver/Importer/ImporterProductsInTaxonsResolverSpec.php @@ -0,0 +1,42 @@ +beConstructedWith($productsInTaxonsAssigner); + } + + public function it_is_initializable() + { + $this->shouldHaveType(ImporterProductsInTaxonsResolver::class); + } + + public function it_resolves_taxons_for_products_in_taxons_aware_entity( + ProductsInTaxonsAssignerInterface $productsInTaxonsAssigner, + ProductsInTaxonsAwareInterface $productsInTaxonsAware, + ) { + $taxonsRow = 'taxon_code_1, taxon_code_2'; + $productsInTaxonsAssigner->assign($productsInTaxonsAware, ['taxon_code_1', 'taxon_code_2'])->shouldBeCalled(); + + $this->resolve($productsInTaxonsAware, $taxonsRow); + } + + public function it_does_not_assign_taxons_when_taxons_row_is_null( + ProductsInTaxonsAssignerInterface $productsInTaxonsAssigner, + ProductsInTaxonsAwareInterface $productsInTaxonsAware, + ) { + $productsInTaxonsAssigner->assign($productsInTaxonsAware, [])->shouldNotBeCalled(); + + $this->resolve($productsInTaxonsAware, null); + } +} diff --git a/spec/Resolver/ImporterProductsResolverSpec.php b/spec/Resolver/Importer/ImporterProductsResolverSpec.php similarity index 63% rename from spec/Resolver/ImporterProductsResolverSpec.php rename to spec/Resolver/Importer/ImporterProductsResolverSpec.php index 3b3bd5b96..5649e82f2 100644 --- a/spec/Resolver/ImporterProductsResolverSpec.php +++ b/spec/Resolver/Importer/ImporterProductsResolverSpec.php @@ -1,20 +1,14 @@ beConstructedWith($taxonsAssigner); + } + + public function it_is_initializable() + { + $this->shouldHaveType(ImporterTaxonsResolver::class); + } + + public function it_resolves_taxons_for_taxon_aware_entity( + TaxonsAssignerInterface $taxonsAssigner, + TaxonAwareInterface $taxonsAware, + ) { + $taxonsRow = 'taxon_code_1, taxon_code_2'; + $taxonsAssigner->assign($taxonsAware, ['taxon_code_1', 'taxon_code_2'])->shouldBeCalled(); + + $this->resolve($taxonsAware, $taxonsRow); + } + + public function it_does_not_assign_taxons_when_taxons_row_is_null( + TaxonsAssignerInterface $taxonsAssigner, + TaxonAwareInterface $taxonsAware, + ) { + $taxonsAssigner->assign($taxonsAware, [])->shouldNotBeCalled(); + + $this->resolve($taxonsAware, null); + } +} diff --git a/spec/Resolver/ImporterSectionsResolverSpec.php b/spec/Resolver/ImporterSectionsResolverSpec.php deleted file mode 100644 index 83cc8dd11..000000000 --- a/spec/Resolver/ImporterSectionsResolverSpec.php +++ /dev/null @@ -1,53 +0,0 @@ -beConstructedWith($sectionsAssigner); - } - - public function it_is_initializable() - { - $this->shouldHaveType(ImporterSectionsResolver::class); - } - - public function it_resolves_sections_for_sectionable_entity( - SectionsAssignerInterface $sectionsAssigner, - SectionableInterface $sectionable - ) { - $sectionsRow = 'section1, section2, section3'; - $sectionCodes = ['section1', 'section2', 'section3']; - - $sectionsAssigner->assign($sectionable, $sectionCodes)->shouldBeCalled(); - - $this->resolve($sectionable, $sectionsRow); - } - - public function it_skips_resolution_when_sections_row_is_null( - SectionsAssignerInterface $sectionsAssigner, - SectionableInterface $sectionable - ) { - $sectionsRow = null; - - $sectionsAssigner->assign($sectionable, Argument::any())->shouldNotBeCalled(); - - $this->resolve($sectionable, $sectionsRow); - } -} diff --git a/spec/Resolver/MediaProviderResolverSpec.php b/spec/Resolver/MediaProviderResolverSpec.php index 5010793c9..d57e7b57e 100644 --- a/spec/Resolver/MediaProviderResolverSpec.php +++ b/spec/Resolver/MediaProviderResolverSpec.php @@ -1,20 +1,14 @@ getType()->willReturn($mediaType); @@ -45,7 +39,7 @@ public function it_resolves_provider_for_media( } public function it_throws_exception_when_media_type_is_null( - MediaInterface $media + MediaInterface $media, ) { $media->getType()->willReturn(null); diff --git a/spec/Resolver/MediaResourceResolverSpec.php b/spec/Resolver/MediaResourceResolverSpec.php index a3fb1a139..fc744b63b 100644 --- a/spec/Resolver/MediaResourceResolverSpec.php +++ b/spec/Resolver/MediaResourceResolverSpec.php @@ -1,34 +1,26 @@ beConstructedWith($mediaRepository, $localeContext, $channelContext, $logger); + ) { + $this->beConstructedWith($mediaRepository, $channelContext, $logger); } public function it_is_initializable(): void @@ -43,40 +35,34 @@ public function it_implements_media_resource_resolver_interface(): void public function it_returns_media_when_found( MediaRepositoryInterface $mediaRepository, - LocaleContextInterface $localeContext, ChannelContextInterface $channelContext, MediaInterface $media, ChannelInterface $channel, - ) { + ) { $code = 'media_code'; - $localeCode = 'en_US'; $channelCode = 'ecommerce'; $channelContext->getChannel()->willReturn($channel); $channel->getCode()->willReturn($channelCode); - $localeContext->getLocaleCode()->willReturn($localeCode); - $mediaRepository->findOneEnabledByCode($code, $localeCode, $channelCode)->willReturn($media); + $mediaRepository->findOneEnabledByCode($code, $channelCode)->willReturn($media); $this->findOrLog($code)->shouldReturn($media); } public function it_logs_warning_and_returns_null_when_media_not_found( MediaRepositoryInterface $mediaRepository, - LocaleContextInterface $localeContext, ChannelContextInterface $channelContext, LoggerInterface $logger, ChannelInterface $channel, - ) { + ) { $code = 'non_existing_code'; - $localeCode = 'en_US'; $channelCode = 'ecommerce'; $channelContext->getChannel()->willReturn($channel); $channel->getCode()->willReturn($channelCode); - $localeContext->getLocaleCode()->willReturn($localeCode); - $mediaRepository->findOneEnabledByCode($code, $localeCode, $channelCode)->willReturn(null); + $mediaRepository->findOneEnabledByCode($code, $channelCode)->willReturn(null); $logger->warning(sprintf('Media with "%s" code was not found in the database.', $code))->shouldBeCalled(); diff --git a/spec/Resolver/PageResourceResolverSpec.php b/spec/Resolver/PageResourceResolverSpec.php index 903e409ef..61f7920c0 100755 --- a/spec/Resolver/PageResourceResolverSpec.php +++ b/spec/Resolver/PageResourceResolverSpec.php @@ -1,31 +1,23 @@ beConstructedWith($pageRepository, $localeContext, $logger); + $this->beConstructedWith($pageRepository, $logger); } public function it_is_initializable(): void @@ -40,16 +32,14 @@ public function it_implements_page_resource_resolver_interface(): void public function it_logs_warning_if_page_was_not_found( PageRepositoryInterface $pageRepository, - LocaleContextInterface $localeContext, - LoggerInterface $logger + LoggerInterface $logger, ) { - $localeContext->getLocaleCode()->willReturn('en_US'); - $pageRepository->findOneEnabledByCode('homepage_banner', 'en_US')->willReturn(null); + $pageRepository->findOneEnabledByCode('homepage_banner')->willReturn(null); $logger ->warning(sprintf( 'Page with "%s" code was not found in the database.', - 'homepage_banner' + 'homepage_banner', )) ->shouldBeCalled() ; @@ -59,11 +49,9 @@ public function it_logs_warning_if_page_was_not_found( public function it_returns_page_if_found_in_database( PageRepositoryInterface $pageRepository, - LocaleContextInterface $localeContext, - PageInterface $page + PageInterface $page, ) { - $localeContext->getLocaleCode()->willReturn('en_US'); - $pageRepository->findOneEnabledByCode('homepage_banner', 'en_US')->willReturn($page); + $pageRepository->findOneEnabledByCode('homepage_banner')->willReturn($page); $this->findOrLog('homepage_banner')->shouldReturn($page); } diff --git a/spec/Resolver/ResourceResolverSpec.php b/spec/Resolver/ResourceResolverSpec.php index 74817d9bf..9ce6bea2b 100644 --- a/spec/Resolver/ResourceResolverSpec.php +++ b/spec/Resolver/ResourceResolverSpec.php @@ -1,17 +1,11 @@ beConstructedWith($repository, $factory, 'unique_column'); } @@ -32,7 +26,7 @@ public function it_is_initializable() public function it_returns_existing_resource_from_repository( RepositoryInterface $repository, - ResourceInterface $resource + ResourceInterface $resource, ) { $identifier = 'resource_identifier'; @@ -44,7 +38,7 @@ public function it_returns_existing_resource_from_repository( public function it_creates_new_resource_using_factory( RepositoryInterface $repository, FactoryInterface $factory, - ResourceInterface $newResource + ResourceInterface $newResource, ) { $identifier = 'resource_identifier'; $factoryMethod = 'createNew'; @@ -57,7 +51,7 @@ public function it_creates_new_resource_using_factory( public function it_throws_exception_when_factory_method_not_callable( RepositoryInterface $repository, - FactoryInterface $factory + FactoryInterface $factory, ) { $identifier = 'resource_identifier'; $factoryMethod = 'nonExistingMethod'; diff --git a/spec/Sorter/CollectionsSorterSpec.php b/spec/Sorter/CollectionsSorterSpec.php new file mode 100644 index 000000000..6a296c90a --- /dev/null +++ b/spec/Sorter/CollectionsSorterSpec.php @@ -0,0 +1,88 @@ +shouldHaveType(CollectionsSorter::class); + } + + public function it_implements_collections_sorter_interface(): void + { + $this->shouldHaveType(CollectionsSorterInterface::class); + } + + public function it_sorts_collections_with_one_element( + PageInterface $page, + CollectionInterface $collection, + ): void { + $collection->getCode()->willReturn('COLLECTION_CODE'); + $page->getCollections()->willReturn(new ArrayCollection([$collection->getWrappedObject()])); + + $this->sortByCollections([$page])->shouldReturn( + [ + 'COLLECTION_CODE' => ['collection' => $collection, 0 => $page], + ], + ); + } + + public function it_sorts_collections_with_more_elements( + PageInterface $page1, + PageInterface $page2, + PageInterface $page3, + CollectionInterface $collection1, + CollectionInterface $collection2, + CollectionInterface $collection3, + ): void { + $collection1->getCode()->willReturn('COLLECTION_1_CODE'); + $collection2->getCode()->willReturn('COLLECTION_2_CODE'); + $collection3->getCode()->willReturn('COLLECTION_3_CODE'); + + $page1->getCollections()->willReturn(new ArrayCollection( + [$collection1->getWrappedObject(), $collection3->getWrappedObject()], + )); + $page2->getCollections()->willReturn(new ArrayCollection([$collection3->getWrappedObject()])); + $page3->getCollections()->willReturn(new ArrayCollection( + [$collection2->getWrappedObject(), $collection1->getWrappedObject()], + )); + + $this->sortByCollections([$page1, $page2, $page3])->shouldReturn( + [ + 'COLLECTION_1_CODE' => ['collection' => $collection1, 0 => $page1, 1 => $page3], + 'COLLECTION_3_CODE' => ['collection' => $collection3, 0 => $page1, 1 => $page2], + 'COLLECTION_2_CODE' => ['collection' => $collection2, 0 => $page3], + ], + ); + } + + public function it_sorts_collections_with_less_elements( + PageInterface $page1, + PageInterface $page2, + CollectionInterface $collection1, + CollectionInterface $collection2, + ): void { + $collection1->getCode()->willReturn('COLLECTION_1_CODE'); + $collection2->getCode()->willReturn('COLLECTION_2_CODE'); + + $page1->getCollections()->willReturn(new ArrayCollection([$collection1->getWrappedObject()])); + $page2->getCollections()->willReturn(new ArrayCollection([$collection2->getWrappedObject()])); + + $this->sortByCollections([$page1, $page2])->shouldReturn( + [ + 'COLLECTION_1_CODE' => ['collection' => $collection1, 0 => $page1], + 'COLLECTION_2_CODE' => ['collection' => $collection2, 0 => $page2], + ], + ); + } +} diff --git a/spec/Sorter/SectionsSorterSpec.php b/spec/Sorter/SectionsSorterSpec.php deleted file mode 100644 index 3b20091dd..000000000 --- a/spec/Sorter/SectionsSorterSpec.php +++ /dev/null @@ -1,96 +0,0 @@ -shouldHaveType(SectionsSorter::class); - } - - public function it_implements_sections_sorter_interface(): void - { - $this->shouldHaveType(SectionsSorterInterface::class); - } - - public function it_sorts_sections_with_one_element( - PageInterface $page, - SectionInterface $section - ): void { - $section->getCode()->willReturn('SECTION_CODE'); - $page->getSections()->willReturn(new ArrayCollection([$section->getWrappedObject()])); - - $this->sortBySections([$page])->shouldReturn( - [ - 'SECTION_CODE' => ['section' => $section, 0 => $page], - ] - ); - } - - public function it_sorts_sections_with_more_elements( - PageInterface $page1, - PageInterface $page2, - PageInterface $page3, - SectionInterface $section1, - SectionInterface $section2, - SectionInterface $section3 - ): void { - $section1->getCode()->willReturn('SECTION_1_CODE'); - $section2->getCode()->willReturn('SECTION_2_CODE'); - $section3->getCode()->willReturn('SECTION_3_CODE'); - - $page1->getSections()->willReturn(new ArrayCollection( - [$section1->getWrappedObject(), $section3->getWrappedObject()] - )); - $page2->getSections()->willReturn(new ArrayCollection([$section3->getWrappedObject()])); - $page3->getSections()->willReturn(new ArrayCollection( - [$section2->getWrappedObject(), $section1->getWrappedObject()] - )); - - $this->sortBySections([$page1, $page2, $page3])->shouldReturn( - [ - 'SECTION_1_CODE' => ['section' => $section1, 0 => $page1, 1 => $page3], - 'SECTION_3_CODE' => ['section' => $section3, 0 => $page1, 1 => $page2], - 'SECTION_2_CODE' => ['section' => $section2, 0 => $page3], - ] - ); - } - - public function it_sorts_sections_with_less_elements( - PageInterface $page1, - PageInterface $page2, - SectionInterface $section1, - SectionInterface $section2 - ): void { - $section1->getCode()->willReturn('SECTION_1_CODE'); - $section2->getCode()->willReturn('SECTION_2_CODE'); - - $page1->getSections()->willReturn(new ArrayCollection([$section1->getWrappedObject()])); - $page2->getSections()->willReturn(new ArrayCollection([$section2->getWrappedObject()])); - - $this->sortBySections([$page1, $page2])->shouldReturn( - [ - 'SECTION_1_CODE' => ['section' => $section1, 0 => $page1], - 'SECTION_2_CODE' => ['section' => $section2, 0 => $page2], - ] - ); - } -} diff --git a/spec/Twig/Extension/RenderBlockExtensionSpec.php b/spec/Twig/Extension/RenderBlockExtensionSpec.php deleted file mode 100755 index a2d6c2985..000000000 --- a/spec/Twig/Extension/RenderBlockExtensionSpec.php +++ /dev/null @@ -1,47 +0,0 @@ -beConstructedWith($blockRuntime); - } - - public function it_is_initializable(): void - { - $this->shouldHaveType(RenderBlockExtension::class); - } - - public function it_extends_abstract_extension(): void - { - $this->shouldHaveType(AbstractExtension::class); - } - - public function it_returns_functions(): void - { - $functions = $this->getFunctions(); - - $functions->shouldHaveCount(1); - - foreach ($functions as $function) { - $function->shouldHaveType(TwigFunction::class); - } - } -} diff --git a/spec/Twig/Extension/RenderContentExtensionSpec.php b/spec/Twig/Extension/RenderContentExtensionSpec.php deleted file mode 100644 index 52e8c7f2c..000000000 --- a/spec/Twig/Extension/RenderContentExtensionSpec.php +++ /dev/null @@ -1,40 +0,0 @@ -shouldHaveType(RenderContentExtension::class); - } - - public function it_extends_abstract_extension(): void - { - $this->shouldHaveType(AbstractExtension::class); - } - - public function it_returns_functions(): void - { - $functions = $this->getFunctions(); - - $functions->shouldHaveCount(1); - - foreach ($functions as $function) { - $function->shouldHaveType(TwigFunction::class); - } - } -} diff --git a/spec/Twig/Extension/RenderLinkExtensionSpec.php b/spec/Twig/Extension/RenderLinkExtensionSpec.php deleted file mode 100644 index cf29332b4..000000000 --- a/spec/Twig/Extension/RenderLinkExtensionSpec.php +++ /dev/null @@ -1,42 +0,0 @@ -shouldHaveType(RenderLinkExtension::class); - } - - public function it_extends_abstract_extension(): void - { - $this->shouldHaveType(AbstractExtension::class); - } - - public function it_returns_functions(): void - { - $functions = $this->getFunctions(); - - $functions->shouldHaveCount(2); - - foreach ($functions as $function) { - $function->shouldHaveType(TwigFunction::class); - } - } -} diff --git a/spec/Twig/Extension/RenderMediaExtensionSpec.php b/spec/Twig/Extension/RenderMediaExtensionSpec.php deleted file mode 100755 index 7fd5959cd..000000000 --- a/spec/Twig/Extension/RenderMediaExtensionSpec.php +++ /dev/null @@ -1,47 +0,0 @@ -beConstructedWith($mediaRuntime); - } - - public function it_is_initializable(): void - { - $this->shouldHaveType(RenderMediaExtension::class); - } - - public function it_extends_abstract_extension(): void - { - $this->shouldHaveType(AbstractExtension::class); - } - - public function it_returns_functions(): void - { - $functions = $this->getFunctions(); - - $functions->shouldHaveCount(1); - - foreach ($functions as $function) { - $function->shouldHaveType(TwigFunction::class); - } - } -} diff --git a/spec/Twig/Extension/RenderProductPagesExtensionSpec.php b/spec/Twig/Extension/RenderProductPagesExtensionSpec.php deleted file mode 100755 index 04c66790b..000000000 --- a/spec/Twig/Extension/RenderProductPagesExtensionSpec.php +++ /dev/null @@ -1,46 +0,0 @@ -beConstructedWith($productPagesRuntime); - } - - public function it_is_initializable(): void - { - $this->shouldHaveType(RenderProductPagesExtension::class); - } - - public function it_extends_abstract_extension(): void - { - $this->shouldHaveType(AbstractExtension::class); - } - - public function it_returns_functions(): void - { - $functions = $this->getFunctions(); - - $functions->shouldHaveCount(1); - - foreach ($functions as $function) { - $function->shouldHaveType(\Twig_SimpleFunction::class); - } - } -} diff --git a/spec/Twig/Parser/ContentParserSpec.php b/spec/Twig/Parser/ContentParserSpec.php index 96e4fcdd9..665680212 100644 --- a/spec/Twig/Parser/ContentParserSpec.php +++ b/spec/Twig/Parser/ContentParserSpec.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace spec\BitBag\SyliusCmsPlugin\Twig\Parser; +namespace spec\Sylius\CmsPlugin\Twig\Parser; -use BitBag\SyliusCmsPlugin\Twig\Parser\ContentParser; -use BitBag\SyliusCmsPlugin\Twig\Parser\ContentParserInterface; -use BitBag\SyliusCmsPlugin\Twig\Runtime\RenderBlockRuntimeInterface; use PhpSpec\ObjectBehavior; +use Sylius\CmsPlugin\Twig\Parser\ContentParser; +use Sylius\CmsPlugin\Twig\Parser\ContentParserInterface; +use Sylius\CmsPlugin\Twig\Runtime\RenderBlockRuntimeInterface; use Twig\Environment; use Twig\TwigFunction; @@ -15,7 +15,7 @@ final class ContentParserSpec extends ObjectBehavior { public function let(Environment $twigEnvironment): void { - $this->beConstructedWith($twigEnvironment, ['bitbag_cms_render_block']); + $this->beConstructedWith($twigEnvironment, ['sylius_cms_render_block']); } public function it_is_initializable(): void @@ -30,35 +30,34 @@ public function it_implements_content_parser_interface(): void public function it_parses_string_function( Environment $twigEnvironment, - RenderBlockRuntimeInterface $renderBlockRuntime + RenderBlockRuntimeInterface $renderBlockRuntime, ): void { - $twigFunctionName = 'bitbag_cms_render_block'; + $twigFunctionName = 'sylius_cms_render_block'; $twigEnvironment->getFunctions()->willReturn([ - $twigFunctionName => new TwigFunction($twigFunctionName, [$renderBlockRuntime->getWrappedObject(), 'renderBlock']) + $twigFunctionName => new TwigFunction($twigFunctionName, [$renderBlockRuntime->getWrappedObject(), 'renderBlock']), ]); - $input = "Let's render! {{ bitbag_cms_render_block('intro', '@BitBagSyliusCmsPlugin/Shop/Block/show.html.twig') }}"; + $input = "Let's render! {{ sylius_cms_render_block('intro', '@SyliusCmsPlugin/Shop/Block/show.html.twig') }}"; - $renderBlockRuntime->renderBlock('intro', '@BitBagSyliusCmsPlugin/Shop/Block/show.html.twig')->shouldBeCalled(); + $renderBlockRuntime->renderBlock('intro', '@SyliusCmsPlugin/Shop/Block/show.html.twig')->shouldBeCalled(); $this->parse($input); } public function it_parses_string_functions( Environment $twigEnvironment, - RenderBlockRuntimeInterface $renderBlockRuntime + RenderBlockRuntimeInterface $renderBlockRuntime, ): void { - - $twigFunctionName = 'bitbag_cms_render_block'; + $twigFunctionName = 'sylius_cms_render_block'; $twigEnvironment->getFunctions()->willReturn([ - $twigFunctionName => new TwigFunction($twigFunctionName, [$renderBlockRuntime->getWrappedObject(), 'renderBlock']) + $twigFunctionName => new TwigFunction($twigFunctionName, [$renderBlockRuntime->getWrappedObject(), 'renderBlock']), ]); - $input = "Let's render! {{ bitbag_cms_render_block('intro', '@BitBagSyliusCmsPlugin/Shop/Block/show.html.twig') }} - Let's render twice! {{ bitbag_cms_render_block('intro1', '@BitBagSyliusCmsPlugin/Shop/Block/show.html.twig') }}"; + $input = "Let's render! {{ sylius_cms_render_block('intro', '@SyliusCmsPlugin/Shop/Block/show.html.twig') }} + Let's render twice! {{ sylius_cms_render_block('intro1', '@SyliusCmsPlugin/Shop/Block/show.html.twig') }}"; - $renderBlockRuntime->renderBlock('intro', '@BitBagSyliusCmsPlugin/Shop/Block/show.html.twig')->shouldBeCalled(); - $renderBlockRuntime->renderBlock('intro1', '@BitBagSyliusCmsPlugin/Shop/Block/show.html.twig')->shouldBeCalled(); + $renderBlockRuntime->renderBlock('intro', '@SyliusCmsPlugin/Shop/Block/show.html.twig')->shouldBeCalled(); + $renderBlockRuntime->renderBlock('intro1', '@SyliusCmsPlugin/Shop/Block/show.html.twig')->shouldBeCalled(); $this->parse($input); } diff --git a/spec/Twig/Runtime/RenderBlockRuntimeSpec.php b/spec/Twig/Runtime/RenderBlockRuntimeSpec.php index fca4ad8a5..f59b06686 100644 --- a/spec/Twig/Runtime/RenderBlockRuntimeSpec.php +++ b/spec/Twig/Runtime/RenderBlockRuntimeSpec.php @@ -1,31 +1,27 @@ beConstructedWith($blockResourceResolver, $templatingEngine); + $this->beConstructedWith($blockResourceResolver, $templatingEngine, $contentElementRendererStrategy); } public function it_is_initializable(): void @@ -35,28 +31,70 @@ public function it_is_initializable(): void public function it_implements_render_block_runtime_interface(): void { - $this->shouldHaveType(RenderBlockRuntimeInterface::class); + $this->shouldImplement(RenderBlockRuntimeInterface::class); + } + + public function it_returns_empty_string_when_block_not_found(BlockResourceResolverInterface $blockResourceResolver): void + { + $blockResourceResolver->findOrLog('code')->willReturn(null); + + $this->renderBlock('code')->shouldReturn(''); } - public function it_renders_block( + public function it_returns_empty_string_when_block_not_displayable_for_taxon( BlockResourceResolverInterface $blockResourceResolver, BlockInterface $block, - Environment $templatingEngine + TaxonInterface $taxon, ): void { - $blockResourceResolver->findOrLog('bitbag')->willReturn($block); - $templatingEngine->render('@BitBagSyliusCmsPlugin/Shop/Block/show.html.twig', ['block' => $block])->willReturn('
BitBag
'); + $blockResourceResolver->findOrLog('code')->willReturn($block); + $block->canBeDisplayedForTaxon($taxon)->willReturn(false); - $this->renderBlock('bitbag'); + $this->renderBlock('code', null, $taxon)->shouldReturn(''); } - public function it_renders_block_with_template( + public function it_returns_empty_string_when_block_not_displayable_for_product( BlockResourceResolverInterface $blockResourceResolver, BlockInterface $block, - Environment $templatingEngine + ProductInterface $product, ): void { - $blockResourceResolver->findOrLog('bitbag')->willReturn($block); - $templatingEngine->render('@BitBagSyliusCmsPlugin/Shop/Block/otherTemplate.html.twig', ['block' => $block])->willReturn('
BitBag Other Template
'); + $blockResourceResolver->findOrLog('code')->willReturn($block); + $block->canBeDisplayedForProduct($product)->willReturn(false); + $block->canBeDisplayedForProductInTaxon($product)->willReturn(false); + + $this->renderBlock('code', null, $product)->shouldReturn(''); + } + + public function it_renders_block_with_default_template( + BlockResourceResolverInterface $blockResourceResolver, + Environment $templatingEngine, + ContentElementRendererStrategyInterface $contentElementRendererStrategy, + BlockInterface $block, + ): void { + $blockResourceResolver->findOrLog('code')->willReturn($block); + $contentElementRendererStrategy->render($block)->willReturn('rendered content'); + + $templatingEngine->render('@SyliusCmsPlugin/Shop/Block/show.html.twig', [ + 'content' => 'rendered content', + 'context' => null, + ])->willReturn('rendered block'); + + $this->renderBlock('code')->shouldReturn('rendered block'); + } + + public function it_renders_block_with_custom_template( + BlockResourceResolverInterface $blockResourceResolver, + Environment $templatingEngine, + ContentElementRendererStrategyInterface $contentElementRendererStrategy, + BlockInterface $block, + ): void { + $blockResourceResolver->findOrLog('code')->willReturn($block); + $contentElementRendererStrategy->render($block)->willReturn('rendered content'); + + $templatingEngine->render('custom_template.html.twig', [ + 'content' => 'rendered content', + 'context' => null, + ])->willReturn('rendered block'); - $this->renderBlock('bitbag', '@BitBagSyliusCmsPlugin/Shop/Block/otherTemplate.html.twig'); + $this->renderBlock('code', 'custom_template.html.twig')->shouldReturn('rendered block'); } } diff --git a/spec/Twig/Runtime/RenderContentElementsRuntimeSpec.php b/spec/Twig/Runtime/RenderContentElementsRuntimeSpec.php new file mode 100644 index 000000000..c5c3eea89 --- /dev/null +++ b/spec/Twig/Runtime/RenderContentElementsRuntimeSpec.php @@ -0,0 +1,36 @@ +beConstructedWith($contentElementRendererStrategy); + } + + public function it_is_initializable(): void + { + $this->shouldHaveType(RenderContentElementsRuntime::class); + } + + public function it_renders_a_block(ContentElementRendererStrategyInterface $contentElementRendererStrategy, BlockInterface $block): void + { + $contentElementRendererStrategy->render($block)->willReturn('rendered block content'); + $this->render($block)->shouldReturn('rendered block content'); + } + + public function it_renders_a_page(ContentElementRendererStrategyInterface $contentElementRendererStrategy, PageInterface $page): void + { + $contentElementRendererStrategy->render($page)->willReturn('rendered page content'); + $this->render($page)->shouldReturn('rendered page content'); + } +} diff --git a/spec/Twig/Runtime/RenderContentRuntimeSpec.php b/spec/Twig/Runtime/RenderContentRuntimeSpec.php index 300f3d3e5..3a7dd67da 100644 --- a/spec/Twig/Runtime/RenderContentRuntimeSpec.php +++ b/spec/Twig/Runtime/RenderContentRuntimeSpec.php @@ -1,27 +1,19 @@ beConstructedWith($contentParser); } @@ -38,7 +30,7 @@ public function it_implements_render_content_runtime_interface(): void public function it_renders_content( ContentParserInterface $contentParser, - ContentableInterface $contentableResource + ContentableInterface $contentableResource, ): void { $contentParser->parse('content')->willReturn('content'); $contentableResource->getContent()->willReturn('content'); diff --git a/spec/Twig/Runtime/RenderMediaRuntimeSpec.php b/spec/Twig/Runtime/RenderMediaRuntimeSpec.php index f699e23e1..c5ec67b9d 100644 --- a/spec/Twig/Runtime/RenderMediaRuntimeSpec.php +++ b/spec/Twig/Runtime/RenderMediaRuntimeSpec.php @@ -1,30 +1,22 @@ beConstructedWith($mediaProviderResolver, $mediaResourceResolver); } @@ -43,12 +35,12 @@ public function it_renders_media( MediaResourceResolverInterface $mediaResourceResolver, MediaProviderResolverInterface $mediaProviderResolver, ProviderInterface $provider, - MediaInterface $media + MediaInterface $media, ): void { - $mediaResourceResolver->findOrLog('bitbag')->willReturn($media); + $mediaResourceResolver->findOrLog('sylius_cms')->willReturn($media); $provider->render($media, null)->willReturn('content'); $mediaProviderResolver->resolveProvider($media)->willReturn($provider); - $this->renderMedia('bitbag')->shouldReturn('content'); + $this->renderMedia('sylius_cms')->shouldReturn('content'); } } diff --git a/spec/Twig/Runtime/RenderLinkRuntimeSpec.php b/spec/Twig/Runtime/RenderPageLinkRuntimeSpec.php similarity index 52% rename from spec/Twig/Runtime/RenderLinkRuntimeSpec.php rename to spec/Twig/Runtime/RenderPageLinkRuntimeSpec.php index 0440b8cfb..c2240ca7a 100644 --- a/spec/Twig/Runtime/RenderLinkRuntimeSpec.php +++ b/spec/Twig/Runtime/RenderPageLinkRuntimeSpec.php @@ -1,60 +1,48 @@ beConstructedWith($localeContext, $pageRepository, $router, 'defaultTemplate'); + $this->beConstructedWith($pageRepository, $router, 'defaultTemplate'); } public function it_is_initializable(): void { - $this->shouldHaveType(RenderLinkRuntime::class); + $this->shouldHaveType(RenderPageLinkRuntime::class); } public function it_implements_render_link_runtime_interface(): void { - $this->shouldHaveType(RenderLinkRuntimeInterface::class); + $this->shouldHaveType(RenderPageLinkRuntimeInterface::class); } public function it_renders_link_for_code( Environment $environment, PageInterface $page, PageRepositoryInterface $pageRepository, - LocaleContextInterface $localeContext ): void { $options = []; $code = 'CODE'; $template = null; - $localeCode = 'en_US'; - $localeContext->getLocaleCode()->willReturn($localeCode); - $pageRepository->findOneEnabledByCode($code, $localeCode)->willReturn($page); + $pageRepository->findOneEnabledByCode($code)->willReturn($page); $environment->render($template ?? 'defaultTemplate', [ 'page' => $page, @@ -66,26 +54,23 @@ public function it_renders_link_for_code( public function it_gets_link_for_code( RouterInterface $router, - LocaleContextInterface $localeContext, PageRepositoryInterface $pageRepository, - PageInterface $page + PageInterface $page, ): void { $code = 'CODE'; - $localeCode = 'en_US'; $slug = 'SLUG'; $options = []; - $localeContext->getLocaleCode()->willReturn($localeCode); - $pageRepository->findOneEnabledByCode($code, $localeCode)->willReturn($page); + $pageRepository->findOneEnabledByCode($code)->willReturn($page); $page->getSlug()->willReturn($slug); - $router->generate('bitbag_sylius_cms_plugin_shop_page_show', ['slug' => $slug])->willReturn('link'); + $router->generate('sylius_cms_shop_page_show', ['slug' => $slug])->willReturn('link'); $this->getLinkForCode($code, $options)->shouldReturn('link'); } public function it_returns_not_found_message_when_getting_link_for_code( - LocaleContextInterface $localeContext + LocaleContextInterface $localeContext, ): void { $localeContext->getLocaleCode()->willReturn('en_US'); diff --git a/spec/Twig/Runtime/RenderProductPagesRuntimeSpec.php b/spec/Twig/Runtime/RenderProductPagesRuntimeSpec.php deleted file mode 100644 index 1406b14a2..000000000 --- a/spec/Twig/Runtime/RenderProductPagesRuntimeSpec.php +++ /dev/null @@ -1,90 +0,0 @@ -beConstructedWith($pageRepository, $channelContext, $templatingEngine, $sectionsSorter); - } - - public function it_is_initializable(): void - { - $this->shouldHaveType(RenderProductPagesRuntime::class); - } - - public function it_implements_render_product_pages_runtime_interface(): void - { - $this->shouldHaveType(RenderProductPagesRuntimeInterface::class); - } - - public function it_renders_product_pages( - ChannelContextInterface $channelContext, - ProductInterface $product, - ChannelInterface $channel, - PageRepositoryInterface $pageRepository, - PageInterface $page, - SectionInterface $section, - Environment $templatingEngine, - SectionsSorterInterface $sectionsSorter - ): void { - $channel->getCode()->willReturn('WEB'); - $channelContext->getChannel()->willReturn($channel); - $page->getSections()->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'); - - $this->renderProductPages($product)->shouldReturn('content'); - } - - public function it_renders_product_pages_with_sections( - ChannelContextInterface $channelContext, - ProductInterface $product, - ChannelInterface $channel, - PageRepositoryInterface $pageRepository, - PageInterface $page, - SectionInterface $section, - Environment $templatingEngine, - SectionsSorterInterface $sectionsSorter - ): void { - $channel->getCode()->willReturn('WEB'); - $channelContext->getChannel()->willReturn($channel); - $page->getSections()->willReturn(new ArrayCollection([$section])); - $section->getCode()->willReturn('SECTION_CODE'); - $pageRepository->findByProductAndSectionCode($product, 'SECTION_CODE', 'WEB', null)->willReturn([])->shouldBeCalled(); - $sectionsSorter->sortBySections([])->willReturn([]); - $templatingEngine->render('@BitBagSyliusCmsPlugin/Shop/Product/_pagesBySection.html.twig', ['data' => []])->willReturn('content'); - - $this->renderProductPages($product, 'SECTION_CODE')->shouldReturn('content'); - } -} diff --git a/spec/Twig/Runtime/TranslationFormReduceRuntimeSpec.php b/spec/Twig/Runtime/TranslationFormReduceRuntimeSpec.php new file mode 100644 index 000000000..80822f696 --- /dev/null +++ b/spec/Twig/Runtime/TranslationFormReduceRuntimeSpec.php @@ -0,0 +1,125 @@ +shouldHaveType(TranslationFormReduceRuntime::class); + } + + public function it_reduces_form_to_specified_fields( + FormView $form, + FormView $localeForm, + FormView $slugForm, + FormView $titleForm, + ): void { + $form->children = [ + 'en_US' => $localeForm, + ]; + + $localeForm->children = [ + 'slug' => $slugForm, + 'title' => $titleForm, + 'metaDescription' => new FormView(), + ]; + + $result = $this->reduceTranslationForm($form, ['slug', 'title']); + $result->shouldHaveKey('en_US'); + $result['en_US']->shouldHaveKey('slug'); + $result['en_US']->shouldHaveKey('title'); + $result['en_US']->shouldNotHaveKey('metaDescription'); + } + + public function it_throws_exception_if_field_is_not_found(FormView $form, FormView $localeForm): void + { + $form->children = [ + 'en_US' => $localeForm, + ]; + + $localeForm->children = [ + 'metaDescription' => new FormView(), + ]; + + $this->shouldThrow(\InvalidArgumentException::class)->during('reduceTranslationForm', [$form, ['slug', 'title']]); + } + + public function it_handles_multiple_locales( + FormView $form, + FormView $enLocale, + FormView $deLocale, + FormView $slugForm, + FormView $titleForm, + ): void { + $form->children = [ + 'en_US' => $enLocale, + 'de_DE' => $deLocale, + ]; + + $enLocale->children = [ + 'slug' => $slugForm, + 'title' => $titleForm, + ]; + + $deLocale->children = [ + 'slug' => $slugForm, + 'title' => $titleForm, + ]; + + $result = $this->reduceTranslationForm($form, ['slug', 'title']); + $result->shouldHaveCount(2); + $result['en_US']->shouldHaveKey('slug'); + $result['en_US']->shouldHaveKey('title'); + $result['de_DE']->shouldHaveKey('slug'); + $result['de_DE']->shouldHaveKey('title'); + } + + public function it_throws_exception_if_field_is_not_present_in_multiple_locales( + FormView $form, + FormView $enLocale, + FormView $deLocale, + FormView $slugForm, + ): void { + $form->children = [ + 'en_US' => $enLocale, + 'de_DE' => $deLocale, + ]; + + $enLocale->children = [ + 'slug' => $slugForm, + ]; + + $deLocale->children = [ + 'slug' => $slugForm, + // 'title' is missing in de_DE + ]; + + $this->shouldThrow(\InvalidArgumentException::class)->during('reduceTranslationForm', [$form, ['slug', 'title']]); + } + + public function it_handles_empty_field_array( + FormView $form, + FormView $localeForm, + FormView $slugForm, + FormView $titleForm, + ): void { + $form->children = [ + 'en_US' => $localeForm, + ]; + + $localeForm->children = [ + 'slug' => $slugForm, + 'title' => $titleForm, + ]; + + $result = $this->reduceTranslationForm($form, []); + $result->shouldHaveCount(0); + } +} diff --git a/src/Assigner/ChannelsAssigner.php b/src/Assigner/ChannelsAssigner.php index ababfc15b..c911fca89 100644 --- a/src/Assigner/ChannelsAssigner.php +++ b/src/Assigner/ChannelsAssigner.php @@ -1,14 +1,8 @@ channelRepository->findOneBy(['code' => $channelCode]); + $channels = $this->channelRepository->findBy(['code' => $channelsCodes]); + Assert::allIsInstanceOf($channels, ChannelInterface::class); - Assert::notNull($channel, sprintf('Channel with %s code not found.', $channelCode)); + foreach ($channels as $channel) { $channelsAware->addChannel($channel); } } diff --git a/src/Assigner/ChannelsAssignerInterface.php b/src/Assigner/ChannelsAssignerInterface.php index 4bc3c7731..d44118350 100644 --- a/src/Assigner/ChannelsAssignerInterface.php +++ b/src/Assigner/ChannelsAssignerInterface.php @@ -1,14 +1,8 @@ collectionRepository->findBy(['code' => $collectionsCodes]); + Assert::allIsInstanceOf($collections, CollectionInterface::class); + + foreach ($collections as $collection) { + $collectionsAware->addCollection($collection); + } + } +} diff --git a/src/Assigner/CollectionsAssignerInterface.php b/src/Assigner/CollectionsAssignerInterface.php new file mode 100644 index 000000000..a48e7af97 --- /dev/null +++ b/src/Assigner/CollectionsAssignerInterface.php @@ -0,0 +1,12 @@ +localeRepository->findBy(['code' => $localesCodes]); + Assert::allIsInstanceOf($locales, LocaleInterface::class); + + foreach ($locales as $locale) { + $localesAware->addLocale($locale); + } + } +} diff --git a/src/Assigner/LocalesAssignerInterface.php b/src/Assigner/LocalesAssignerInterface.php new file mode 100644 index 000000000..5d5a3645e --- /dev/null +++ b/src/Assigner/LocalesAssignerInterface.php @@ -0,0 +1,12 @@ +productRepository->findOneBy(['code' => $productCode]); + $products = $this->productRepository->findBy(['code' => $productsCodes]); + Assert::allIsInstanceOf($products, ProductInterface::class); - Assert::notNull($product, sprintf('Product with %s code not found.', $productCode)); + foreach ($products as $product) { $productsAware->addProduct($product); } } diff --git a/src/Assigner/ProductsAssignerInterface.php b/src/Assigner/ProductsAssignerInterface.php index b3fb31b89..333cd6383 100644 --- a/src/Assigner/ProductsAssignerInterface.php +++ b/src/Assigner/ProductsAssignerInterface.php @@ -1,16 +1,10 @@ taxonRepository->findBy(['code' => $taxonCodes]); + Assert::allIsInstanceOf($taxons, TaxonInterface::class); + + foreach ($taxons as $taxon) { + $productsInTaxonsAware->addProductsInTaxon($taxon); + } + } +} diff --git a/src/Assigner/ProductsInTaxonsAssignerInterface.php b/src/Assigner/ProductsInTaxonsAssignerInterface.php new file mode 100644 index 000000000..4bf692b76 --- /dev/null +++ b/src/Assigner/ProductsInTaxonsAssignerInterface.php @@ -0,0 +1,12 @@ +sectionRepository->findOneBy(['code' => $sectionCode]); - - Assert::notNull($section, sprintf('Section with %s code not found.', $sectionCode)); - $sectionsAware->addSection($section); - } - } -} diff --git a/src/Assigner/SectionsAssignerInterface.php b/src/Assigner/SectionsAssignerInterface.php deleted file mode 100644 index ef30f7542..000000000 --- a/src/Assigner/SectionsAssignerInterface.php +++ /dev/null @@ -1,18 +0,0 @@ -taxonRepository->findOneBy(['code' => $taxonCode]); + $taxons = $this->taxonRepository->findBy(['code' => $taxonCodes]); + Assert::allIsInstanceOf($taxons, TaxonInterface::class); - Assert::notNull($taxon, sprintf('Taxon with %s code not found.', $taxonCode)); + foreach ($taxons as $taxon) { $taxonAware->addTaxon($taxon); } } diff --git a/src/Assigner/TaxonsAssignerInterface.php b/src/Assigner/TaxonsAssignerInterface.php index 3a903587a..736082580 100644 --- a/src/Assigner/TaxonsAssignerInterface.php +++ b/src/Assigner/TaxonsAssignerInterface.php @@ -1,16 +1,10 @@ addCompilerPass(new ImporterCompilerPass()); - $container->addCompilerPass(new MediaProviderPass()); - $container->addCompilerPass(new AuthenticationManagerPolyfillPass()); - } -} diff --git a/src/Command/ImportFromCsvCommand.php b/src/Console/Command/ImportFromCsvCommand.php similarity index 70% rename from src/Command/ImportFromCsvCommand.php rename to src/Console/Command/ImportFromCsvCommand.php index cf1ea18de..f5d3f28e0 100644 --- a/src/Command/ImportFromCsvCommand.php +++ b/src/Console/Command/ImportFromCsvCommand.php @@ -1,20 +1,15 @@ setName('bitbag:import:csv') + ->setName('cms:import:csv') ->setDescription('Imports a resource') ->setHelp('This command allows you to import resources from CSV. It takes file path and resource name as parameter.') ->addArgument('resource', InputArgument::REQUIRED, 'Importer resource name.') @@ -36,11 +31,16 @@ protected function configure(): void protected function execute(InputInterface $input, OutputInterface $output): int { + $io = new SymfonyStyle($input, $output); $resourceName = $input->getArgument('resource'); $file = $input->getArgument('file'); + $io->title('Importing resources...'); + $this->importProcessor->process($resourceName, $file); - return 0; + $io->success('Resources imported successfully.'); + + return Command::SUCCESS; } } diff --git a/src/Controller/Action/Admin/ImportDataAction.php b/src/Controller/Action/Admin/ImportDataAction.php index e9164a177..ea21e8512 100644 --- a/src/Controller/Action/Admin/ImportDataAction.php +++ b/src/Controller/Action/Admin/ImportDataAction.php @@ -1,19 +1,13 @@ importProcessor->process($resourceName, $file->getPathname()); - $flashBag->set('success', $this->translator->trans('bitbag_sylius_cms_plugin.ui.successfully_imported')); + $flashBag->set('success', $this->translator->trans('sylius_cms.ui.successfully_imported')); } catch (ImportFailedException $exception) { $flashBag->set('error', $exception->getMessage()); } @@ -66,7 +60,7 @@ public function __invoke(Request $request): Response return new RedirectResponse($referer); } - return new Response($this->twig->render('@BitBagSyliusCmsPlugin/Grid/Form/_importForm.html.twig', [ + return new Response($this->twig->render('@SyliusCmsPlugin/Grid/Form/_importForm.html.twig', [ 'form' => $form->createView(), ])); } diff --git a/src/Controller/Action/Admin/ProductSearchAction.php b/src/Controller/Action/Admin/ProductSearchAction.php index feb882ef6..e8fff2e69 100644 --- a/src/Controller/Action/Admin/ProductSearchAction.php +++ b/src/Controller/Action/Admin/ProductSearchAction.php @@ -1,14 +1,8 @@ getScheme(), $request->getHttpHost()), )); - } catch (\Exception $exception) { + } catch (\Exception) { return new Response('', Response::HTTP_BAD_REQUEST); } diff --git a/src/Controller/Action/Admin/TaxonSearchAction.php b/src/Controller/Action/Admin/TaxonSearchAction.php index 8e8883700..728a259a7 100644 --- a/src/Controller/Action/Admin/TaxonSearchAction.php +++ b/src/Controller/Action/Admin/TaxonSearchAction.php @@ -1,14 +1,8 @@ templateRepository->find($id); + if (null === $template) { + return new JsonResponse([ + 'status' => 'error', + 'message' => 'Template not found', + ]); + } + + return new JsonResponse([ + 'status' => 'success', + 'content' => $template->getContentElements(), + ]); + } +} diff --git a/src/Controller/Action/Admin/UploadEditorImageAction.php b/src/Controller/Action/Admin/UploadEditorImageAction.php index d45b500b5..84a6e7c71 100644 --- a/src/Controller/Action/Admin/UploadEditorImageAction.php +++ b/src/Controller/Action/Admin/UploadEditorImageAction.php @@ -1,18 +1,12 @@ get('code'); /** @var BlockResourceResolverInterface $blockResourceResolver */ - $blockResourceResolver = $this->get('bitbag_sylius_cms_plugin.resolver.block_resource'); + $blockResourceResolver = $this->get('sylius_cms.resolver.block_resource'); $block = $blockResourceResolver->findOrLog($code); if (null === $block) { @@ -46,9 +41,7 @@ public function renderBlockAction(Request $request): Response return $this->viewHandler->handle($configuration, View::create($block)); } - $template = $request->get('template') ?? self::BLOCK_TEMPLATE; - - return $this->render($template, [ + return $this->render($block->getTemplate() ?? self::BLOCK_TEMPLATE, [ 'configuration' => $configuration, 'metadata' => $this->metadata, 'resource' => $block, @@ -69,10 +62,6 @@ public function previewAction(Request $request): Response /** @var BlockInterface $block */ $block = $form->getData(); - $defaultLocale = $this->getParameter('locale'); - - $block->setFallbackLocale($request->get('_locale', $defaultLocale)); - $block->setCurrentLocale($request->get('_locale', $defaultLocale)); if (!$configuration->isHtmlRequest()) { Assert::true(null !== $this->viewHandler); @@ -80,10 +69,14 @@ public function previewAction(Request $request): Response return $this->viewHandler->handle($configuration, View::create($block)); } + /** @var ContentElementRendererStrategyInterface $contentElementRendererStrategy */ + $contentElementRendererStrategy = $this->get('sylius_cms.content_element_renderer_strategy'); + return $this->render($configuration->getTemplate(ResourceActions::CREATE . '.html'), [ 'resource' => $block, + 'template' => $block->getTemplate(), + 'content' => $contentElementRendererStrategy->render($block), $this->metadata->getName() => $block, - 'blockTemplate' => self::BLOCK_TEMPLATE, ]); } } diff --git a/src/Controller/Helper/FormErrorsFlashHelper.php b/src/Controller/Helper/FormErrorsFlashHelper.php index ab03bedc8..5ec6ef61f 100644 --- a/src/Controller/Helper/FormErrorsFlashHelper.php +++ b/src/Controller/Helper/FormErrorsFlashHelper.php @@ -1,14 +1,8 @@ getMessage(); } - $message = $this->translator->trans('bitbag_sylius_cms_plugin.ui.form_was_submitted_with_errors') . ' ' . rtrim(implode(' ', $errors)); + $message = $this->translator->trans('sylius_cms.ui.form_was_submitted_with_errors') . ' ' . rtrim(implode(' ', $errors)); $session = $this->requestStack->getSession()->getFlashBag(); $session->set('error', $message); diff --git a/src/Controller/Helper/FormErrorsFlashHelperInterface.php b/src/Controller/Helper/FormErrorsFlashHelperInterface.php index 99aa53283..e12a85c10 100644 --- a/src/Controller/Helper/FormErrorsFlashHelperInterface.php +++ b/src/Controller/Helper/FormErrorsFlashHelperInterface.php @@ -1,14 +1,8 @@ getRequestConfiguration($request); - - $this->isGrantedOr403($configuration, ResourceActions::CREATE); - /** @var MediaInterface $media */ - $media = $this->getResourceInterface($request); - $form = $this->getFormForResource($configuration, $media); - $mediaTemplate = null; - - $form->handleRequest($request); - - if ($form->isSubmitted() && $form->isValid()) { - $this->setMediaLocales($media, $request); - $this->setMediaPathIfExists($media); - $mediaTemplate = $this->mediaProviderResolver->resolveProvider($media)->getTemplate(); - } - $this->formErrorsFlashHelper->addFlashErrors($form); - - return $this->render($configuration->getTemplate(ResourceActions::CREATE . '.html'), [ - 'metadata' => $this->metadata, - 'resource' => $media, - 'mediaTemplate' => $mediaTemplate, - $this->metadata->getName() => $media, - ]); - } - public function setMediaProviderResolver(MediaProviderResolverInterface $mediaProviderResolver): void { $this->mediaProviderResolver = $mediaProviderResolver; @@ -117,18 +82,4 @@ private function getMediaForRequestCode(RequestConfiguration $configuration, Req return $this->mediaResourceResolver->findOrLog($code); } - - private function setMediaLocales(MediaInterface $media, Request $request): void - { - $defaultLocale = $this->getParameter('locale'); - $media->setFallbackLocale($request->get('_locale', $defaultLocale)); - $media->setCurrentLocale($request->get('_locale', $defaultLocale)); - } - - private function setMediaPathIfExists(MediaInterface $media): void - { - if (null !== $media->getFile() || null !== $media->getPath()) { - $this->setResourceMediaPath($media); - } - } } diff --git a/src/Controller/MediaPageControllersCommonDependencyInjectionsTrait.php b/src/Controller/MediaPageControllersCommonDependencyInjectionsTrait.php index 9fe0e48a9..5592b00df 100644 --- a/src/Controller/MediaPageControllersCommonDependencyInjectionsTrait.php +++ b/src/Controller/MediaPageControllersCommonDependencyInjectionsTrait.php @@ -2,22 +2,19 @@ declare(strict_types=1); -namespace BitBag\SyliusCmsPlugin\Controller; +namespace Sylius\CmsPlugin\Controller; -use BitBag\SyliusCmsPlugin\Controller\Helper\FormErrorsFlashHelperInterface; use Liip\ImagineBundle\Imagine\Cache\CacheManager; use Liip\ImagineBundle\Imagine\Data\DataManager; +use Sylius\CmsPlugin\Controller\Helper\FormErrorsFlashHelperInterface; trait MediaPageControllersCommonDependencyInjectionsTrait { - /** @var CacheManager */ - private $cacheManager; + private CacheManager $cacheManager; - /** @var DataManager */ - private $dataManager; + private DataManager $dataManager; - /** @var FormErrorsFlashHelperInterface */ - private $formErrorsFlashHelper; + private FormErrorsFlashHelperInterface $formErrorsFlashHelper; public function setFormErrorsFlashHelper(FormErrorsFlashHelperInterface $formErrorsFlashHelper): void { diff --git a/src/Controller/PageController.php b/src/Controller/PageController.php index da031234a..b06197d9f 100755 --- a/src/Controller/PageController.php +++ b/src/Controller/PageController.php @@ -1,20 +1,16 @@ getRequestConfiguration($request); + + $this->isGrantedOr403($configuration, ResourceActions::SHOW); + + $slug = $request->attributes->get('slug'); + + /** @var PageRepositoryInterface $pageRepository */ + $pageRepository = $this->get('sylius_cms.repository.page'); + + /** @var LocaleContextInterface $localeContext */ + $localeContext = $this->get('sylius.context.locale'); + + /** @var ChannelContextInterface $channelContext */ + $channelContext = $this->get('sylius.context.channel'); + + Assert::notNull($channelContext->getChannel()->getCode()); + + $page = $pageRepository->findOneEnabledBySlugAndChannelCode( + $slug, + $localeContext->getLocaleCode(), + $channelContext->getChannel()->getCode(), + ); + + if (null === $page) { + throw $this->createNotFoundException('Page not found'); + } + + return $this->render($page->getTemplate() ?? self::DEFAULT_TEMPLATE, [ + 'page' => $page, + ]); + } + public function renderLinkAction(Request $request): Response { $configuration = $this->getRequestConfiguration($request); @@ -76,8 +107,6 @@ public function previewAction(Request $request): Response $page->setFallbackLocale($request->get('_locale', $defaultLocale)); $page->setCurrentLocale($request->get('_locale', $defaultLocale)); - $this->resolveImage($page); - $this->formErrorsFlashHelper->addFlashErrors($form); if (!$configuration->isHtmlRequest()) { @@ -88,26 +117,11 @@ public function previewAction(Request $request): Response return $this->render($configuration->getTemplate(ResourceActions::CREATE . '.html'), [ 'resource' => $page, 'preview' => true, + 'template' => $page->getTemplate() ?? self::DEFAULT_TEMPLATE, $this->metadata->getName() => $page, ]); } - private function resolveImage(PageInterface $page): void - { - /** @var PageTranslationInterface $translation */ - $translation = $page->getTranslation(); - - $image = $translation->getImage(); - - if (null === $image || null === $image->getPath()) { - return; - } - $this->setResourceMediaPath($image); - /** @var PageTranslationInterface $pageTranslationInterface */ - $pageTranslationInterface = $page->getTranslation(); - $pageTranslationInterface->setImage($image); - } - public function setPageResourceResolver(PageResourceResolverInterface $pageResourceResolver): void { $this->pageResourceResolver = $pageResourceResolver; diff --git a/src/Controller/PageSlugController.php b/src/Controller/PageSlugController.php index 2714b16aa..83b68fbc6 100755 --- a/src/Controller/PageSlugController.php +++ b/src/Controller/PageSlugController.php @@ -1,14 +1,8 @@ getMimeType()); Assert::notNull($media->getType()); - if (1 === preg_match("/image\//", $media->getMimeType()) && 'image' === $media->getType()) { + if ('image' === $media->getType() && 1 === preg_match("/image\//", $media->getMimeType())) { $this->setPathForImageMediaType($media); } else { $this->setPathForNonImageMediaType($media); diff --git a/src/DependencyInjection/BitBagSyliusCmsExtension.php b/src/DependencyInjection/BitBagSyliusCmsExtension.php deleted file mode 100755 index f22888356..000000000 --- a/src/DependencyInjection/BitBagSyliusCmsExtension.php +++ /dev/null @@ -1,45 +0,0 @@ -prependDoctrineMigrations($container); - } - - protected function getMigrationsNamespace(): string - { - return 'BitBag\SyliusCmsPlugin\Migrations'; - } - - protected function getMigrationsDirectory(): string - { - return '@BitBagSyliusCmsPlugin/Migrations'; - } - - protected function getNamespacesOfMigrationsExecutedBefore(): array - { - return ['Sylius\Bundle\CoreBundle\Migrations']; - } -} diff --git a/src/DependencyInjection/Compiler/AuthenticationManagerPolyfillPass.php b/src/DependencyInjection/Compiler/AuthenticationManagerPolyfillPass.php deleted file mode 100644 index 239ad5fde..000000000 --- a/src/DependencyInjection/Compiler/AuthenticationManagerPolyfillPass.php +++ /dev/null @@ -1,21 +0,0 @@ -has('security.authentication_manager') && - true === $container->has('security.authentication.manager') - ) { - $container->setAlias('security.authentication_manager', 'security.authentication.manager'); - } - } -} diff --git a/src/DependencyInjection/Compiler/ContentElementPass.php b/src/DependencyInjection/Compiler/ContentElementPass.php new file mode 100644 index 000000000..685584139 --- /dev/null +++ b/src/DependencyInjection/Compiler/ContentElementPass.php @@ -0,0 +1,57 @@ +findTaggedServiceIds('sylius_cms.content_element') as $id => $attributes) { + if (!isset($attributes[0]['template'])) { + throw new \InvalidArgumentException( + sprintf('Tagged content element "%s" needs to have `template` attribute.', $id), + ); + } + + $definition = $container->getDefinition($id); + $definition->addMethodCall('setTemplate', [$attributes[0]['template']]); + $definition->addMethodCall('setTwigEnvironment', [new Reference('twig')]); + + if (isset($attributes[0]['form_type'])) { + $this->registerFormTypeService($container, $attributes[0]['form_type']); + } + } + } + + private function retrieveElementNameConstantFromFormType(string $formType): string + { + if (!class_exists($formType)) { + throw new \InvalidArgumentException(sprintf('Form type "%s" does not exist.', $formType)); + } + + if (!defined($formType . '::TYPE')) { + throw new \InvalidArgumentException(sprintf('Form type "%s" needs to have "TYPE" constant.', $formType)); + } + + return constant(sprintf('%s::TYPE', $formType)); + } + + private function registerFormTypeService(ContainerBuilder $container, string $formType): void + { + $elementName = $this->retrieveElementNameConstantFromFormType($formType); + $formTypeDefinition = new Definition($formType); + $formTypeDefinition->addTag('form.type'); + $formTypeDefinition->addTag('sylius_cms.content_elements.type', [ + 'key' => $elementName, + ]); + + $container->setDefinition('sylius_cms.form.type.content_element.' . $elementName, $formTypeDefinition); + } +} diff --git a/src/DependencyInjection/Compiler/ImporterCompilerPass.php b/src/DependencyInjection/Compiler/ImporterCompilerPass.php index 7379c5ded..53b2645a3 100644 --- a/src/DependencyInjection/Compiler/ImporterCompilerPass.php +++ b/src/DependencyInjection/Compiler/ImporterCompilerPass.php @@ -1,27 +1,21 @@ has('bitbag_sylius_cms_plugin.importer.chain')) { + if (!$container->has('sylius_cms.importer.chain')) { return; } @@ -31,7 +25,7 @@ public function process(ContainerBuilder $container): void ; $taggedServices = $container->findTaggedServiceIds(self::TAG_ID); - $definition = $container->findDefinition('bitbag_sylius_cms_plugin.importer.chain'); + $definition = $container->findDefinition('sylius_cms.importer.chain'); foreach ($taggedServices as $id => $tags) { $definition->addMethodCall('addImporter', [new Reference($id)]); diff --git a/src/DependencyInjection/Compiler/MediaProviderPass.php b/src/DependencyInjection/Compiler/MediaProviderPass.php index 5e8c80962..80c375fa0 100644 --- a/src/DependencyInjection/Compiler/MediaProviderPass.php +++ b/src/DependencyInjection/Compiler/MediaProviderPass.php @@ -1,14 +1,8 @@ hasDefinition('bitbag_sylius_cms_plugin.registry.media_provider')) { + if (!$container->hasDefinition('sylius_cms.registry.media_provider')) { return; } - $providerRegistry = $container->getDefinition('bitbag_sylius_cms_plugin.registry.media_provider'); + $providerRegistry = $container->getDefinition('sylius_cms.registry.media_provider'); $providers = []; - foreach ($container->findTaggedServiceIds('bitbag_sylius_cms_plugin.media_provider') as $id => $attributes) { - if (!isset($attributes[0]['type']) || !isset($attributes[0]['label'])) { + foreach ($container->findTaggedServiceIds('sylius_cms.media_provider') as $id => $attributes) { + if (!isset($attributes[0]['type'], $attributes[0]['label'])) { throw new \InvalidArgumentException('Tagged media provider needs to have `type` and `label` attribute.'); } @@ -40,6 +34,6 @@ public function process(ContainerBuilder $container): void ksort($providers); - $container->setParameter('bitbag_sylius_cms_plugin.media_providers', $providers); + $container->setParameter('sylius_cms.media_providers', $providers); } } diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php new file mode 100644 index 000000000..20206897b --- /dev/null +++ b/src/DependencyInjection/Configuration.php @@ -0,0 +1,219 @@ +getRootNode(); + + $this->addResourcesSection($rootNode); + $this->addTemplatesSection($rootNode); + + return $treeBuilder; + } + + private function addResourcesSection(ArrayNodeDefinition $node): void + { + $node + ->children() + ->arrayNode('resources') + ->addDefaultsIfNotSet() + ->children() + ->arrayNode('block') + ->addDefaultsIfNotSet() + ->children() + ->variableNode('options')->end() + ->arrayNode('classes') + ->addDefaultsIfNotSet() + ->children() + ->scalarNode('model')->defaultValue(Block::class)->cannotBeEmpty()->end() + ->scalarNode('interface')->defaultValue(BlockInterface::class)->cannotBeEmpty()->end() + ->scalarNode('controller')->defaultValue(BlockController::class)->cannotBeEmpty()->end() + ->scalarNode('factory')->defaultValue(Factory::class)->cannotBeEmpty()->end() + ->scalarNode('repository')->defaultValue(BlockRepository::class)->cannotBeEmpty()->end() + ->scalarNode('form')->defaultValue(BlockType::class)->cannotBeEmpty()->end() + ->end() + ->end() + ->end() + ->end() + ->arrayNode('collection') + ->addDefaultsIfNotSet() + ->children() + ->variableNode('options')->end() + ->arrayNode('classes') + ->addDefaultsIfNotSet() + ->children() + ->scalarNode('model')->defaultValue(Collection::class)->cannotBeEmpty()->end() + ->scalarNode('interface')->defaultValue(CollectionInterface::class)->cannotBeEmpty()->end() + ->scalarNode('controller')->defaultValue(ResourceController::class)->cannotBeEmpty()->end() + ->scalarNode('factory')->defaultValue(Factory::class)->cannotBeEmpty()->end() + ->scalarNode('repository')->defaultValue(CollectionRepository::class)->cannotBeEmpty()->end() + ->scalarNode('form')->defaultValue(CollectionType::class)->cannotBeEmpty()->end() + ->end() + ->end() + ->end() + ->end() + ->arrayNode('content_configuration') + ->addDefaultsIfNotSet() + ->children() + ->variableNode('options')->end() + ->arrayNode('classes') + ->addDefaultsIfNotSet() + ->children() + ->scalarNode('model')->defaultValue(ContentConfiguration::class)->cannotBeEmpty()->end() + ->scalarNode('interface')->defaultValue(ContentConfigurationInterface::class)->cannotBeEmpty()->end() + ->scalarNode('controller')->defaultValue(ResourceController::class)->cannotBeEmpty()->end() + ->scalarNode('factory')->defaultValue(Factory::class)->cannotBeEmpty()->end() + ->scalarNode('repository')->defaultValue(ContentConfigurationRepository::class)->cannotBeEmpty()->end() + ->scalarNode('form')->defaultValue(ContentConfigurationType::class)->cannotBeEmpty()->end() + ->end() + ->end() + ->end() + ->end() + ->arrayNode('media') + ->addDefaultsIfNotSet() + ->children() + ->variableNode('options')->end() + ->arrayNode('classes') + ->addDefaultsIfNotSet() + ->children() + ->scalarNode('model')->defaultValue(Media::class)->cannotBeEmpty()->end() + ->scalarNode('interface')->defaultValue(MediaInterface::class)->cannotBeEmpty()->end() + ->scalarNode('controller')->defaultValue(MediaController::class)->cannotBeEmpty()->end() + ->scalarNode('factory')->defaultValue(TranslatableFactory::class)->cannotBeEmpty()->end() + ->scalarNode('repository')->defaultValue(MediaRepository::class)->cannotBeEmpty()->end() + ->scalarNode('form')->defaultValue(MediaType::class)->cannotBeEmpty()->end() + ->end() + ->end() + ->arrayNode('translation') + ->addDefaultsIfNotSet() + ->children() + ->arrayNode('classes') + ->addDefaultsIfNotSet() + ->children() + ->scalarNode('model')->defaultValue(MediaTranslation::class)->cannotBeEmpty()->end() + ->scalarNode('interface')->defaultValue(MediaTranslationInterface::class)->cannotBeEmpty()->end() + ->scalarNode('factory')->defaultValue(Factory::class)->cannotBeEmpty()->end() + ->end() + ->end() + ->end() + ->end() + ->end() + ->end() + ->arrayNode('page') + ->addDefaultsIfNotSet() + ->children() + ->variableNode('options')->end() + ->arrayNode('classes') + ->addDefaultsIfNotSet() + ->children() + ->scalarNode('model')->defaultValue(Page::class)->cannotBeEmpty()->end() + ->scalarNode('interface')->defaultValue(PageInterface::class)->cannotBeEmpty()->end() + ->scalarNode('controller')->defaultValue(PageController::class)->cannotBeEmpty()->end() + ->scalarNode('factory')->defaultValue(TranslatableFactory::class)->cannotBeEmpty()->end() + ->scalarNode('repository')->defaultValue(PageRepository::class)->cannotBeEmpty()->end() + ->scalarNode('form')->defaultValue(PageType::class)->cannotBeEmpty()->end() + ->end() + ->end() + ->arrayNode('translation') + ->addDefaultsIfNotSet() + ->children() + ->arrayNode('classes') + ->addDefaultsIfNotSet() + ->children() + ->scalarNode('model')->defaultValue(PageTranslation::class)->cannotBeEmpty()->end() + ->scalarNode('interface')->defaultValue(PageTranslationInterface::class)->cannotBeEmpty()->end() + ->scalarNode('factory')->defaultValue(Factory::class)->cannotBeEmpty()->end() + ->end() + ->end() + ->end() + ->end() + ->end() + ->end() + ->arrayNode('template') + ->addDefaultsIfNotSet() + ->children() + ->variableNode('options')->end() + ->arrayNode('classes') + ->addDefaultsIfNotSet() + ->children() + ->scalarNode('model')->defaultValue(Template::class)->cannotBeEmpty()->end() + ->scalarNode('interface')->defaultValue(TemplateInterface::class)->cannotBeEmpty()->end() + ->scalarNode('controller')->defaultValue(ResourceController::class)->cannotBeEmpty()->end() + ->scalarNode('factory')->defaultValue(Factory::class)->cannotBeEmpty()->end() + ->scalarNode('repository')->defaultValue(TemplateRepository::class)->cannotBeEmpty()->end() + ->scalarNode('form')->defaultValue(TemplateType::class)->cannotBeEmpty()->end() + ->end() + ->end() + ->end() + ->end() + ->end() + ->end() + ->end() + ; + } + + private function addTemplatesSection(ArrayNodeDefinition $node): void + { + $node + ->children() + ->arrayNode('templates') + ->addDefaultsIfNotSet() + ->children() + ->arrayNode('pages') + ->scalarPrototype()->end() + ->end() + ->arrayNode('blocks') + ->scalarPrototype()->end() + ->end() + ->end() + ->end() + ->end() + ; + } +} diff --git a/src/DependencyInjection/SyliusCmsExtension.php b/src/DependencyInjection/SyliusCmsExtension.php new file mode 100755 index 000000000..983f50e88 --- /dev/null +++ b/src/DependencyInjection/SyliusCmsExtension.php @@ -0,0 +1,59 @@ +processConfiguration($configuration, $configs); + + $container->setParameter('sylius_cms.templates.pages', $config['templates']['pages']); + $container->setParameter('sylius_cms.templates.blocks', $config['templates']['blocks']); + } + + public function prepend(ContainerBuilder $container): void + { + $config = $this->getCurrentConfiguration($container); + $container->setParameter('sylius_cms.fixtures_dir', __DIR__.'/../Resources/config/fixtures'); + + $this->registerResources('sylius_cms', 'doctrine/orm', $config['resources'], $container); + + $this->prependDoctrineMigrations($container); + } + + protected function getMigrationsNamespace(): string + { + return 'Sylius\CmsPlugin\Migrations'; + } + + protected function getMigrationsDirectory(): string + { + return '@SyliusCmsPlugin/Migrations'; + } + + protected function getNamespacesOfMigrationsExecutedBefore(): array + { + return ['Sylius\Bundle\CoreBundle\Migrations']; + } + + private function getCurrentConfiguration(ContainerBuilder $container): array + { + /** @var ConfigurationInterface $configuration */ + $configuration = $this->getConfiguration([], $container); + $configs = $container->getExtensionConfig($this->getAlias()); + + return $this->processConfiguration($configuration, $configs); + } +} diff --git a/src/Doctrine/ORM/Extension/EnabledAndAvailableExtension.php b/src/Doctrine/ORM/Extension/EnabledAndAvailableExtension.php new file mode 100644 index 000000000..6f69d8c66 --- /dev/null +++ b/src/Doctrine/ORM/Extension/EnabledAndAvailableExtension.php @@ -0,0 +1,69 @@ +addEnabledAndChannelCondition($queryBuilder, $queryNameGenerator, $resourceClass); + } + + public function applyToItem( + QueryBuilder $queryBuilder, + QueryNameGeneratorInterface $queryNameGenerator, + string $resourceClass, + array $identifiers, + Operation $operation = null, + array $context = [], + ): void { + $this->addEnabledAndChannelCondition($queryBuilder, $queryNameGenerator, $resourceClass); + } + + private function addEnabledAndChannelCondition(QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, string $resourceClass): void + { + $rootAlias = $queryBuilder->getRootAliases()[0]; + + $user = $this->userContext->getUser(); + if (null !== $user && in_array('ROLE_API_ACCESS', $user->getRoles(), true)) { + return; + } + + if (in_array(ToggleableInterface::class, (array) class_implements($resourceClass), true)) { + $queryBuilder + ->andWhere(sprintf('%s.enabled = :enabled', $rootAlias)) + ->setParameter('enabled', true); + } + + if (in_array(ChannelsAwareInterface::class, (array) class_implements($resourceClass), true)) { + $channelAlias = $queryNameGenerator->generateJoinAlias('channel'); + $queryBuilder + ->innerJoin(sprintf('%s.channels', $rootAlias), $channelAlias) + ->andWhere(sprintf('%s.code = :channel', $channelAlias)) + ->setParameter('channel', $this->channelContext->getChannel()->getCode()); + } + } +} diff --git a/src/Downloader/ImageDownloader.php b/src/Downloader/ImageDownloader.php deleted file mode 100644 index 93743c481..000000000 --- a/src/Downloader/ImageDownloader.php +++ /dev/null @@ -1,39 +0,0 @@ -filesystem->dumpFile($path, $contents); - - return new UploadedFile($path, $originalName); - } -} diff --git a/src/Downloader/ImageDownloaderInterface.php b/src/Downloader/ImageDownloaderInterface.php deleted file mode 100644 index f483dbf69..000000000 --- a/src/Downloader/ImageDownloaderInterface.php +++ /dev/null @@ -1,18 +0,0 @@ -initializeTranslationsCollection(); - $this->initializeSectionsCollection(); + $this->initializeCollectionsCollection(); + $this->initializeChannelsCollection(); + $this->initializeContentElementsCollection(); $this->initializeProductsCollection(); $this->initializeTaxonCollection(); - $this->initializeChannelsCollection(); + $this->initializeProductsInTaxonsCollection(); } - /** @var int|null */ - protected $id; + protected ?int $id; - /** @var string|null */ - protected $code; + protected ?string $code = null; + + protected ?string $name; + + protected ?string $template = null; public function getId(): ?int { @@ -57,59 +57,21 @@ public function setCode(?string $code): void public function getName(): ?string { - /** @var BlockTranslationInterface $blockTranslationInterface */ - $blockTranslationInterface = $this->getBlockTranslation(); - - return $blockTranslationInterface->getName(); + return $this->name; } public function setName(?string $name): void { - /** @var BlockTranslationInterface $blockTranslationInterface */ - $blockTranslationInterface = $this->getBlockTranslation(); - $blockTranslationInterface->setName($name); - } - - public function getContent(): ?string - { - /** @var BlockTranslationInterface $blockTranslationInterface */ - $blockTranslationInterface = $this->getBlockTranslation(); - - return $blockTranslationInterface->getContent(); - } - - public function setContent(?string $content): void - { - /** @var BlockTranslationInterface $blockTranslationInterface */ - $blockTranslationInterface = $this->getBlockTranslation(); - $blockTranslationInterface->setContent($content); - } - - public function getLink(): ?string - { - /** @var BlockTranslationInterface $blockTranslationInterface */ - $blockTranslationInterface = $this->getBlockTranslation(); - - return $blockTranslationInterface->getLink(); - } - - public function setLink(?string $link): void - { - /** @var BlockTranslationInterface $blockTranslationInterface */ - $blockTranslationInterface = $this->getBlockTranslation(); - $blockTranslationInterface->setLink($link); + $this->name = $name; } - /** - * @return BlockTranslationInterface|TranslationInterface - */ - protected function getBlockTranslation(): TranslationInterface + public function getTemplate(): ?string { - return $this->getTranslation(); + return $this->template; } - protected function createTranslation(): BlockTranslationInterface + public function setTemplate(?string $template): void { - return new BlockTranslation(); + $this->template = $template; } } diff --git a/src/Entity/BlockInterface.php b/src/Entity/BlockInterface.php index 86dddbdc5..fd16e7f36 100755 --- a/src/Entity/BlockInterface.php +++ b/src/Entity/BlockInterface.php @@ -1,29 +1,24 @@ name; - } - - public function setName(?string $name): void - { - $this->name = $name; - } - - public function getContent(): ?string - { - return $this->content; - } - - public function setContent(?string $content): void - { - $this->content = $content; - } - - public function getId(): ?int - { - return $this->id; - } - - public function getLink(): ?string - { - return $this->link; - } - - public function setLink(?string $link): void - { - $this->link = $link; - } -} diff --git a/src/Entity/BlockTranslationInterface.php b/src/Entity/BlockTranslationInterface.php index 28676df90..399dd1125 100755 --- a/src/Entity/BlockTranslationInterface.php +++ b/src/Entity/BlockTranslationInterface.php @@ -1,29 +1,15 @@ initializePagesCollection(); + $this->initializeBlocksCollection(); + $this->initializeMediaCollection(); + } + + public function getId(): ?int + { + return $this->id; + } + + public function getCode(): ?string + { + return $this->code; + } + + 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 + { + return $this->name; + } + + public function setName(?string $name): void + { + $this->name = $name; + } +} diff --git a/src/Entity/CollectionInterface.php b/src/Entity/CollectionInterface.php new file mode 100755 index 000000000..96c6dc68f --- /dev/null +++ b/src/Entity/CollectionInterface.php @@ -0,0 +1,26 @@ +id; + } + + public function getType(): ?string + { + return $this->type; + } + + public function setType(?string $type): void + { + $this->type = $type; + } + + public function getConfiguration(): array + { + return $this->configuration; + } + + public function setConfiguration(array $configuration): void + { + $this->configuration = $configuration; + } + + public function getLocale(): ?string + { + return $this->locale; + } + + public function setLocale(?string $locale): void + { + $this->locale = $locale; + } + + public function getBlock(): ?BlockInterface + { + return $this->block; + } + + public function setBlock(?BlockInterface $block): void + { + $this->block = $block; + } + + public function getPage(): ?PageInterface + { + return $this->page; + } + + public function setPage(?PageInterface $page): void + { + $this->page = $page; + } +} diff --git a/src/Entity/ContentConfigurationInterface.php b/src/Entity/ContentConfigurationInterface.php new file mode 100644 index 000000000..b593a3c2c --- /dev/null +++ b/src/Entity/ContentConfigurationInterface.php @@ -0,0 +1,30 @@ +initializeTranslationsCollection(); - $this->initializeChannelsCollection(); - } - - public function getId(): ?int - { - return $this->id; - } - - public function getCode(): ?string - { - return $this->code; - } - - public function setCode(?string $code): void - { - $this->code = $code; - } - - public function getPosition(): ?int - { - return $this->position; - } - - public function setPosition(?int $position): void - { - $this->position = $position; - } - - public function getQuestion(): ?string - { - /** @var FrequentlyAskedQuestionInterface $frequentlyAskedQuestionInterface */ - $frequentlyAskedQuestionInterface = $this->getFrequentlyAskedQuestionTranslation(); - - return $frequentlyAskedQuestionInterface->getQuestion(); - } - - public function setQuestion(?string $question): void - { - /** @var FrequentlyAskedQuestionInterface $frequentlyAskedQuestionInterface */ - $frequentlyAskedQuestionInterface = $this->getFrequentlyAskedQuestionTranslation(); - $frequentlyAskedQuestionInterface->setQuestion($question); - } - - public function getAnswer(): ?string - { - /** @var FrequentlyAskedQuestionInterface $frequentlyAskedQuestionInterface */ - $frequentlyAskedQuestionInterface = $this->getFrequentlyAskedQuestionTranslation(); - - return $frequentlyAskedQuestionInterface->getAnswer(); - } - - public function setAnswer(?string $answer): void - { - /** @var FrequentlyAskedQuestionInterface $frequentlyAskedQuestionInterface */ - $frequentlyAskedQuestionInterface = $this->getFrequentlyAskedQuestionTranslation(); - $frequentlyAskedQuestionInterface->setAnswer($answer); - } - - /** - * @return TranslationInterface|FrequentlyAskedQuestionTranslationInterface - */ - protected function getFrequentlyAskedQuestionTranslation(): TranslationInterface - { - return $this->getTranslation(); - } - - protected function createTranslation(): TranslationInterface - { - return new FrequentlyAskedQuestionTranslation(); - } -} diff --git a/src/Entity/FrequentlyAskedQuestionInterface.php b/src/Entity/FrequentlyAskedQuestionInterface.php deleted file mode 100755 index 6c7abfd6a..000000000 --- a/src/Entity/FrequentlyAskedQuestionInterface.php +++ /dev/null @@ -1,39 +0,0 @@ -id; - } - - public function getQuestion(): ?string - { - return $this->question; - } - - public function setQuestion(string $question): void - { - $this->question = $question; - } - - public function getAnswer(): ?string - { - return $this->answer; - } - - public function setAnswer(string $answer): void - { - $this->answer = $answer; - } -} diff --git a/src/Entity/FrequentlyAskedQuestionTranslationInterface.php b/src/Entity/FrequentlyAskedQuestionTranslationInterface.php deleted file mode 100755 index 147327483..000000000 --- a/src/Entity/FrequentlyAskedQuestionTranslationInterface.php +++ /dev/null @@ -1,25 +0,0 @@ -initializeTranslationsCollection(); - $this->initializeSectionsCollection(); - $this->initializeProductsCollection(); + $this->initializeCollectionsCollection(); $this->initializeChannelsCollection(); } @@ -90,6 +78,16 @@ public function setCode(?string $code): void $this->code = $code; } + public function getName(): ?string + { + return $this->name; + } + + public function setName(?string $name): void + { + $this->name = $name; + } + public function getPath(): ?string { return $this->path; @@ -125,21 +123,6 @@ public function setMimeType(?string $mimeType): void $this->mimeType = $mimeType; } - public function getName(): ?string - { - /** @var MediaTranslationInterface $mediaTranslationInterface */ - $mediaTranslationInterface = $this->getMediaTranslation(); - - return $mediaTranslationInterface->getName(); - } - - public function setName(?string $name): void - { - /** @var MediaTranslationInterface $mediaTranslationInterface */ - $mediaTranslationInterface = $this->getMediaTranslation(); - $mediaTranslationInterface->setName($name); - } - public function getDownloadName(): string { return FilenameHelper::removeSlashes($this->getName() ?? $this->getCode() ?? self::DEFAULT_DOWNLOAD_NAME); @@ -220,9 +203,6 @@ public function setSaveWithOriginalName(bool $saveWithOriginalName): void $this->saveWithOriginalName = $saveWithOriginalName; } - /** - * @return MediaTranslationInterface|TranslationInterface - */ protected function getMediaTranslation(): TranslationInterface { return $this->getTranslation(); diff --git a/src/Entity/MediaCollectionInterface.php b/src/Entity/MediaCollectionInterface.php new file mode 100644 index 000000000..55344601a --- /dev/null +++ b/src/Entity/MediaCollectionInterface.php @@ -0,0 +1,20 @@ +id; } - public function getName(): ?string - { - return $this->name; - } - - public function setName(?string $name): void - { - $this->name = $name; - } - public function getContent(): ?string { return $this->content; diff --git a/src/Entity/MediaTranslationInterface.php b/src/Entity/MediaTranslationInterface.php index 4b5c8a8b8..9163045d3 100755 --- a/src/Entity/MediaTranslationInterface.php +++ b/src/Entity/MediaTranslationInterface.php @@ -1,24 +1,14 @@ initializeProductsCollection(); - $this->initializeSectionsCollection(); - $this->initializeTranslationsCollection(); + $this->initializeCollectionsCollection(); $this->initializeChannelsCollection(); + $this->initializeTranslationsCollection(); + $this->initializeContentElementsCollection(); $this->createdAt = new \DateTime(); } @@ -110,94 +108,69 @@ public function setMetaDescription(?string $metaDescription): void $pageTranslationInterface->setMetaDescription($metaDescription); } - public function getContent(): ?string + public function getTeaserTitle(): ?string { /** @var PageTranslationInterface $pageTranslationInterface */ $pageTranslationInterface = $this->getPageTranslation(); - return $pageTranslationInterface->getContent(); + return $pageTranslationInterface->getTeaserTitle(); } - public function setContent(?string $content): void + public function setTeaserTitle(?string $teaserTitle): void { /** @var PageTranslationInterface $pageTranslationInterface */ $pageTranslationInterface = $this->getPageTranslation(); - $pageTranslationInterface->setContent($content); + $pageTranslationInterface->setTeaserTitle($teaserTitle); } - public function getName(): ?string + public function getTeaserContent(): ?string { /** @var PageTranslationInterface $pageTranslationInterface */ $pageTranslationInterface = $this->getPageTranslation(); - return $pageTranslationInterface->getName(); + return $pageTranslationInterface->getTeaserContent(); } - public function setName(?string $name): void + public function setTeaserContent(?string $teaserContent): void { /** @var PageTranslationInterface $pageTranslationInterface */ $pageTranslationInterface = $this->getPageTranslation(); - $pageTranslationInterface->setName($name); + $pageTranslationInterface->setTeaserContent($teaserContent); } - public function getNameWhenLinked(): ?string + public function getTeaserImage(): ?MediaInterface { /** @var PageTranslationInterface $pageTranslationInterface */ $pageTranslationInterface = $this->getPageTranslation(); - return $pageTranslationInterface->getNameWhenLinked(); + return $pageTranslationInterface->getTeaserImage(); } - public function setNameWhenLinked(?string $nameWhenLinked): void + public function setTeaserImage(?MediaInterface $teaserImage): void { /** @var PageTranslationInterface $pageTranslationInterface */ $pageTranslationInterface = $this->getPageTranslation(); - $pageTranslationInterface->setNameWhenLinked($nameWhenLinked); + $pageTranslationInterface->setTeaserImage($teaserImage); } - public function getDescriptionWhenLinked(): ?string - { - /** @var PageTranslationInterface $pageTranslationInterface */ - $pageTranslationInterface = $this->getPageTranslation(); - - return $pageTranslationInterface->getDescriptionWhenLinked(); - } - - public function setDescriptionWhenLinked(?string $descriptionWhenLinked): void - { - /** @var PageTranslationInterface $pageTranslationInterface */ - $pageTranslationInterface = $this->getPageTranslation(); - $pageTranslationInterface->setDescriptionWhenLinked($descriptionWhenLinked); - } - - public function getBreadcrumb(): ?string + public function getName(): ?string { - /** @var PageTranslationInterface $pageTranslationInterface */ - $pageTranslationInterface = $this->getPageTranslation(); - - return $pageTranslationInterface->getBreadcrumb(); + return $this->name; } - public function setBreadcrumb(?string $breadcrumb): void + public function setName(?string $name): void { - /** @var PageTranslationInterface $pageTranslationInterface */ - $pageTranslationInterface = $this->getPageTranslation(); - $pageTranslationInterface->setBreadcrumb($breadcrumb); + $this->name = $name; } - public function getImage(): ?MediaInterface + public function getTemplate(): ?string { - /** @var PageTranslationInterface $pageTranslationInterface */ - $pageTranslationInterface = $this->getPageTranslation(); - - return $pageTranslationInterface->getImage(); + return $this->template; } - public function setImage(?MediaInterface $image): void + public function setTemplate(?string $template): void { - /** @var PageTranslationInterface $pageTranslationInterface */ - $pageTranslationInterface = $this->getPageTranslation(); - $pageTranslationInterface->setImage($image); + $this->template = $template; } public function getTitle(): ?string @@ -215,26 +188,23 @@ public function setTitle(?string $title): void $pageTranslationInterface->setTitle($title); } - /** - * @return PageTranslationInterface|TranslationInterface - */ - protected function getPageTranslation(): TranslationInterface + public function getPublishAt(): ?\DateTimeImmutable { - return $this->getTranslation(); + return $this->publishAt; } - protected function createTranslation(): PageTranslationInterface + public function setPublishAt(?\DateTimeImmutable $publishAt): void { - return new PageTranslation(); + $this->publishAt = $publishAt; } - public function getPublishAt(): ?\DateTimeImmutable + protected function getPageTranslation(): TranslationInterface { - return $this->publishAt; + return $this->getTranslation(); } - public function setPublishAt(?\DateTimeImmutable $publishAt): void + protected function createTranslation(): PageTranslationInterface { - $this->publishAt = $publishAt; + return new PageTranslation(); } } diff --git a/src/Entity/PageInterface.php b/src/Entity/PageInterface.php index b57d01a2d..0998a65c6 100755 --- a/src/Entity/PageInterface.php +++ b/src/Entity/PageInterface.php @@ -1,14 +1,8 @@ id; } - public function getContent(): ?string - { - return $this->content; - } - - public function setContent(?string $content): void - { - $this->content = $content; - } - public function getSlug(): ?string { return $this->slug; @@ -72,56 +36,6 @@ public function setSlug(?string $slug): void $this->slug = $slug; } - public function getImage(): ?MediaInterface - { - return $this->image; - } - - public function setImage(?MediaInterface $image): void - { - $this->image = $image; - } - - public function getName(): ?string - { - return $this->name; - } - - public function setName(?string $name): void - { - $this->name = $name; - } - - public function getBreadcrumb(): ?string - { - return $this->breadcrumb; - } - - public function setBreadcrumb(?string $breadcrumb): void - { - $this->breadcrumb = $breadcrumb; - } - - public function getNameWhenLinked(): ?string - { - return $this->nameWhenLinked; - } - - public function setNameWhenLinked(?string $nameWhenLinked): void - { - $this->nameWhenLinked = $nameWhenLinked; - } - - public function getDescriptionWhenLinked(): ?string - { - return $this->descriptionWhenLinked; - } - - public function setDescriptionWhenLinked(?string $descriptionWhenLinked): void - { - $this->descriptionWhenLinked = $descriptionWhenLinked; - } - public function getMetaKeywords(): ?string { return $this->metaKeywords; diff --git a/src/Entity/PageTranslationInterface.php b/src/Entity/PageTranslationInterface.php index 6f7e43aea..0ab27d96c 100755 --- a/src/Entity/PageTranslationInterface.php +++ b/src/Entity/PageTranslationInterface.php @@ -1,44 +1,18 @@ initializeTranslationsCollection(); - } - - public function getId(): ?int - { - return $this->id; - } - - public function getCode(): ?string - { - return $this->code; - } - - public function setCode(?string $code): void - { - $this->code = $code; - } - - public function getName(): ?string - { - /** @var SectionTranslationInterface $sectionTranslationInterface */ - $sectionTranslationInterface = $this->getSectionTranslation(); - - return $sectionTranslationInterface->getName(); - } - - public function setName(?string $name): void - { - /** @var SectionTranslationInterface $sectionTranslationInterface */ - $sectionTranslationInterface = $this->getSectionTranslation(); - $sectionTranslationInterface->setName($name); - } - - /** - * @return TranslationInterface|SectionTranslationInterface - */ - protected function getSectionTranslation(): TranslationInterface - { - return $this->getTranslation(); - } - - protected function createTranslation(): TranslationInterface - { - return new SectionTranslation(); - } -} diff --git a/src/Entity/SectionInterface.php b/src/Entity/SectionInterface.php deleted file mode 100755 index 80687bf2e..000000000 --- a/src/Entity/SectionInterface.php +++ /dev/null @@ -1,25 +0,0 @@ -id; - } - - public function getName(): ?string - { - return $this->name; - } - - public function setName(?string $name): void - { - $this->name = $name; - } -} diff --git a/src/Entity/SectionTranslationInterface.php b/src/Entity/SectionTranslationInterface.php deleted file mode 100755 index eb9bdb6ba..000000000 --- a/src/Entity/SectionTranslationInterface.php +++ /dev/null @@ -1,21 +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/Entity/TaxonAwareInterface.php b/src/Entity/TaxonAwareInterface.php index 6dcea88ca..b05318a75 100755 --- a/src/Entity/TaxonAwareInterface.php +++ b/src/Entity/TaxonAwareInterface.php @@ -1,14 +1,8 @@ id; + } + + public function getName(): ?string + { + return $this->name; + } + + public function setName(?string $name): void + { + $this->name = $name; + } + + public function getType(): ?string + { + return $this->type; + } + + public function setType(?string $type): void + { + $this->type = $type; + } + + public function getContentElements(): array + { + return $this->contentElements; + } + + public function setContentElements(array $contentElements): void + { + $this->contentElements = $contentElements; + } +} diff --git a/src/Entity/TemplateInterface.php b/src/Entity/TemplateInterface.php new file mode 100644 index 000000000..f108e5877 --- /dev/null +++ b/src/Entity/TemplateInterface.php @@ -0,0 +1,22 @@ +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/ChannelsAwareTrait.php b/src/Entity/Trait/ChannelsAwareTrait.php similarity index 55% rename from src/Entity/ChannelsAwareTrait.php rename to src/Entity/Trait/ChannelsAwareTrait.php index 0a9bb55eb..91810fe76 100755 --- a/src/Entity/ChannelsAwareTrait.php +++ b/src/Entity/Trait/ChannelsAwareTrait.php @@ -1,20 +1,8 @@ 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); + + /** @phpstan-var Block|Page|Media $this */ + if ($this instanceof PageInterface) { + $collection->addPage($this); + } elseif ($this instanceof BlockInterface) { + $collection->addBlock($this); + } elseif ($this instanceof MediaInterface) { + $collection->addMedium($this); + } + } + } + + public function removeCollection(CollectionInterface $collection): void + { + if (true === $this->hasCollection($collection)) { + $this->collections->removeElement($collection); + /** @phpstan-var Block|Page|Media $this */ + if ($this instanceof PageInterface) { + $collection->removePage($this); + } elseif ($this instanceof BlockInterface) { + $collection->removeBlock($this); + } elseif ($this instanceof MediaInterface) { + $collection->removeMedium($this); + } + } + } +} diff --git a/src/Entity/Trait/ContentElementsAwareTrait.php b/src/Entity/Trait/ContentElementsAwareTrait.php new file mode 100644 index 000000000..103dcfcc8 --- /dev/null +++ b/src/Entity/Trait/ContentElementsAwareTrait.php @@ -0,0 +1,62 @@ +contentElements = new ArrayCollection(); + } + + public function getContentElements(): Collection + { + return $this->contentElements; + } + + public function hasContentElement(ContentConfigurationInterface $contentElement): bool + { + return $this->contentElements->contains($contentElement); + } + + public function addContentElement(ContentConfigurationInterface $contentElement): void + { + if (!$this->hasContentElement($contentElement)) { + /** @phpstan-var Block|Page $this */ + if ($this instanceof Block) { + $contentElement->setBlock($this); + } elseif ($this instanceof Page) { + $contentElement->setPage($this); + } + + $this->contentElements->add($contentElement); + } + } + + public function removeContentElement(ContentConfigurationInterface $contentElement): void + { + if ($this->hasContentElement($contentElement)) { + $this->contentElements->removeElement($contentElement); + + /** @phpstan-var Block|Page $this */ + if ($this instanceof Block) { + $contentElement->setBlock(null); + } elseif ($this instanceof Page) { + $contentElement->setPage(null); + } + } + } +} diff --git a/src/Entity/Trait/LocaleAwareTrait.php b/src/Entity/Trait/LocaleAwareTrait.php new file mode 100644 index 000000000..61553fc1d --- /dev/null +++ b/src/Entity/Trait/LocaleAwareTrait.php @@ -0,0 +1,43 @@ +locales = new ArrayCollection(); + } + + public function getLocales(): Collection + { + return $this->locales; + } + + public function hasLocale(LocaleInterface $locale): bool + { + return $this->locales->contains($locale); + } + + public function addLocale(LocaleInterface $locale): void + { + if (!$this->hasLocale($locale)) { + $this->locales->add($locale); + } + } + + public function removeLocale(LocaleInterface $locale): void + { + if ($this->hasLocale($locale)) { + $this->locales->removeElement($locale); + } + } +} diff --git a/src/Entity/Trait/MediaCollectionTrait.php b/src/Entity/Trait/MediaCollectionTrait.php new file mode 100644 index 000000000..78134a2ea --- /dev/null +++ b/src/Entity/Trait/MediaCollectionTrait.php @@ -0,0 +1,43 @@ +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/Trait/PagesCollectionTrait.php b/src/Entity/Trait/PagesCollectionTrait.php new file mode 100644 index 000000000..ab3c90e22 --- /dev/null +++ b/src/Entity/Trait/PagesCollectionTrait.php @@ -0,0 +1,43 @@ +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/ProductsAwareTrait.php b/src/Entity/Trait/ProductsAwareTrait.php similarity index 68% rename from src/Entity/ProductsAwareTrait.php rename to src/Entity/Trait/ProductsAwareTrait.php index 7b783ccc3..7fd5408a2 100755 --- a/src/Entity/ProductsAwareTrait.php +++ b/src/Entity/Trait/ProductsAwareTrait.php @@ -1,14 +1,8 @@ products->removeElement($product); } } + + public function canBeDisplayedForProduct(ProductInterface $product): bool + { + return $this->hasProduct($product); + } } diff --git a/src/Entity/Trait/ProductsInTaxonsAwareTrait.php b/src/Entity/Trait/ProductsInTaxonsAwareTrait.php new file mode 100644 index 000000000..8be07cdb2 --- /dev/null +++ b/src/Entity/Trait/ProductsInTaxonsAwareTrait.php @@ -0,0 +1,54 @@ +productsInTaxons = new ArrayCollection(); + } + + public function getProductsInTaxons(): Collection + { + return $this->productsInTaxons; + } + + public function hasProductsInTaxon(TaxonInterface $taxon): bool + { + return $this->productsInTaxons->contains($taxon); + } + + public function addProductsInTaxon(TaxonInterface $taxon): void + { + if (false === $this->hasProductsInTaxon($taxon)) { + $this->productsInTaxons->add($taxon); + } + } + + public function removeProductsInTaxon(TaxonInterface $taxon): void + { + if (true === $this->hasProductsInTaxon($taxon)) { + $this->productsInTaxons->removeElement($taxon); + } + } + + public function canBeDisplayedForProductInTaxon(ProductInterface $product): bool + { + $taxon = $product->getMainTaxon(); + if (null === $taxon) { + return false; + } + + return $this->hasProductsInTaxon($taxon); + } +} diff --git a/src/Entity/TaxonAwareTrait.php b/src/Entity/Trait/TaxonAwareTrait.php similarity index 50% rename from src/Entity/TaxonAwareTrait.php rename to src/Entity/Trait/TaxonAwareTrait.php index 0da155fce..c4ca3c49d 100644 --- a/src/Entity/TaxonAwareTrait.php +++ b/src/Entity/Trait/TaxonAwareTrait.php @@ -1,14 +1,8 @@ taxonomies = new ArrayCollection(); + $this->taxons = new ArrayCollection(); } public function getTaxons(): Collection { - return $this->taxonomies; + return $this->taxons; } public function hasTaxon(TaxonInterface $taxon): bool { - return $this->taxonomies->contains($taxon); + return $this->taxons->contains($taxon); } public function addTaxon(TaxonInterface $taxon): void { if (false === $this->hasTaxon($taxon)) { - $this->taxonomies->add($taxon); + $this->taxons->add($taxon); } } public function removeTaxon(TaxonInterface $taxon): void { if (true === $this->hasTaxon($taxon)) { - $this->taxonomies->removeElement($taxon); + $this->taxons->removeElement($taxon); } } + + public function canBeDisplayedForTaxon(TaxonInterface $taxon): bool + { + return $this->hasTaxon($taxon); + } } diff --git a/src/Entity/Trait/TeaserTrait.php b/src/Entity/Trait/TeaserTrait.php new file mode 100644 index 000000000..69f556c8d --- /dev/null +++ b/src/Entity/Trait/TeaserTrait.php @@ -0,0 +1,46 @@ +teaserTitle; + } + + public function setTeaserTitle(?string $teaserTitle): void + { + $this->teaserTitle = $teaserTitle; + } + + public function getTeaserContent(): ?string + { + return $this->teaserContent; + } + + public function setTeaserContent(?string $teaserContent): void + { + $this->teaserContent = $teaserContent; + } + + public function getTeaserImage(): ?MediaInterface + { + return $this->teaserImage; + } + + public function setTeaserImage(?MediaInterface $teaserImage): void + { + $this->teaserImage = $teaserImage; + } +} diff --git a/src/EventListener/MediaUploadListener.php b/src/EventListener/MediaUploadListener.php index 0e1f5b4e7..f1e9d49f0 100755 --- a/src/EventListener/MediaUploadListener.php +++ b/src/EventListener/MediaUploadListener.php @@ -1,18 +1,12 @@ setLocale($locale ?? 'en_US'); + $contentConfiguration->setType('heading'); + $contentConfiguration->setConfiguration([ + 'heading_type' => $headingType ?? 'h1', + 'heading' => $headingContent, + ]); + + return $contentConfiguration; + } + + public static function createTextareaContentElement(?string $locale, ?string $content): ?ContentConfiguration + { + if (null === $content) { + return null; + } + + $contentConfiguration = new ContentConfiguration(); + $contentConfiguration->setLocale($locale ?? 'en_US'); + $contentConfiguration->setType('textarea'); + $contentConfiguration->setConfiguration([ + 'textarea' => $content, + ]); + + return $contentConfiguration; + } + + public static function createProductsGridContentElement(?string $locale, ?string $codes): ?ContentConfiguration + { + if (null === $codes) { + return null; + } + + $productsCodes = explode(',', $codes); + $productsCodes = array_map(static function (string $element): string { + return trim($element); + }, $productsCodes); + + $contentConfiguration = new ContentConfiguration(); + $contentConfiguration->setLocale($locale ?? 'en_US'); + $contentConfiguration->setType('products_grid'); + $contentConfiguration->setConfiguration([ + 'products_grid' => [ + 'products' => $productsCodes, + ], + ]); + + return $contentConfiguration; + } + + public static function createSingleMediaContentElement(?string $locale, ?string $code): ?ContentConfiguration + { + if (null === $code) { + return null; + } + + $contentConfiguration = new ContentConfiguration(); + $contentConfiguration->setLocale($locale ?? 'en_US'); + $contentConfiguration->setType('single_media'); + $contentConfiguration->setConfiguration([ + 'single_media' => $code, + ]); + + return $contentConfiguration; + } +} diff --git a/src/Fixture/BlockFixture.php b/src/Fixture/BlockFixture.php index f4222a162..46ebb4bba 100755 --- a/src/Fixture/BlockFixture.php +++ b/src/Fixture/BlockFixture.php @@ -1,17 +1,11 @@ arrayPrototype() ->children() ->booleanNode('remove_existing')->defaultTrue()->end() - ->integerNode('number')->defaultNull()->end() - ->booleanNode('last_four_products')->defaultFalse()->end() + ->scalarNode('name')->end() ->booleanNode('enabled')->defaultTrue()->end() - ->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') + ->arrayNode('products')->scalarPrototype()->end()->end() + ->arrayNode('taxons')->scalarPrototype()->end()->end() + ->arrayNode('products_in_taxons')->scalarPrototype()->end()->end() + ->arrayNode('content_elements') + ->useAttributeAsKey('locale') ->arrayPrototype() - ->children() - ->scalarNode('name')->defaultNull()->end() - ->scalarNode('content')->defaultNull()->end() - ->scalarNode('link')->defaultNull()->end() - ->scalarNode('image_path')->defaultNull()->end() + ->useAttributeAsKey('key') + ->arrayPrototype() + ->children() + ->scalarNode('type')->end() + ->arrayNode('data') + ->children() + ->scalarNode('heading_type')->end() + ->scalarNode('heading')->end() + ->scalarNode('textarea')->end() + ->scalarNode('single_media')->end() + ->scalarNode('products_carousel_by_taxon')->end() + ->scalarNode('products_grid_by_taxon')->end() + ->scalarNode('pages_collection')->end() + ->scalarNode('spacer')->end() + ->arrayNode('multiple_media')->scalarPrototype()->end()->end() + ->arrayNode('products_grid') + ->children() + ->arrayNode('products')->scalarPrototype()->end()->end() + ->end() + ->end() + ->arrayNode('products_carousel') + ->children() + ->arrayNode('products')->scalarPrototype()->end()->end() + ->end() + ->end() + ->arrayNode('taxons_list') + ->children() + ->arrayNode('taxons')->scalarPrototype()->end()->end() + ->end() + ->end() + ->end() + ->end() + ->end() ->end() ->end() ->end() diff --git a/src/Fixture/CollectionFixture.php b/src/Fixture/CollectionFixture.php new file mode 100755 index 000000000..907e3544a --- /dev/null +++ b/src/Fixture/CollectionFixture.php @@ -0,0 +1,44 @@ +collectionFixtureFactory->load($options['custom']); + } + + public function getName(): string + { + return 'collection'; + } + + protected function configureOptionsNode(ArrayNodeDefinition $optionsNode): void + { + $optionsNode + ->children() + ->arrayNode('custom') + ->arrayPrototype() + ->children() + ->booleanNode('remove_existing')->defaultTrue()->end() + ->node('name', 'scalar')->end() + ->node('type', 'scalar')->end() + ->arrayNode('page_codes')->scalarPrototype()->end() + ->end() + ->end() + ->end() + ->end() + ; + } +} diff --git a/src/Fixture/Factory/BlockFixtureFactory.php b/src/Fixture/Factory/BlockFixtureFactory.php index 7c8115877..93f09ed73 100755 --- a/src/Fixture/Factory/BlockFixtureFactory.php +++ b/src/Fixture/Factory/BlockFixtureFactory.php @@ -1,41 +1,29 @@ blockRepository->remove($block); } - if (null !== $fields['number']) { - for ($i = 0; $i < $fields['number']; ++$i) { - $this->createBlock(md5(uniqid()), $fields); - } - } else { - $this->createBlock($code, $fields); - } + $this->createBlock($code, $fields); } } @@ -66,44 +48,31 @@ private function createBlock(string $code, array $blockData): void /** @var BlockInterface $block */ $block = $this->blockFactory->createNew(); - $products = $blockData['products']; - if (null !== $products) { - $this->resolveProducts($block, $products); - } - - $this->sectionsAssigner->assign($block, $blockData['sections']); - $this->productsAssigner->assign($block, $blockData['productCodes']); - $this->taxonsAssigner->assign($block, $blockData['taxons']); - $this->channelAssigner->assign($block, $blockData['channels']); - $block->setCode($code); + $block->setName($blockData['name']); $block->setEnabled($blockData['enabled']); - foreach ($blockData['translations'] as $localeCode => $translation) { - /** @var BlockTranslationInterface $blockTranslation */ - $blockTranslation = $this->blockTranslationFactory->createNew(); + $this->collectionsAssigner->assign($block, $blockData['collections']); + $this->channelAssigner->assign($block, $blockData['channels']); + $this->productsAssigner->assign($block, $blockData['products']); + $this->taxonsAssigner->assign($block, $blockData['taxons']); + $this->productsInTaxonsAssigner->assign($block, $blockData['products_in_taxons']); - $blockTranslation->setLocale($localeCode); - $blockTranslation->setName($translation['name']); - $blockTranslation->setContent($translation['content']); - $blockTranslation->setLink($translation['link']); - $block->addTranslation($blockTranslation); + foreach ($blockData['content_elements'] as $locale => $data) { + foreach ($data as $contentElementData) { + $contentElementData['data'] = array_filter($contentElementData['data'], static function ($value) { + return !empty($value); + }); + + $contentConfiguration = new ContentConfiguration(); + $contentConfiguration->setType($contentElementData['type']); + $contentConfiguration->setConfiguration($contentElementData['data']); + $contentConfiguration->setLocale($locale); + $contentConfiguration->setBlock($block); + $block->addContentElement($contentConfiguration); + } } $this->blockRepository->add($block); } - - private function resolveProducts(BlockInterface $block, int $limit): void - { - /** @var ChannelInterface $channel */ - $channel = $this->channelContext->getChannel(); - $products = $this->productRepository->findLatestByChannel( - $channel, - $this->localeContext->getLocaleCode(), - $limit, - ); - foreach ($products as $product) { - $block->addProduct($product); - } - } } diff --git a/src/Fixture/Factory/CollectionFixtureFactory.php b/src/Fixture/Factory/CollectionFixtureFactory.php new file mode 100755 index 000000000..48e7605bb --- /dev/null +++ b/src/Fixture/Factory/CollectionFixtureFactory.php @@ -0,0 +1,51 @@ + $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); + $collection->setName($fields['name']); + $collection->setType($fields['type']); + + foreach ($fields['page_codes'] as $pageCode) { + /** @var PageInterface|null $page */ + $page = $this->pageRepository->findOneBy(['code' => $pageCode]); + if ($page) { + $collection->addPage($page); + } + } + + $this->collectionRepository->add($collection); + } + } +} diff --git a/src/Fixture/Factory/FixtureFactoryInterface.php b/src/Fixture/Factory/FixtureFactoryInterface.php index 4c29d5dd5..be0d66215 100755 --- a/src/Fixture/Factory/FixtureFactoryInterface.php +++ b/src/Fixture/Factory/FixtureFactoryInterface.php @@ -1,14 +1,8 @@ $fields) { - /** @var ?FrequentlyAskedQuestionInterface $frequentlyAskedQuestion */ - $frequentlyAskedQuestion = $this->frequentlyAskedQuestionRepository->findOneBy(['code' => $code]); - if ( - true === $fields['remove_existing'] && - null !== $frequentlyAskedQuestion - ) { - $this->frequentlyAskedQuestionRepository->remove($frequentlyAskedQuestion); - } - - if (null !== $fields['number']) { - for ($i = 1; $i <= $fields['number']; ++$i) { - $this->createFrequentlyAskedQuestion(md5(uniqid()), $fields, $i); - } - } else { - $this->createFrequentlyAskedQuestion($code, $fields, $fields['position']); - } - } - } - - private function createFrequentlyAskedQuestion( - string $code, - array $frequentlyAskedQuestionData, - int $position, - ): void { - /** @var FrequentlyAskedQuestionInterface $frequentlyAskedQuestion */ - $frequentlyAskedQuestion = $this->frequentlyAskedQuestionFactory->createNew(); - - $frequentlyAskedQuestion->setCode($code); - $frequentlyAskedQuestion->setEnabled($frequentlyAskedQuestionData['enabled']); - $frequentlyAskedQuestion->setPosition($position); - - $this->channelAssigner->assign($frequentlyAskedQuestion, $frequentlyAskedQuestionData['channels']); - - foreach ($frequentlyAskedQuestionData['translations'] as $localeCode => $translation) { - /** @var FrequentlyAskedQuestionTranslationInterface $frequentlyAskedQuestionTranslation */ - $frequentlyAskedQuestionTranslation = $this->frequentlyAskedQuestionTranslationFactory->createNew(); - - $frequentlyAskedQuestionTranslation->setLocale($localeCode); - $frequentlyAskedQuestionTranslation->setQuestion($translation['question']); - $frequentlyAskedQuestionTranslation->setAnswer($translation['answer']); - - $frequentlyAskedQuestion->addTranslation($frequentlyAskedQuestionTranslation); - } - - $this->frequentlyAskedQuestionRepository->add($frequentlyAskedQuestion); - } -} diff --git a/src/Fixture/Factory/MediaFixtureFactory.php b/src/Fixture/Factory/MediaFixtureFactory.php index 153c44c0f..1df89c69a 100644 --- a/src/Fixture/Factory/MediaFixtureFactory.php +++ b/src/Fixture/Factory/MediaFixtureFactory.php @@ -1,22 +1,15 @@ mediaRepository->remove($media); } - if (null !== $fields['number']) { - for ($i = 0; $i < $fields['number']; ++$i) { - $this->createMedia(md5(uniqid()), $fields); - } - } else { - $this->createMedia($code, $fields); - } + $this->createMedia($code, $fields); } } @@ -61,6 +47,7 @@ private function createMedia(string $code, array $mediaData): void $media = $this->mediaFactory->createNew(); $media->setType($mediaData['type']); $media->setCode($code); + $media->setName($mediaData['name']); $media->setEnabled($mediaData['enabled']); $media->setFile(new UploadedFile($mediaData['path'], $mediaData['original_name'])); @@ -71,15 +58,13 @@ private function createMedia(string $code, array $mediaData): void $mediaTranslation = $this->mediaTranslationFactory->createNew(); $mediaTranslation->setLocale($localeCode); - $mediaTranslation->setName($translation['name']); $mediaTranslation->setContent($translation['content']); $mediaTranslation->setAlt($translation['alt']); $mediaTranslation->setLink($translation['link']); $media->addTranslation($mediaTranslation); } - $this->sectionsAssigner->assign($media, $mediaData['sections']); - $this->productsAssigner->assign($media, $mediaData['productCodes']); + $this->collectionsAssigner->assign($media, $mediaData['collections']); $this->channelAssigner->assign($media, $mediaData['channels']); $this->mediaRepository->add($media); diff --git a/src/Fixture/Factory/PageFixtureFactory.php b/src/Fixture/Factory/PageFixtureFactory.php index 3a6827fd3..946a4b633 100755 --- a/src/Fixture/Factory/PageFixtureFactory.php +++ b/src/Fixture/Factory/PageFixtureFactory.php @@ -1,47 +1,28 @@ pageRepository->remove($page); } - if (null !== $fields['number']) { - for ($i = 0; $i < $fields['number']; ++$i) { - $this->createPage(md5(uniqid()), $fields, true); - } - } else { - $this->createPage($code, $fields); - } + $this->createPage($code, $fields); } } private function createPage( string $code, array $pageData, - bool $generateSlug = false, ): void { /** @var PageInterface $page */ $page = $this->pageFactory->createNew(); - $products = $pageData['products']; - $channelsCodes = $pageData['channels']; - if (null !== $products) { - $this->resolveProductsForChannels($page, $products, $channelsCodes); - } - $this->sectionsAssigner->assign($page, $pageData['sections']); - $this->productsAssigner->assign($page, $pageData['productCodes']); - $this->channelAssigner->assign($page, $channelsCodes); + $this->collectionsAssigner->assign($page, $pageData['collections']); + $this->channelAssigner->assign($page, $pageData['channels']); $page->setCode($code); + $page->setName($pageData['name']); $page->setEnabled($pageData['enabled']); foreach ($pageData['translations'] as $localeCode => $translation) { /** @var PageTranslationInterface $pageTranslation */ $pageTranslation = $this->pageTranslationFactory->createNew(); - $slug = true === $generateSlug ? md5(uniqid()) : $translation['slug']; + $slug = $translation['slug'] ?? md5(uniqid('', true)); $pageTranslation->setLocale($localeCode); $pageTranslation->setSlug($slug); - $pageTranslation->setName($translation['name']); - $pageTranslation->setNameWhenLinked($translation['name_when_linked']); - $pageTranslation->setDescriptionWhenLinked($translation['description_when_linked']); + $pageTranslation->setTitle($translation['meta_title']); $pageTranslation->setMetaKeywords($translation['meta_keywords']); $pageTranslation->setMetaDescription($translation['meta_description']); - $pageTranslation->setContent($translation['content']); + $pageTranslation->setTeaserTitle($translation['teaser_title']); + $pageTranslation->setTeaserContent($translation['teaser_content']); - if ($translation['image_path']) { - $image = new Media(); - $path = $translation['image_path']; - $uploadedImage = new UploadedFile($path, md5($path) . '.jpg'); - - $image->setFile($uploadedImage); - $image->setCode(md5(uniqid())); - $image->setType(MediaInterface::IMAGE_TYPE); - $pageTranslation->setImage($image); - - $this->mediaProviderResolver->resolveProvider($image)->upload($image); + /** @var MediaInterface|null $mediaImage */ + $mediaImage = $this->mediaRepository->findOneBy(['code' => $translation['teaser_image']]); + if ($mediaImage) { + $pageTranslation->setTeaserImage($mediaImage); } $page->addTranslation($pageTranslation); } - $this->pageRepository->add($page); - } - - private function resolveProductsForChannels( - PageInterface $page, - int $limit, - array $channelCodes, - ): void { - foreach ($channelCodes as $channelCode) { - /** @var ChannelInterface|null $channel */ - $channel = $this->channelRepository->findOneByCode($channelCode); - Assert::notNull($channel, sprintf(self::CHANNEL_WITH_CODE_NOT_FOUND_MESSAGE, $channelCode)); - - $this->resolveProductsForChannel($page, $limit, $channel); + foreach ($pageData['content_elements'] as $locale => $data) { + foreach ($data as $contentElementData) { + $contentElementData['data'] = array_filter($contentElementData['data'], static function ($value) { + return !empty($value); + }); + + $contentConfiguration = new ContentConfiguration(); + $contentConfiguration->setType($contentElementData['type']); + $contentConfiguration->setConfiguration($contentElementData['data']); + $contentConfiguration->setLocale($locale); + $contentConfiguration->setPage($page); + $page->addContentElement($contentConfiguration); + } } - } - private function resolveProductsForChannel( - PageInterface $page, - int $limit, - ChannelInterface $channel, - ): void { - $products = $this->productRepository->findLatestByChannel( - $channel, - $this->localeContext->getLocaleCode(), - $limit, - ); - - foreach ($products as $product) { - $page->addProduct($product); - } + $this->pageRepository->add($page); } } 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/Factory/TemplateFixtureFactory.php b/src/Fixture/Factory/TemplateFixtureFactory.php new file mode 100755 index 000000000..4a9bbd051 --- /dev/null +++ b/src/Fixture/Factory/TemplateFixtureFactory.php @@ -0,0 +1,46 @@ +templateRepository->findOneBy(['name' => $fields['name']]); + if ( + true === $fields['remove_existing'] && + null !== $template + ) { + $this->templateRepository->remove($template); + } + + $this->createPage($fields); + } + } + + private function createPage(array $pageData): void + { + /** @var TemplateInterface $template */ + $template = $this->templateFactory->createNew(); + + $template->setName($pageData['name']); + $template->setType($pageData['type']); + $template->setContentElements($pageData['content_elements']); + + $this->templateRepository->add($template); + } +} diff --git a/src/Fixture/FrequentlyAskedQuestionFixture.php b/src/Fixture/FrequentlyAskedQuestionFixture.php deleted file mode 100755 index 1daabc69f..000000000 --- a/src/Fixture/FrequentlyAskedQuestionFixture.php +++ /dev/null @@ -1,59 +0,0 @@ -frequentlyAskedQuestionFixtureFactory->load($options['custom']); - } - - public function getName(): string - { - return 'frequently_asked_question'; - } - - protected function configureOptionsNode(ArrayNodeDefinition $optionsNode): void - { - $optionsNode - ->children() - ->arrayNode('custom') - ->arrayPrototype() - ->children() - ->booleanNode('remove_existing')->defaultTrue()->end() - ->integerNode('number')->defaultNull()->end() - ->booleanNode('enabled')->defaultTrue()->end() - ->integerNode('position')->defaultNull()->end() - ->arrayNode('channels')->scalarPrototype()->end()->end() - ->arrayNode('translations') - ->arrayPrototype() - ->children() - ->scalarNode('question')->defaultNull()->end() - ->scalarNode('answer')->defaultNull()->end() - ->end() - ->end() - ->end() - ->end() - ->end() - ->end() - ->end() - ; - } -} diff --git a/src/Fixture/MediaFixture.php b/src/Fixture/MediaFixture.php index 4e6d23e02..acbb83cc4 100644 --- a/src/Fixture/MediaFixture.php +++ b/src/Fixture/MediaFixture.php @@ -1,17 +1,11 @@ arrayPrototype() ->children() ->booleanNode('remove_existing')->defaultTrue()->end() - ->integerNode('number')->defaultNull()->end() ->scalarNode('type')->isRequired()->cannotBeEmpty()->end() ->scalarNode('path')->isRequired()->cannotBeEmpty()->end() ->scalarNode('original_name')->isRequired()->cannotBeEmpty()->end() + ->scalarNode('name')->defaultNull()->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() ->children() - ->scalarNode('name')->defaultNull()->end() ->scalarNode('content')->defaultNull()->end() ->scalarNode('alt')->defaultNull()->end() ->scalarNode('link')->defaultNull()->end() diff --git a/src/Fixture/PageFixture.php b/src/Fixture/PageFixture.php index cdd6c5546..9d331b02a 100755 --- a/src/Fixture/PageFixture.php +++ b/src/Fixture/PageFixture.php @@ -1,17 +1,11 @@ arrayPrototype() ->children() ->booleanNode('remove_existing')->defaultTrue()->end() - ->integerNode('number')->defaultNull()->end() ->booleanNode('enabled')->defaultTrue()->end() - ->integerNode('products')->defaultNull()->end() - ->arrayNode('productCodes')->scalarPrototype()->end()->end() - ->arrayNode('sections')->scalarPrototype()->end()->end() + ->scalarNode('name')->end() + ->arrayNode('collections')->scalarPrototype()->end()->end() ->arrayNode('channels')->scalarPrototype()->end()->end() ->arrayNode('translations') ->prototype('array') ->children() ->scalarNode('slug')->defaultNull()->end() - ->scalarNode('name')->defaultNull()->end() - ->scalarNode('name_when_linked')->defaultNull()->end() - ->scalarNode('description_when_linked')->defaultNull()->end() - ->scalarNode('image_path')->defaultNull()->end() + ->scalarNode('meta_title')->defaultNull()->end() ->scalarNode('meta_keywords')->defaultNull()->end() ->scalarNode('meta_description')->defaultNull()->end() - ->scalarNode('content')->defaultNull()->end() + ->scalarNode('teaser_title')->defaultNull()->end() + ->scalarNode('teaser_content')->defaultNull()->end() + ->scalarNode('teaser_image')->defaultNull()->end() + ->end() + ->end() + ->end() + ->arrayNode('content_elements') + ->useAttributeAsKey('locale') + ->arrayPrototype() + ->useAttributeAsKey('key') + ->arrayPrototype() + ->children() + ->scalarNode('type')->end() + ->arrayNode('data') + ->children() + ->scalarNode('heading_type')->end() + ->scalarNode('heading')->end() + ->scalarNode('textarea')->end() + ->scalarNode('single_media')->end() + ->scalarNode('products_carousel_by_taxon')->end() + ->scalarNode('products_grid_by_taxon')->end() + ->scalarNode('pages_collection')->end() + ->scalarNode('spacer')->end() + ->arrayNode('multiple_media')->scalarPrototype()->end()->end() + ->arrayNode('products_grid') + ->children() + ->arrayNode('products')->scalarPrototype()->end()->end() + ->end() + ->end() + ->arrayNode('products_carousel') + ->children() + ->arrayNode('products')->scalarPrototype()->end()->end() + ->end() + ->end() + ->arrayNode('taxons_list') + ->children() + ->arrayNode('taxons')->scalarPrototype()->end()->end() + ->end() + ->end() + ->end() + ->end() + ->end() ->end() ->end() ->end() diff --git a/src/Fixture/SectionFixture.php b/src/Fixture/TemplateFixture.php similarity index 52% rename from src/Fixture/SectionFixture.php rename to src/Fixture/TemplateFixture.php index 3c4e45c23..056895bb0 100755 --- a/src/Fixture/SectionFixture.php +++ b/src/Fixture/TemplateFixture.php @@ -1,33 +1,27 @@ sectionFixtureFactory->load($options['custom']); + $this->templateFixtureFactory->load($options['custom']); } public function getName(): string { - return 'section'; + return 'template'; } protected function configureOptionsNode(ArrayNodeDefinition $optionsNode): void @@ -38,10 +32,12 @@ protected function configureOptionsNode(ArrayNodeDefinition $optionsNode): void ->arrayPrototype() ->children() ->booleanNode('remove_existing')->defaultTrue()->end() - ->arrayNode('translations') - ->prototype('array') + ->scalarNode('name')->end() + ->scalarNode('type')->end() + ->arrayNode('content_elements') + ->arrayPrototype() ->children() - ->scalarNode('name')->defaultNull()->end() + ->scalarNode('type')->end() ->end() ->end() ->end() diff --git a/src/Form/DataTransformer/ContentElementDataTransformerChecker.php b/src/Form/DataTransformer/ContentElementDataTransformerChecker.php new file mode 100644 index 000000000..d9e4eb95f --- /dev/null +++ b/src/Form/DataTransformer/ContentElementDataTransformerChecker.php @@ -0,0 +1,26 @@ +addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use ($repository, $field): void { + $data = $event->getData(); + $code = $data[$field] ?? null; + $entity = $repository->findOneBy(['code' => $code]); + if (null === $entity) { + $data[$field] = null; + $event->setData($data); + } + }); + } +} diff --git a/src/Form/DataTransformer/MultipleMediaToCodesTransformer.php b/src/Form/DataTransformer/MultipleMediaToCodesTransformer.php new file mode 100644 index 000000000..5ce607c71 --- /dev/null +++ b/src/Form/DataTransformer/MultipleMediaToCodesTransformer.php @@ -0,0 +1,44 @@ +mediaRepository->findBy(['code' => $value])); + } + + public function reverseTransform($value): array + { + Assert::isInstanceOf($value, Collection::class); + + $mediaCodes = []; + + /** @var MediaInterface $media */ + foreach ($value as $media) { + $mediaCodes[] = $media->getCode(); + } + + return $mediaCodes; + } +} diff --git a/src/Form/Type/AbstractTemplateAutocompleteChoiceType.php b/src/Form/Type/AbstractTemplateAutocompleteChoiceType.php new file mode 100644 index 000000000..cafa2f8c9 --- /dev/null +++ b/src/Form/Type/AbstractTemplateAutocompleteChoiceType.php @@ -0,0 +1,37 @@ +setDefaults([ + 'resource' => 'sylius_cms.template', + 'choice_name' => 'name', + 'choice_value' => 'id', + ]); + } + + public function buildView( + FormView $view, + FormInterface $form, + array $options, + ): void { + $view->vars['remote_criteria_type'] = 'contains'; + $view->vars['remote_criteria_name'] = 'phrase'; + } + + public function getParent(): string + { + return ResourceAutocompleteChoiceType::class; + } +} diff --git a/src/Form/Type/SectionAutocompleteChoiceType.php b/src/Form/Type/BlockAutocompleteChoiceType.php old mode 100755 new mode 100644 similarity index 62% rename from src/Form/Type/SectionAutocompleteChoiceType.php rename to src/Form/Type/BlockAutocompleteChoiceType.php index ec57d6918..3dc7139a7 --- a/src/Form/Type/SectionAutocompleteChoiceType.php +++ b/src/Form/Type/BlockAutocompleteChoiceType.php @@ -1,14 +1,8 @@ setDefaults([ - 'resource' => 'bitbag_sylius_cms_plugin.section', + 'resource' => 'sylius_cms.block', 'choice_name' => 'name', 'choice_value' => 'code', ]); @@ -38,7 +32,7 @@ public function buildView( public function getBlockPrefix(): string { - return 'bitbag_section_autocomplete_choice'; + return 'sylius_block_autocomplete_choice'; } public function getParent(): string diff --git a/src/Form/Type/BlockImageType.php b/src/Form/Type/BlockImageType.php deleted file mode 100755 index 80e566eb9..000000000 --- a/src/Form/Type/BlockImageType.php +++ /dev/null @@ -1,21 +0,0 @@ -localeRepository->findAll(); + foreach ($locales as $locale) { + $this->locales[$locale->getName()] = $locale->getCode(); + } + } + public function buildForm(FormBuilderInterface $builder, array $options): void { /** @var BlockInterface $block */ @@ -31,41 +44,79 @@ public function buildForm(FormBuilderInterface $builder, array $options): void $builder ->add('code', TextType::class, [ - 'label' => 'bitbag_sylius_cms_plugin.ui.code', + 'label' => 'sylius_cms.ui.code', 'disabled' => null !== $block->getCode(), ]) - ->add('sections', SectionAutocompleteChoiceType::class, [ - 'label' => 'bitbag_sylius_cms_plugin.ui.sections', + ->add('name', TextType::class, [ + 'label' => 'sylius_cms.ui.name', + ]) + ->add('templates', ChoiceType::class, [ + 'label' => 'sylius_cms.ui.template', + 'choices' => $this->templateProvider->getBlockTemplates(), + 'mapped' => false, + ]) + ->add('collections', CollectionAutocompleteChoiceType::class, [ + 'label' => 'sylius_cms.ui.collections', 'multiple' => true, ]) ->add('enabled', CheckboxType::class, [ - 'label' => 'bitbag_sylius_cms_plugin.ui.enabled', + 'label' => 'sylius_cms.ui.enabled', + ]) + ->add('channels', ChannelChoiceType::class, [ + 'label' => 'sylius_cms.ui.channels', + 'required' => false, + 'multiple' => true, + 'expanded' => true, + ]) + ->add('contentElements', CollectionType::class, [ + 'label' => false, + 'entry_type' => ContentConfigurationType::class, + 'allow_add' => true, + 'allow_delete' => true, + 'by_reference' => false, + 'required' => false, + 'entry_options' => [ + 'label' => false, + ], + 'attr' => [ + 'class' => 'content-elements-container', + ], ]) ->add('products', ProductAutocompleteChoiceType::class, [ - 'label' => 'bitbag_sylius_cms_plugin.ui.products', + 'label' => 'sylius_cms.ui.display_for_products.label', 'multiple' => true, + 'help' => 'sylius_cms.ui.display_for_products.help', ]) - ->add('taxons', TaxonAutocompleteChoiceType::class, [ - 'label' => 'bitbag_sylius_cms_plugin.ui.taxons', + ->add('productsInTaxons', TaxonAutocompleteChoiceType::class, [ + 'label' => 'sylius_cms.ui.display_for_products_in_taxons.label', 'multiple' => true, + 'help' => 'sylius_cms.ui.display_for_products_in_taxons.help', ]) - ->add('channels', ChannelChoiceType::class, [ - 'label' => 'bitbag_sylius_cms_plugin.ui.channels', - 'required' => false, + ->add('taxons', TaxonAutocompleteChoiceType::class, [ + 'label' => 'sylius_cms.ui.display_for_taxons.label', 'multiple' => true, - 'expanded' => true, + 'help' => 'sylius_cms.ui.display_for_taxons.help', ]) - ->add('translations', ResourceTranslationsType::class, [ - 'label' => 'bitbag_sylius_cms_plugin.ui.contents', - 'entry_type' => BlockTranslationType::class, - 'validation_groups' => ['bitbag_content'], - 'constraints' => [new Valid()], + ->add('contentTemplate', TemplateBlockAutocompleteChoiceType::class, [ + 'label' => false, + 'mapped' => false, + ]) + ->add('locale', ChoiceType::class, [ + 'choices' => $this->locales, + 'mapped' => false, + 'label' => 'sylius.ui.locale', + 'attr' => [ + 'class' => 'locale-selector', + ], ]) ; + + PageType::addContentElementLocaleListener($builder); + PageType::addTemplateListener($builder); } public function getBlockPrefix(): string { - return 'bitbag_sylius_cms_plugin_block'; + return 'sylius_cms_block'; } } diff --git a/src/Form/Type/CollectionAutocompleteChoiceType.php b/src/Form/Type/CollectionAutocompleteChoiceType.php new file mode 100755 index 000000000..6d13254e9 --- /dev/null +++ b/src/Form/Type/CollectionAutocompleteChoiceType.php @@ -0,0 +1,42 @@ +setDefaults([ + 'resource' => 'sylius_cms.collection', + 'choice_name' => 'name', + 'choice_value' => 'code', + ]); + } + + public function buildView( + FormView $view, + FormInterface $form, + array $options, + ): void { + $view->vars['remote_criteria_type'] = 'contains'; + $view->vars['remote_criteria_name'] = 'phrase'; + } + + public function getBlockPrefix(): string + { + return 'sylius_collection_autocomplete_choice'; + } + + public function getParent(): string + { + return ResourceAutocompleteChoiceType::class; + } +} diff --git a/src/Form/Type/CollectionType.php b/src/Form/Type/CollectionType.php new file mode 100755 index 000000000..1a806737b --- /dev/null +++ b/src/Form/Type/CollectionType.php @@ -0,0 +1,77 @@ +add('code', TextType::class, [ + 'label' => 'sylius_cms.ui.code', + 'disabled' => null !== $builder->getData()->getCode(), + ]) + ->add('name', TextType::class, [ + 'label' => 'sylius_cms.ui.name', + ]) + ->add('type', ChoiceType::class, [ + 'label' => 'sylius_cms.ui.type', + 'choices' => [ + 'sylius_cms.ui.page' => self::PAGE, + 'sylius_cms.ui.block' => self::BLOCK, + 'sylius_cms.ui.media' => self::MEDIA, + ], + ]) + ->add('pages', PageAutocompleteChoiceType::class, [ + 'label' => 'sylius_cms.ui.pages', + 'multiple' => true, + ]) + ->add('blocks', BlockAutocompleteChoiceType::class, [ + 'label' => 'sylius_cms.ui.blocks', + 'multiple' => true, + ]) + ->add('media', MediaAutocompleteChoiceType::class, [ + 'label' => 'sylius_cms.ui.media', + 'multiple' => true, + ]) + ->addEventListener(FormEvents::PRE_SUBMIT, function (PreSubmitEvent $event): void { + $formData = $event->getData(); + switch ($formData['type']) { + case self::PAGE: + unset($formData['blocks'], $formData['media']); + + break; + case self::BLOCK: + unset($formData['pages'], $formData['media']); + + break; + case self::MEDIA: + unset($formData['pages'], $formData['blocks']); + + break; + } + + $event->setData($formData); + }); + } + + public function getBlockPrefix(): string + { + return 'sylius_cms_collection'; + } +} diff --git a/src/Form/Type/ContentConfigurationType.php b/src/Form/Type/ContentConfigurationType.php new file mode 100644 index 000000000..f6572e438 --- /dev/null +++ b/src/Form/Type/ContentConfigurationType.php @@ -0,0 +1,113 @@ + $formType) { + $this->actionConfigurationTypes[$type] = $formType::class; + $this->actionTypes['sylius_cms.ui.content_elements.type.' . $type] = $type; + } + } + + public function buildForm(FormBuilderInterface $builder, array $options): void + { + $defaultActionType = current($this->actionTypes); + $defaultActionConfigurationType = $this->actionConfigurationTypes[$defaultActionType]; + + $builder + ->add('locale', HiddenType::class) + ->add('type', ChoiceType::class, [ + 'label' => 'sylius.ui.type', + 'choices' => $this->actionTypes, + 'choice_attr' => function (?string $type) use ($builder): array { + return [ + 'data-configuration' => $this->twig->render( + '@SyliusCmsPlugin/ContentConfiguration/_action.html.twig', + [ + 'field' => $builder->create( + 'configuration', + $this->actionConfigurationTypes[$type], + [ + 'label' => false, + 'csrf_protection' => false, + ], + )->getForm()->createView(), + ], + ), + ]; + }, + ]) + ->add('configuration', $defaultActionConfigurationType, [ + 'label' => false, + ]) + ; + + $builder + ->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event): void { + $this->addConfigurationTypeToForm($event); + }) + ->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event): void { + /** @var array|null $data */ + $data = $event->getData(); + if (null === $data) { + return; + } + + $form = $event->getForm(); + $formData = $form->getData(); + + if (null !== $formData && $formData->getType() !== $data['type']) { + $formData->setConfiguration([]); + } + + $this->addConfigurationTypeToForm($event); + }) + ; + } + + private function addConfigurationTypeToForm(FormEvent $event): void + { + $data = $event->getData(); + if (null === $data) { + return; + } + + $form = $event->getForm(); + + $dataType = $data instanceof ContentConfigurationInterface ? $data->getType() : $data['type']; + + $actionConfigurationType = $this->actionConfigurationTypes[$dataType]; + $form->add('configuration', $actionConfigurationType, [ + 'label' => false, + ]); + } + + public function getBlockPrefix(): string + { + return 'sylius_cms_content_configuration'; + } +} diff --git a/src/Form/Type/ContentElementType.php b/src/Form/Type/ContentElementType.php new file mode 100644 index 000000000..4d3091c56 --- /dev/null +++ b/src/Form/Type/ContentElementType.php @@ -0,0 +1,32 @@ +contentElementTypes as $type => $formType) { + $this->contentElements['sylius_cms.ui.content_elements.type.' . $type] = $type; + } + } + + public function buildForm(FormBuilderInterface $builder, array $options): void + { + $builder + ->add('type', ChoiceType::class, [ + 'label' => 'sylius_cms.ui.type', + 'choices' => $this->contentElements, + ]) + ; + } +} diff --git a/src/Form/Type/ContentElements/HeadingContentElementType.php b/src/Form/Type/ContentElements/HeadingContentElementType.php new file mode 100644 index 000000000..2eea9757f --- /dev/null +++ b/src/Form/Type/ContentElements/HeadingContentElementType.php @@ -0,0 +1,42 @@ +add('heading_type', ChoiceType::class, [ + 'label' => 'sylius_cms.ui.content_elements.heading_type', + 'choices' => [ + 'H1' => 'h1', + 'H2' => 'h2', + 'H3' => 'h3', + 'H4' => 'h4', + 'H5' => 'h5', + 'H6' => 'h6', + ], + 'required' => true, + 'empty_data' => 'h1', + ]) + ->add(self::TYPE, TextType::class, [ + 'label' => 'sylius_cms.ui.content_elements.type.' . self::TYPE, + ]) + ; + } + + public function getBlockPrefix(): string + { + return 'sylius_cms_content_elements_' . self::TYPE; + } +} diff --git a/src/Form/Type/ContentElements/MultipleMediaContentElementType.php b/src/Form/Type/ContentElements/MultipleMediaContentElementType.php new file mode 100644 index 000000000..0d5fcec9c --- /dev/null +++ b/src/Form/Type/ContentElements/MultipleMediaContentElementType.php @@ -0,0 +1,36 @@ +add(self::TYPE, MediaAutocompleteChoiceType::class, [ + 'label' => 'sylius_cms.ui.content_elements.type.' . self::TYPE, + 'multiple' => true, + ]) + ; + + $builder->get(self::TYPE)->addModelTransformer($this->mediaToCodesTransformer); + } + + public function getBlockPrefix(): string + { + return 'sylius_cms_content_elements_' . self::TYPE; + } +} diff --git a/src/Form/Type/ContentElements/PagesCollectionContentElementType.php b/src/Form/Type/ContentElements/PagesCollectionContentElementType.php new file mode 100644 index 000000000..410bb3ec3 --- /dev/null +++ b/src/Form/Type/ContentElements/PagesCollectionContentElementType.php @@ -0,0 +1,44 @@ +add(self::TYPE, PageCollectionAutocompleteChoiceType::class, [ + 'label' => 'sylius_cms.ui.content_elements.type.' . self::TYPE, + ]) + ; + + $builder->get(self::TYPE)->addModelTransformer( + new ReversedTransformer(new ResourceToIdentifierTransformer($this->collectionRepository, 'code')), + ); + + $this->contentElementDataTransformerChecker->check($builder, $this->collectionRepository, self::TYPE); + } + + public function getBlockPrefix(): string + { + return 'sylius_cms_content_elements_' . self::TYPE; + } +} diff --git a/src/Form/Type/ContentElements/ProductsCarouselByTaxonContentElementType.php b/src/Form/Type/ContentElements/ProductsCarouselByTaxonContentElementType.php new file mode 100644 index 000000000..b3ff0b0c8 --- /dev/null +++ b/src/Form/Type/ContentElements/ProductsCarouselByTaxonContentElementType.php @@ -0,0 +1,46 @@ +add(self::TYPE, TaxonAutocompleteChoiceType::class, [ + 'label' => 'sylius_cms.ui.taxon', + 'choice_value' => 'code', + 'resource' => 'sylius.taxon', + ]) + ; + + $builder->get(self::TYPE)->addModelTransformer( + new ReversedTransformer(new ResourceToIdentifierTransformer($this->taxonRepository, 'code')), + ); + + $this->contentElementDataTransformerChecker->check($builder, $this->taxonRepository, self::TYPE); + } + + public function getBlockPrefix(): string + { + return 'sylius_cms_content_elements_' . self::TYPE; + } +} diff --git a/src/Form/Type/ContentElements/ProductsCarouselContentElementType.php b/src/Form/Type/ContentElements/ProductsCarouselContentElementType.php new file mode 100644 index 000000000..e8ab722f1 --- /dev/null +++ b/src/Form/Type/ContentElements/ProductsCarouselContentElementType.php @@ -0,0 +1,28 @@ +add(self::TYPE, ForProductsScopeConfigurationType::class, [ + 'label' => false, + ]) + ; + } + + public function getBlockPrefix(): string + { + return 'sylius_cms_content_elements_' . self::TYPE; + } +} diff --git a/src/Form/Type/ContentElements/ProductsGridByTaxonContentElementType.php b/src/Form/Type/ContentElements/ProductsGridByTaxonContentElementType.php new file mode 100644 index 000000000..f128193d7 --- /dev/null +++ b/src/Form/Type/ContentElements/ProductsGridByTaxonContentElementType.php @@ -0,0 +1,46 @@ +add(self::TYPE, TaxonAutocompleteChoiceType::class, [ + 'label' => 'sylius_cms.ui.taxon', + 'choice_value' => 'code', + 'resource' => 'sylius.taxon', + ]) + ; + + $builder->get(self::TYPE)->addModelTransformer( + new ReversedTransformer(new ResourceToIdentifierTransformer($this->taxonRepository, 'code')), + ); + + $this->contentElementDataTransformerChecker->check($builder, $this->taxonRepository, self::TYPE); + } + + public function getBlockPrefix(): string + { + return 'sylius_cms_content_elements_' . self::TYPE; + } +} diff --git a/src/Form/Type/ContentElements/ProductsGridContentElementType.php b/src/Form/Type/ContentElements/ProductsGridContentElementType.php new file mode 100644 index 000000000..bcf15f037 --- /dev/null +++ b/src/Form/Type/ContentElements/ProductsGridContentElementType.php @@ -0,0 +1,28 @@ +add(self::TYPE, ForProductsScopeConfigurationType::class, [ + 'label' => false, + ]) + ; + } + + public function getBlockPrefix(): string + { + return 'sylius_cms_content_elements_' . self::TYPE; + } +} diff --git a/src/Form/Type/ContentElements/SingleMediaContentElementType.php b/src/Form/Type/ContentElements/SingleMediaContentElementType.php new file mode 100644 index 000000000..38479c885 --- /dev/null +++ b/src/Form/Type/ContentElements/SingleMediaContentElementType.php @@ -0,0 +1,44 @@ +add(self::TYPE, MediaAutocompleteChoiceType::class, [ + 'label' => 'sylius_cms.ui.content_elements.type.' . self::TYPE, + ]) + ; + + $builder->get(self::TYPE)->addModelTransformer( + new ReversedTransformer(new ResourceToIdentifierTransformer($this->mediaRepository, 'code')), + ); + + $this->contentElementDataTransformerChecker->check($builder, $this->mediaRepository, self::TYPE); + } + + public function getBlockPrefix(): string + { + return 'sylius_cms_content_elements_' . self::TYPE; + } +} diff --git a/src/Form/Type/ContentElements/SpacerContentElementType.php b/src/Form/Type/ContentElements/SpacerContentElementType.php new file mode 100644 index 000000000..ca2d45e34 --- /dev/null +++ b/src/Form/Type/ContentElements/SpacerContentElementType.php @@ -0,0 +1,32 @@ +add(self::TYPE, NumberType::class, [ + 'label' => 'sylius_cms.ui.content_elements.type.' . self::TYPE . '_height', + 'attr' => [ + 'min' => 0, + ], + 'html5' => true, + ]) + ; + } + + public function getBlockPrefix(): string + { + return 'sylius_cms_content_elements_' . self::TYPE; + } +} diff --git a/src/Form/Type/ContentElements/TaxonsListContentElementType.php b/src/Form/Type/ContentElements/TaxonsListContentElementType.php new file mode 100644 index 000000000..3ac14c567 --- /dev/null +++ b/src/Form/Type/ContentElements/TaxonsListContentElementType.php @@ -0,0 +1,28 @@ +add(self::TYPE, ForTaxonsScopeConfigurationType::class, [ + 'label' => false, + ]) + ; + } + + public function getBlockPrefix(): string + { + return 'sylius_cms_content_elements_' . self::TYPE; + } +} diff --git a/src/Form/Type/ContentElements/TextareaContentElementType.php b/src/Form/Type/ContentElements/TextareaContentElementType.php new file mode 100644 index 000000000..65ad35271 --- /dev/null +++ b/src/Form/Type/ContentElements/TextareaContentElementType.php @@ -0,0 +1,28 @@ +add(self::TYPE, WysiwygType::class, [ + 'label' => 'sylius_cms.ui.content_elements.type.' . self::TYPE, + ]) + ; + } + + public function getBlockPrefix(): string + { + return 'sylius_cms_content_elements_' . self::TYPE; + } +} diff --git a/src/Form/Type/FrequentlyAskedQuestionType.php b/src/Form/Type/FrequentlyAskedQuestionType.php deleted file mode 100755 index 28f24ea3d..000000000 --- a/src/Form/Type/FrequentlyAskedQuestionType.php +++ /dev/null @@ -1,49 +0,0 @@ -add('code', TextType::class, [ - 'label' => 'bitbag_sylius_cms_plugin.ui.code', - 'disabled' => null !== $builder->getData()->getCode(), - ]) - ->add('position', IntegerType::class, [ - 'label' => 'bitbag_sylius_cms_plugin.ui.position', - ]) - ->add('enabled', CheckboxType::class, [ - 'label' => 'bitbag_sylius_cms_plugin.ui.enabled', - ]) - ->add('translations', ResourceTranslationsType::class, [ - 'label' => false, - 'entry_type' => FrequentlyAskedQuestionTranslationType::class, - ]) - ->add('channels', ChannelChoiceType::class, [ - 'label' => 'bitbag_sylius_cms_plugin.ui.channels', - 'required' => false, - 'multiple' => true, - 'expanded' => true, - ]) - ; - } -} diff --git a/src/Form/Type/ImportType.php b/src/Form/Type/ImportType.php index 0c5651259..f1d4b2916 100644 --- a/src/Form/Type/ImportType.php +++ b/src/Form/Type/ImportType.php @@ -1,14 +1,8 @@ true, 'constraints' => [ new NotNull([ - 'message' => 'bitbag_sylius_cms_plugin.import.not_blank', + 'message' => 'sylius_cms.import.not_blank', ]), new File([ 'mimeTypes' => ['text/csv', 'text/plain'], - 'mimeTypesMessage' => 'bitbag_sylius_cms_plugin.import.invalid_format', + 'mimeTypesMessage' => 'sylius_cms.import.invalid_format', ]), ], ]); diff --git a/src/Form/Type/MediaAutocompleteChoiceType.php b/src/Form/Type/MediaAutocompleteChoiceType.php index 951688e39..045511602 100644 --- a/src/Form/Type/MediaAutocompleteChoiceType.php +++ b/src/Form/Type/MediaAutocompleteChoiceType.php @@ -1,17 +1,11 @@ setDefaults([ - 'resource' => 'bitbag_sylius_cms_plugin.media', + 'resource' => 'sylius_cms.media', 'choice_name' => 'name', 'choice_value' => 'code', - 'media_type' => null, - ]); - - $resolver->setAllowedValues('media_type', [ - MediaInterface::IMAGE_TYPE, - MediaInterface::FILE_TYPE, - MediaInterface::VIDEO_TYPE, - null, + 'media_type' => [ + MediaInterface::IMAGE_TYPE, + MediaInterface::FILE_TYPE, + MediaInterface::VIDEO_TYPE, + ], ]); } @@ -48,7 +39,7 @@ public function buildView( public function getBlockPrefix(): string { - return 'bitbag_media_autocomplete_choice'; + return 'sylius_media_autocomplete_choice'; } public function getParent(): string diff --git a/src/Form/Type/MediaImageAutocompleteChoiceType.php b/src/Form/Type/MediaImageAutocompleteChoiceType.php new file mode 100644 index 000000000..2b7e67822 --- /dev/null +++ b/src/Form/Type/MediaImageAutocompleteChoiceType.php @@ -0,0 +1,45 @@ +setDefaults([ + 'resource' => 'sylius_cms.media', + 'choice_name' => 'name', + 'choice_value' => 'code', + 'media_type' => [MediaInterface::IMAGE_TYPE], + ]); + } + + public function buildView( + FormView $view, + FormInterface $form, + array $options, + ): void { + $view->vars['remote_criteria_type'] = 'contains'; + $view->vars['remote_criteria_name'] = 'phrase'; + $view->vars['media_type'] = $options['media_type']; + } + + public function getBlockPrefix(): string + { + return 'sylius_media_autocomplete_choice'; + } + + public function getParent(): string + { + return ResourceAutocompleteChoiceType::class; + } +} diff --git a/src/Form/Type/MediaType.php b/src/Form/Type/MediaType.php index 7671a17d9..4cdc7a749 100644 --- a/src/Form/Type/MediaType.php +++ b/src/Form/Type/MediaType.php @@ -1,20 +1,13 @@ add('code', TextType::class, [ - 'label' => 'bitbag_sylius_cms_plugin.ui.code', + 'label' => 'sylius_cms.ui.code', 'disabled' => null !== $data && null !== $data->getCode(), ]) + ->add('name', TextType::class, [ + 'label' => 'sylius_cms.ui.name', + ]) ->add('type', ChoiceType::class, [ - 'label' => 'bitbag_sylius_cms_plugin.ui.type', + 'label' => 'sylius_cms.ui.type', 'choices' => $this->providers, ]) ->add('file', FileType::class, [ - 'label' => 'bitbag_sylius_cms_plugin.ui.file', + 'label' => 'sylius_cms.ui.file', ]) - ->add('sections', SectionAutocompleteChoiceType::class, [ - 'label' => 'bitbag_sylius_cms_plugin.ui.sections', + ->add('collections', CollectionAutocompleteChoiceType::class, [ + 'label' => 'sylius_cms.ui.collections', 'multiple' => true, ]) ->add('enabled', CheckboxType::class, [ - 'label' => 'bitbag_sylius_cms_plugin.ui.enabled', + 'label' => 'sylius_cms.ui.enabled', ]) ->add('saveWithOriginalName', CheckboxType::class, [ - 'label' => 'bitbag_sylius_cms_plugin.ui.save_with_original_name', - ]) - ->add('products', ProductAutocompleteChoiceType::class, [ - 'label' => 'bitbag_sylius_cms_plugin.ui.products', - 'multiple' => true, + 'label' => 'sylius_cms.ui.save_with_original_name', ]) ->add('channels', ChannelChoiceType::class, [ - 'label' => 'bitbag_sylius_cms_plugin.ui.channels', + 'label' => 'sylius_cms.ui.channels', 'required' => false, 'multiple' => true, 'expanded' => true, ]) + ->add('path', TextType::class, [ + 'label' => 'sylius_cms.ui.path', + 'disabled' => true, + 'required' => false, + ]) ->add('translations', ResourceTranslationsType::class, [ 'entry_type' => MediaTranslationType::class, ]) @@ -80,6 +76,6 @@ public function buildForm(FormBuilderInterface $builder, array $options): void public function getBlockPrefix(): string { - return 'bitbag_sylius_cms_plugin_media'; + return 'sylius_cms_media'; } } diff --git a/src/Form/Type/PageAutocompleteChoiceType.php b/src/Form/Type/PageAutocompleteChoiceType.php new file mode 100644 index 000000000..86c27d7be --- /dev/null +++ b/src/Form/Type/PageAutocompleteChoiceType.php @@ -0,0 +1,42 @@ +setDefaults([ + 'resource' => 'sylius_cms.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 'sylius_page_autocomplete_choice'; + } + + public function getParent(): string + { + return ResourceAutocompleteChoiceType::class; + } +} diff --git a/src/Form/Type/PageCollectionAutocompleteChoiceType.php b/src/Form/Type/PageCollectionAutocompleteChoiceType.php new file mode 100755 index 000000000..7f543b0ec --- /dev/null +++ b/src/Form/Type/PageCollectionAutocompleteChoiceType.php @@ -0,0 +1,42 @@ +setDefaults([ + 'resource' => 'sylius_cms.collection', + 'choice_name' => 'name', + 'choice_value' => 'code', + ]); + } + + public function buildView( + FormView $view, + FormInterface $form, + array $options, + ): void { + $view->vars['remote_criteria_type'] = 'contains'; + $view->vars['remote_criteria_name'] = 'phrase'; + } + + public function getBlockPrefix(): string + { + return 'sylius_page_collection_autocomplete_choice'; + } + + public function getParent(): string + { + return ResourceAutocompleteChoiceType::class; + } +} diff --git a/src/Form/Type/PageType.php b/src/Form/Type/PageType.php index a16f092e1..0dbeba156 100755 --- a/src/Form/Type/PageType.php +++ b/src/Form/Type/PageType.php @@ -1,67 +1,155 @@ localeRepository->findAll(); + foreach ($locales as $locale) { + $this->locales[$locale->getName()] = $locale->getCode(); + } + } + public function buildForm(FormBuilderInterface $builder, array $options): void { $builder ->add('code', TextType::class, [ - 'label' => 'bitbag_sylius_cms_plugin.ui.code', + 'label' => 'sylius_cms.ui.code', 'disabled' => null !== $builder->getData()->getCode(), ]) - ->add('enabled', CheckboxType::class, [ - 'label' => 'bitbag_sylius_cms_plugin.ui.enabled', + ->add('name', TextType::class, [ + 'label' => 'sylius_cms.ui.name', ]) - ->add('products', ProductAutocompleteChoiceType::class, [ - 'label' => 'bitbag_sylius_cms_plugin.ui.products', - 'multiple' => true, + ->add('templates', ChoiceType::class, [ + 'label' => 'sylius_cms.ui.template', + 'choices' => $this->templateProvider->getPageTemplates(), + 'mapped' => false, + ]) + ->add('enabled', CheckboxType::class, [ + 'label' => 'sylius_cms.ui.enabled', ]) ->add('translations', ResourceTranslationsType::class, [ - 'label' => 'bitbag_sylius_cms_plugin.ui.images', + 'label' => 'sylius_cms.ui.images', 'entry_type' => PageTranslationType::class, ]) - ->add('sections', SectionAutocompleteChoiceType::class, [ - 'label' => 'bitbag_sylius_cms_plugin.ui.sections', + ->add('collections', CollectionAutocompleteChoiceType::class, [ + 'label' => 'sylius_cms.ui.collections', 'multiple' => true, ]) ->add('channels', ChannelChoiceType::class, [ - 'label' => 'bitbag_sylius_cms_plugin.ui.channels', + 'label' => 'sylius_cms.ui.channels', 'required' => false, 'multiple' => true, 'expanded' => true, ]) ->add('publishAt', DateTimeType::class, [ 'input' => 'datetime_immutable', - 'label' => 'bitbag_sylius_cms_plugin.ui.publish_at', + 'label' => 'sylius_cms.ui.publish_at', 'date_widget' => 'single_text', 'time_widget' => 'single_text', 'required' => false, ]) + ->add('contentElements', CollectionType::class, [ + 'label' => false, + 'entry_type' => ContentConfigurationType::class, + 'allow_add' => true, + 'allow_delete' => true, + 'by_reference' => false, + 'required' => false, + 'entry_options' => [ + 'label' => false, + ], + 'attr' => [ + 'class' => 'content-elements-container', + ], + ]) + ->add('contentTemplate', TemplatePageAutocompleteChoiceType::class, [ + 'label' => false, + 'mapped' => false, + ]) + ->add('locale', ChoiceType::class, [ + 'choices' => $this->locales, + 'mapped' => false, + 'label' => 'sylius.ui.locale', + 'attr' => [ + 'class' => 'locale-selector', + ], + ]) ; + + self::addContentElementLocaleListener($builder); + self::addTemplateListener($builder); + } + + public static function addContentElementLocaleListener(FormBuilderInterface $builder): void + { + $builder->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event) { + $data = $event->getData(); + $selectedLocale = $data['locale'] ?? null; + + if (isset($data['contentElements'])) { + foreach ($data['contentElements'] as &$contentElement) { + if (empty($contentElement['locale'])) { + $contentElement['locale'] = $selectedLocale; + } + } + } + + $event->setData($data); + }); + } + + public static function addTemplateListener(FormBuilderInterface $builder): void + { + $builder->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event) { + $form = $event->getForm(); + $data = $event->getData(); + $template = $data['templates'] ?? null; + + $entity = $form->getData(); + $entity->setTemplate($template); + }); + + $builder->addEventListener(FormEvents::POST_SET_DATA, function (FormEvent $event) { + $data = $event->getData(); + $form = $event->getForm(); + $template = $data->getTemplate(); + + $form->get('templates')->setData($template); + }); } public function getBlockPrefix(): string { - return 'bitbag_sylius_cms_plugin_page'; + return 'sylius_cms_page'; } } diff --git a/src/Form/Type/SectionType.php b/src/Form/Type/SectionType.php deleted file mode 100755 index 6ef143368..000000000 --- a/src/Form/Type/SectionType.php +++ /dev/null @@ -1,38 +0,0 @@ -add('code', TextType::class, [ - 'label' => 'bitbag_sylius_cms_plugin.ui.code', - 'disabled' => null !== $builder->getData()->getCode(), - ]) - ->add('translations', ResourceTranslationsType::class, [ - 'entry_type' => SectionTranslationType::class, - ]) - ; - } - - public function getBlockPrefix(): string - { - return 'bitbag_sylius_cms_plugin_section'; - } -} diff --git a/src/Form/Type/TemplateBlockAutocompleteChoiceType.php b/src/Form/Type/TemplateBlockAutocompleteChoiceType.php new file mode 100644 index 000000000..121bf2346 --- /dev/null +++ b/src/Form/Type/TemplateBlockAutocompleteChoiceType.php @@ -0,0 +1,13 @@ +add('name', TextType::class, [ + 'label' => 'sylius_cms.ui.name', + ]) + ->add('type', ChoiceType::class, [ + 'label' => 'sylius_cms.ui.type', + 'choices' => [ + 'sylius_cms.ui.page' => 'page', + 'sylius_cms.ui.block' => 'block', + ], + ]) + ->add('contentElements', CollectionType::class, [ + 'entry_type' => ContentElementType::class, + 'label' => false, + 'allow_add' => true, + 'allow_delete' => true, + 'by_reference' => false, + 'required' => false, + ]) + ; + } + + public function getBlockPrefix(): string + { + return 'sylius_cms_template'; + } +} diff --git a/src/Form/Type/Translation/BlockTranslationType.php b/src/Form/Type/Translation/BlockTranslationType.php deleted file mode 100644 index 2c74b196c..000000000 --- a/src/Form/Type/Translation/BlockTranslationType.php +++ /dev/null @@ -1,41 +0,0 @@ -add('name', TextType::class, [ - 'label' => 'bitbag_sylius_cms_plugin.ui.name', - 'required' => false, - ]) - ->add('link', TextType::class, [ - 'label' => 'bitbag_sylius_cms_plugin.ui.link', - 'required' => false, - ]) - ->add('content', WysiwygType::class, [ - 'required' => false, - ]) - ; - } - - public function getBlockPrefix(): string - { - return 'bitbag_sylius_cms_plugin_text_translation'; - } -} diff --git a/src/Form/Type/Translation/FrequentlyAskedQuestionTranslationType.php b/src/Form/Type/Translation/FrequentlyAskedQuestionTranslationType.php deleted file mode 100755 index c992620e1..000000000 --- a/src/Form/Type/Translation/FrequentlyAskedQuestionTranslationType.php +++ /dev/null @@ -1,31 +0,0 @@ -add('question', TextType::class, [ - 'label' => 'bitbag_sylius_cms_plugin.ui.question', - ]) - ->add('answer', TextareaType::class, [ - 'label' => 'bitbag_sylius_cms_plugin.ui.answer', - ]) - ; - } -} diff --git a/src/Form/Type/Translation/MediaTranslationType.php b/src/Form/Type/Translation/MediaTranslationType.php index 5d40e3273..1dc707d04 100755 --- a/src/Form/Type/Translation/MediaTranslationType.php +++ b/src/Form/Type/Translation/MediaTranslationType.php @@ -1,17 +1,11 @@ add('name', TextType::class, [ - 'label' => 'bitbag_sylius_cms_plugin.ui.name', - 'required' => false, - ]) ->add('alt', TextType::class, [ - 'label' => 'bitbag_sylius_cms_plugin.ui.alt', + 'label' => 'sylius_cms.ui.alt', 'required' => false, ]) ->add('link', TextType::class, [ - 'label' => 'bitbag_sylius_cms_plugin.ui.link', + 'label' => 'sylius_cms.ui.link', + 'required' => false, + ]) + ->add('content', WysiwygType::class, [ + 'label' => 'sylius_cms.ui.link_content', 'required' => false, ]) - ->add('content', WysiwygType::class, ['required' => false]) ; } public function getBlockPrefix(): string { - return 'bitbag_sylius_cms_plugin_media_translation'; + return 'sylius_cms_media_translation'; } } diff --git a/src/Form/Type/Translation/PageTranslationType.php b/src/Form/Type/Translation/PageTranslationType.php index 54a9d18bc..fbd264562 100755 --- a/src/Form/Type/Translation/PageTranslationType.php +++ b/src/Form/Type/Translation/PageTranslationType.php @@ -1,19 +1,12 @@ add('name', TextType::class, [ - 'label' => 'bitbag_sylius_cms_plugin.ui.name', - ]) ->add('slug', TextType::class, [ - 'label' => 'bitbag_sylius_cms_plugin.ui.slug', + 'label' => 'sylius_cms.ui.slug', ]) - ->add('breadcrumb', TextType::class, [ - 'label' => 'bitbag_sylius_cms_plugin.ui.breadcrumb', - 'required' => false, - ]) - ->add('nameWhenLinked', TextType::class, [ - 'label' => 'bitbag_sylius_cms_plugin.ui.name_when_linked', + ->add('title', TextType::class, [ + 'label' => 'sylius_cms.ui.meta_title', 'required' => false, ]) - ->add('descriptionWhenLinked', TextareaType::class, [ - 'label' => 'bitbag_sylius_cms_plugin.ui.description_when_linked', + ->add('metaKeywords', TextareaType::class, [ + 'label' => 'sylius_cms.ui.meta_keywords', 'required' => false, ]) - ->add('image', MediaAutocompleteChoiceType::class, [ - 'label' => 'bitbag_sylius_cms_plugin.ui.image', + ->add('metaDescription', TextareaType::class, [ + 'label' => 'sylius_cms.ui.meta_description', 'required' => false, - 'media_type' => MediaInterface::IMAGE_TYPE, ]) - ->add('metaKeywords', TextareaType::class, [ - 'label' => 'bitbag_sylius_cms_plugin.ui.meta_keywords', + ->add('teaserTitle', TextType::class, [ + 'label' => 'sylius_cms.ui.teaser.title', 'required' => false, ]) - ->add('metaDescription', TextareaType::class, [ - 'label' => 'bitbag_sylius_cms_plugin.ui.meta_description', + ->add('teaserContent', WysiwygType::class, [ + 'label' => 'sylius_cms.ui.teaser.content', 'required' => false, ]) - ->add('content', WysiwygType::class) - ->add('title', TextType::class, [ - 'label' => 'bitbag_sylius_cms_plugin.ui.title', + ->add('teaserImage', MediaImageAutocompleteChoiceType::class, [ + 'label' => 'sylius_cms.ui.teaser.image', 'required' => false, ]) ; @@ -64,6 +48,6 @@ public function buildForm(FormBuilderInterface $builder, array $options): void public function getBlockPrefix(): string { - return 'bitbag_sylius_cms_plugin_page_translation'; + return 'sylius_cms_page_translation'; } } diff --git a/src/Form/Type/Translation/SectionTranslationType.php b/src/Form/Type/Translation/SectionTranslationType.php deleted file mode 100755 index 18069a56c..000000000 --- a/src/Form/Type/Translation/SectionTranslationType.php +++ /dev/null @@ -1,32 +0,0 @@ -add('name', TextType::class, [ - 'label' => 'bitbag_sylius_cms_plugin.ui.name', - ]) - ; - } - - public function getBlockPrefix(): string - { - return 'bitbag_sylius_cms_plugin_section_translation'; - } -} diff --git a/src/Form/Type/WysiwygType.php b/src/Form/Type/WysiwygType.php index 6318c3d0a..d11c662aa 100644 --- a/src/Form/Type/WysiwygType.php +++ b/src/Form/Type/WysiwygType.php @@ -1,14 +1,8 @@ setDefaults([ - 'label' => 'bitbag_sylius_cms_plugin.ui.content', + 'label' => 'sylius_cms.ui.content', 'config' => [ - 'filebrowserUploadUrl' => $this->urlGenerator->generate('bitbag_sylius_cms_plugin_admin_upload_editor_image'), - 'bodyId' => 'bitbag-ckeditor', + 'filebrowserUploadUrl' => $this->urlGenerator->generate('sylius_cms_admin_upload_editor_image'), + 'bodyId' => 'cms-ckeditor', ], ]); } @@ -39,6 +33,6 @@ public function getParent(): string public function getBlockPrefix(): string { - return 'bitbag_wysiwyg'; + return 'sylius_wysiwyg'; } } diff --git a/src/Importer/AbstractImporter.php b/src/Importer/AbstractImporter.php index 52147a013..e053006b8 100755 --- a/src/Importer/AbstractImporter.php +++ b/src/Importer/AbstractImporter.php @@ -1,14 +1,8 @@ blockResourceResolver->getResource($code); - $block->setCode($code); - $block->setFallbackLocale($this->localeContext->getLocaleCode()); - - foreach ($this->getAvailableLocales($this->getTranslatableColumns(), array_keys($row)) as $locale) { - $block->setCurrentLocale($locale); - $block->setName($this->getTranslatableColumnValue(self::NAME_COLUMN, $locale, $row)); - $block->setLink($this->getTranslatableColumnValue(self::LINK_COLUMN, $locale, $row)); - $block->setContent($this->getTranslatableColumnValue(self::CONTENT_COLUMN, $locale, $row)); - } + $block->setName($this->getColumnValue(self::NAME_COLUMN, $row)); + $block->setEnabled((bool) $this->getColumnValue(self::ENABLED_COLUMN, $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)); + $this->importerTaxonsResolver->resolve($block, $this->getColumnValue(self::TAXONS_COLUMN, $row)); + $this->importerProductsInTaxonsResolver->resolve($block, $this->getColumnValue(self::PRODUCTS_IN_TAXONS_COLUMN, $row)); - $this->validateResource($block, ['bitbag']); + $this->validateResource($block, ['cms']); $this->blockRepository->add($block); } @@ -64,13 +55,4 @@ public function getResourceCode(): string { return 'block'; } - - private function getTranslatableColumns(): array - { - return [ - self::NAME_COLUMN, - self::CONTENT_COLUMN, - self::LINK_COLUMN, - ]; - } } diff --git a/src/Importer/BlockImporterInterface.php b/src/Importer/BlockImporterInterface.php index 5be16a7ef..a22b25457 100644 --- a/src/Importer/BlockImporterInterface.php +++ b/src/Importer/BlockImporterInterface.php @@ -1,28 +1,24 @@ getColumnValue(self::CODE_COLUMN, $row); + Assert::notNull($code); + /** @var BlockInterface $block */ + $block = $this->blockResourceResolver->getResource($code); + $block->setCode($code); + + $this->importerCollectionsResolver->resolve($block, $this->getColumnValue(self::SECTIONS_COLUMN, $row)); + $this->importerChannelsResolver->resolve($block, $this->getColumnValue(self::CHANNELS_COLUMN, $row)); + + $translationArray = $this->getAvailableLocales($this->getTranslatableColumns(), array_keys($row)); + foreach ($translationArray as $key => $locale) { + if ($key === array_key_first($translationArray)) { + $block->setName($this->getTranslatableColumnValue(self::NAME_COLUMN, $locale, $row)); + } + + $heading = ContentElementFactory::createHeadingContentElement( + $locale, + 'h2', + $this->getTranslatableColumnValue(self::NAME_COLUMN, $locale, $row), + ); + if ($heading) { + $heading->setBlock($block); + $block->addContentElement($heading); + } + + $singleMedia = ContentElementFactory::createSingleMediaContentElement( + $locale, + $this->getTranslatableColumnValue(self::IMAGE_COLUMN, $locale, $row), + ); + if ($singleMedia) { + $singleMedia->setBlock($block); + $block->addContentElement($singleMedia); + } + + $content = ContentElementFactory::createTextareaContentElement( + $locale, + $this->getTranslatableColumnValue(self::CONTENT_COLUMN, $locale, $row), + ); + if ($content) { + $content->setBlock($block); + $block->addContentElement($content); + } + } + + $locales = $this->localeRepository->findAll(); + /** @var LocaleInterface $locale */ + foreach ($locales as $locale) { + $productsGrid = ContentElementFactory::createProductsGridContentElement( + $locale->getCode(), + $this->getColumnValue(self::PRODUCTS_COLUMN, $row), + ); + if ($productsGrid) { + $productsGrid->setBlock($block); + $block->addContentElement($productsGrid); + } + } + + $this->validateResource($block, ['cms']); + $this->blockRepository->add($block); + } + + public function getResourceCode(): string + { + return 'block_legacy'; + } + + private function getTranslatableColumns(): array + { + return [ + self::NAME_COLUMN, + self::CONTENT_COLUMN, + self::IMAGE_COLUMN, + ]; + } +} diff --git a/src/Importer/Legacy/LegacyBlockImporterInterface.php b/src/Importer/Legacy/LegacyBlockImporterInterface.php new file mode 100644 index 000000000..182699840 --- /dev/null +++ b/src/Importer/Legacy/LegacyBlockImporterInterface.php @@ -0,0 +1,24 @@ +getColumnValue(self::CODE_COLUMN, $row); + Assert::notNull($code); + + /** @var PageInterface $page */ + $page = $this->pageResourceResolver->getResource($code); + + $page->setCode($code); + $page->setFallbackLocale($this->localeContext->getLocaleCode()); + + $this->importerCollectionsResolver->resolve($page, $this->getColumnValue(self::SECTIONS_COLUMN, $row)); + $this->importerChannelsResolver->resolve($page, $this->getColumnValue(self::CHANNELS_COLUMN, $row)); + + $translationArray = $this->getAvailableLocales($this->getTranslatableColumns(), array_keys($row)); + foreach ($translationArray as $key => $locale) { + $page->setCurrentLocale($locale); + $page->setSlug($this->getTranslatableColumnValue(self::SLUG_COLUMN, $locale, $row)); + $page->setMetaKeywords($this->getTranslatableColumnValue(self::META_KEYWORDS_COLUMN, $locale, $row)); + $page->setMetaDescription($this->getTranslatableColumnValue(self::META_DESCRIPTION_COLUMN, $locale, $row)); + + if ($key === array_key_first($translationArray)) { + $page->setName($this->getTranslatableColumnValue(self::NAME_COLUMN, $locale, $row)); + } + + $page->setTeaserTitle($this->getTranslatableColumnValue(self::NAME_WHEN_LINKED_COLUMN, $locale, $row)); + $page->setTeaserContent($this->getTranslatableColumnValue(self::DESCRIPTION_WHEN_LINKED_COLUMN, $locale, $row)); + + $heading = ContentElementFactory::createHeadingContentElement( + $locale, + 'h2', + $this->getTranslatableColumnValue(self::NAME_COLUMN, $locale, $row), + ); + if ($heading) { + $heading->setPage($page); + $page->addContentElement($heading); + } + + $singleMedia = ContentElementFactory::createSingleMediaContentElement( + $locale, + $this->getTranslatableColumnValue(self::IMAGE_COLUMN, $locale, $row), + ); + if ($singleMedia) { + $singleMedia->setPage($page); + $page->addContentElement($singleMedia); + } + + $content = ContentElementFactory::createTextareaContentElement( + $locale, + $this->getTranslatableColumnValue(self::CONTENT_COLUMN, $locale, $row), + ); + if ($content) { + $content->setPage($page); + $page->addContentElement($content); + } + } + + $locales = $this->localeRepository->findAll(); + /** @var LocaleInterface $locale */ + foreach ($locales as $locale) { + $productsGrid = ContentElementFactory::createProductsGridContentElement( + $locale->getCode(), + $this->getColumnValue(self::PRODUCTS_COLUMN, $row), + ); + if ($productsGrid) { + $productsGrid->setPage($page); + $page->addContentElement($productsGrid); + } + } + + $this->validateResource($page, ['cms']); + + $this->entityManager->persist($page); + $this->entityManager->flush(); + } + + public function getResourceCode(): string + { + return 'page_legacy'; + } + + private function getTranslatableColumns(): array + { + return [ + self::SLUG_COLUMN, + self::NAME_COLUMN, + self::IMAGE_COLUMN, + self::CONTENT_COLUMN, + self::META_KEYWORDS_COLUMN, + self::META_DESCRIPTION_COLUMN, + self::NAME_WHEN_LINKED_COLUMN, + self::DESCRIPTION_WHEN_LINKED_COLUMN, + ]; + } +} diff --git a/src/Importer/Legacy/LegacyPageImporterInterface.php b/src/Importer/Legacy/LegacyPageImporterInterface.php new file mode 100644 index 000000000..bc6e980f4 --- /dev/null +++ b/src/Importer/Legacy/LegacyPageImporterInterface.php @@ -0,0 +1,34 @@ +setAlt($this->getTranslatableColumnValue(self::ALT_COLUMN, $locale, $row)); } - $this->importerSectionsResolver->resolve($media, $this->getColumnValue(self::SECTIONS_COLUMN, $row)); - $this->importerProductsResolver->resolve($media, $this->getColumnValue(self::PRODUCTS_COLUMN, $row)); + $this->importerCollectionsResolver->resolve($media, $this->getColumnValue(self::COLLECTIONS_COLUMN, $row)); - $this->validateResource($media, ['bitbag']); + $this->validateResource($media, ['cms']); $this->mediaRepository->add($media); } diff --git a/src/Importer/MediaImporterInterface.php b/src/Importer/MediaImporterInterface.php index 7dd57f881..79872ea4f 100644 --- a/src/Importer/MediaImporterInterface.php +++ b/src/Importer/MediaImporterInterface.php @@ -1,14 +1,8 @@ setCode($code); $page->setFallbackLocale($this->localeContext->getLocaleCode()); + $page->setName($this->getColumnValue(self::NAME_COLUMN, $row)); + $page->setEnabled((bool) $this->getColumnValue(self::ENABLED_COLUMN, $row)); foreach ($this->getAvailableLocales($this->getTranslatableColumns(), array_keys($row)) as $locale) { $page->setCurrentLocale($locale); $page->setSlug($this->getTranslatableColumnValue(self::SLUG_COLUMN, $locale, $row)); - $page->setName($this->getTranslatableColumnValue(self::NAME_COLUMN, $locale, $row)); + $page->setTitle($this->getTranslatableColumnValue(self::META_TITLE_COLUMN, $locale, $row)); $page->setMetaKeywords($this->getTranslatableColumnValue(self::META_KEYWORDS_COLUMN, $locale, $row)); $page->setMetaDescription($this->getTranslatableColumnValue(self::META_DESCRIPTION_COLUMN, $locale, $row)); - $page->setContent($this->getTranslatableColumnValue(self::CONTENT_COLUMN, $locale, $row)); - $page->setBreadcrumb($this->getTranslatableColumnValue(self::BREADCRUMB_COLUMN, $locale, $row)); - $page->setNameWhenLinked($this->getTranslatableColumnValue(self::NAME_WHEN_LINKED_COLUMN, $locale, $row)); - $page->setDescriptionWhenLinked($this->getTranslatableColumnValue(self::DESCRIPTION_WHEN_LINKED_COLUMN, $locale, $row)); - - $url = $this->getTranslatableColumnValue(self::IMAGE_COLUMN, $locale, $row); - $imageCode = $this->getTranslatableColumnValue(self::IMAGE_CODE_COLUMN, $locale, $row); - - if (null !== $url) { - $this->resolveImage($page, $url, $locale, $imageCode); - } } - $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)); - $this->validateResource($page, ['bitbag']); + $this->validateResource($page, ['cms']); $this->entityManager->persist($page); $this->entityManager->flush(); @@ -89,56 +62,13 @@ public function getResourceCode(): string return 'page'; } - private function resolveImage( - PageInterface $page, - string $url, - string $locale, - string $imageCode, - ): void { - $downloadedImage = $this->imageDownloader->download($url); - - /** @var MediaInterface $image */ - $image = $this->mediaFactory->createNew(); - $image->setFile($downloadedImage); - $image->setType($this->getFileType($downloadedImage)); - $image->setCode($imageCode); - - /** @var PageTranslationInterface $pageTranslation */ - $pageTranslation = $page->getTranslation($locale); - $pageTranslation->setImage($image); - - $this->mediaProviderResolver->resolveProvider($image)->upload($image); - $this->entityManager->persist($image); - } - - private function getFileType(File $file): string - { - switch ($file->getExtension()) { - case 'png': - case 'jpg': - case 'jpeg': - case 'gif': - return MediaInterface::IMAGE_TYPE; - case 'mp4': - return MediaInterface::VIDEO_TYPE; - } - - return MediaInterface::FILE_TYPE; - } - private function getTranslatableColumns(): array { return [ self::SLUG_COLUMN, - self::NAME_COLUMN, - self::IMAGE_COLUMN, - self::IMAGE_CODE_COLUMN, + self::META_TITLE_COLUMN, self::META_KEYWORDS_COLUMN, self::META_DESCRIPTION_COLUMN, - self::CONTENT_COLUMN, - self::BREADCRUMB_COLUMN, - self::NAME_WHEN_LINKED_COLUMN, - self::DESCRIPTION_WHEN_LINKED_COLUMN, ]; } } diff --git a/src/Importer/PageImporterInterface.php b/src/Importer/PageImporterInterface.php index aa00ce707..ae6eaa795 100644 --- a/src/Importer/PageImporterInterface.php +++ b/src/Importer/PageImporterInterface.php @@ -1,42 +1,26 @@ getMenu(); $cmsRootMenuItem = $menu - ->addChild('bitbag_cms') - ->setLabel('bitbag_sylius_cms_plugin.ui.cms') + ->addChild('sylius_cms') + ->setLabel('sylius_cms.ui.cms') ; $cmsRootMenuItem - ->addChild('blocks', [ - 'route' => 'bitbag_sylius_cms_plugin_admin_block_index', + ->addChild('collections', [ + 'route' => 'sylius_cms_admin_collection_index', ]) - ->setLabel('bitbag_sylius_cms_plugin.ui.blocks') - ->setLabelAttribute('icon', 'block layout') + ->setLabel('sylius_cms.ui.collections') + ->setLabelAttribute('icon', 'grid layout') ; $cmsRootMenuItem - ->addChild('media', [ - 'route' => 'bitbag_sylius_cms_plugin_admin_media_index', + ->addChild('templates', [ + 'route' => 'sylius_cms_admin_template_index', ]) - ->setLabel('bitbag_sylius_cms_plugin.ui.media') - ->setLabelAttribute('icon', 'file') + ->setLabel('sylius_cms.ui.content_templates') + ->setLabelAttribute('icon', 'clone') ; $cmsRootMenuItem ->addChild('pages', [ - 'route' => 'bitbag_sylius_cms_plugin_admin_page_index', + 'route' => 'sylius_cms_admin_page_index', ]) - ->setLabel('bitbag_sylius_cms_plugin.ui.pages') + ->setLabel('sylius_cms.ui.pages') ->setLabelAttribute('icon', 'sticky note') ; $cmsRootMenuItem - ->addChild('faq', [ - 'route' => 'bitbag_sylius_cms_plugin_admin_frequently_asked_question_index', + ->addChild('blocks', [ + 'route' => 'sylius_cms_admin_block_index', ]) - ->setLabel('bitbag_sylius_cms_plugin.ui.faq') - ->setLabelAttribute('icon', 'help') + ->setLabel('sylius_cms.ui.blocks') + ->setLabelAttribute('icon', 'block layout') ; $cmsRootMenuItem - ->addChild('sections', [ - 'route' => 'bitbag_sylius_cms_plugin_admin_section_index', + ->addChild('media', [ + 'route' => 'sylius_cms_admin_media_index', ]) - ->setLabel('bitbag_sylius_cms_plugin.ui.sections') - ->setLabelAttribute('icon', 'grid layout') + ->setLabel('sylius_cms.ui.media') + ->setLabelAttribute('icon', 'file') ; + + $this->menuReorder->reorder($menu, 'sylius_cms', 'marketing'); } } diff --git a/src/Menu/MenuReorder.php b/src/Menu/MenuReorder.php new file mode 100644 index 000000000..a57fa8c94 --- /dev/null +++ b/src/Menu/MenuReorder.php @@ -0,0 +1,32 @@ +getChildren(); + + $newMenuItem = $menu->getChild($newItemKey); + unset($menuItems[$newItemKey]); + + $targetPosition = array_search($targetItemKey, array_keys($menuItems), true); + + if (null !== $newMenuItem && false !== $targetPosition) { + $menuItems = array_slice($menuItems, 0, $targetPosition + 1, true) + + [$newItemKey => $newMenuItem] + + array_slice($menuItems, $targetPosition + 1, null, true); + + $menuItems = array_filter($menuItems, static function ($item) { + return $item instanceof ItemInterface; + }); + + $menu->setChildren($menuItems); + } + } +} diff --git a/src/Menu/MenuReorderInterface.php b/src/Menu/MenuReorderInterface.php new file mode 100644 index 000000000..98b086ee6 --- /dev/null +++ b/src/Menu/MenuReorderInterface.php @@ -0,0 +1,12 @@ +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->addSql('ALTER TABLE bitbag_cms_section_pages DROP FOREIGN KEY FK_C96225EED823E37A'); + $this->addSql('ALTER TABLE bitbag_cms_section_pages DROP FOREIGN KEY FK_C96225EEC4663E4'); + $this->addSql('ALTER TABLE bitbag_cms_section_blocks DROP FOREIGN KEY FK_A9D9C974D823E37A'); + $this->addSql('ALTER TABLE bitbag_cms_section_blocks DROP FOREIGN KEY FK_A9D9C974E9ED820C'); + $this->addSql('ALTER TABLE bitbag_cms_section_media DROP FOREIGN KEY FK_833A6197D823E37A'); + $this->addSql('ALTER TABLE bitbag_cms_section_media DROP FOREIGN KEY FK_833A6197EA9FDD75'); + $this->addSql('DROP TABLE bitbag_cms_section_pages'); + $this->addSql('DROP TABLE bitbag_cms_section_blocks'); + $this->addSql('DROP TABLE bitbag_cms_section_media'); + $this->addSql('ALTER TABLE bitbag_cms_section DROP type'); + } +} diff --git a/src/Migrations/Version20240701100702.php b/src/Migrations/Version20240701100702.php new file mode 100644 index 000000000..8247e1938 --- /dev/null +++ b/src/Migrations/Version20240701100702.php @@ -0,0 +1,74 @@ +addSql('CREATE TABLE bitbag_cms_block_locales (block_id INT NOT NULL, locale_id INT NOT NULL, INDEX IDX_E1F907BAE9ED820C (block_id), INDEX IDX_E1F907BAE559DFD1 (locale_id), PRIMARY KEY(block_id, locale_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE bitbag_cms_content_configuration (id INT AUTO_INCREMENT NOT NULL, block_id INT DEFAULT NULL, page_id INT DEFAULT NULL, type VARCHAR(255) NOT NULL, configuration JSON NOT NULL COMMENT \'(DC2Type:json)\', INDEX IDX_D899EFA7E9ED820C (block_id), INDEX IDX_D899EFA7C4663E4 (page_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE bitbag_cms_page_locales (page_id INT NOT NULL, locale_id INT NOT NULL, INDEX IDX_EF20FD23C4663E4 (page_id), INDEX IDX_EF20FD23E559DFD1 (locale_id), PRIMARY KEY(page_id, locale_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('ALTER TABLE bitbag_cms_block_locales ADD CONSTRAINT FK_E1F907BAE9ED820C FOREIGN KEY (block_id) REFERENCES bitbag_cms_block (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE bitbag_cms_block_locales ADD CONSTRAINT FK_E1F907BAE559DFD1 FOREIGN KEY (locale_id) REFERENCES sylius_locale (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE bitbag_cms_content_configuration ADD CONSTRAINT FK_D899EFA7E9ED820C FOREIGN KEY (block_id) REFERENCES bitbag_cms_block (id)'); + $this->addSql('ALTER TABLE bitbag_cms_content_configuration ADD CONSTRAINT FK_D899EFA7C4663E4 FOREIGN KEY (page_id) REFERENCES bitbag_cms_page (id)'); + $this->addSql('ALTER TABLE bitbag_cms_page_locales ADD CONSTRAINT FK_EF20FD23C4663E4 FOREIGN KEY (page_id) REFERENCES bitbag_cms_page (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE bitbag_cms_page_locales ADD CONSTRAINT FK_EF20FD23E559DFD1 FOREIGN KEY (locale_id) REFERENCES sylius_locale (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE bitbag_cms_block_taxonomies DROP FOREIGN KEY FK_10C3E429DE13F470'); + $this->addSql('ALTER TABLE bitbag_cms_block_taxonomies DROP FOREIGN KEY FK_10C3E429E9ED820C'); + $this->addSql('ALTER TABLE bitbag_cms_page_products DROP FOREIGN KEY FK_4D64FA854584665A'); + $this->addSql('ALTER TABLE bitbag_cms_page_products DROP FOREIGN KEY FK_4D64FA85C4663E4'); + $this->addSql('ALTER TABLE bitbag_cms_block_products DROP FOREIGN KEY FK_C4B9089F4584665A'); + $this->addSql('ALTER TABLE bitbag_cms_block_products DROP FOREIGN KEY FK_C4B9089FE9ED820C'); + $this->addSql('ALTER TABLE bitbag_cms_block_translation DROP FOREIGN KEY FK_32897FDF2C2AC5D3'); + $this->addSql('DROP TABLE bitbag_cms_block_taxonomies'); + $this->addSql('DROP TABLE bitbag_cms_page_products'); + $this->addSql('DROP TABLE bitbag_cms_block_products'); + $this->addSql('DROP TABLE bitbag_cms_block_translation'); + $this->addSql('ALTER TABLE bitbag_cms_block ADD name VARCHAR(250) DEFAULT NULL'); + $this->addSql('ALTER TABLE bitbag_cms_page ADD name VARCHAR(255) DEFAULT NULL'); + $this->addSql('ALTER TABLE bitbag_cms_page_translation DROP FOREIGN KEY FK_FDD074A63DA5256D'); + $this->addSql('DROP INDEX IDX_FDD074A63DA5256D ON bitbag_cms_page_translation'); + $this->addSql('ALTER TABLE bitbag_cms_page_translation DROP image_id, DROP name, DROP breadcrumb, DROP name_when_linked, DROP description_when_linked, DROP content'); + } + + public function down(Schema $schema): void + { + $this->addSql('CREATE TABLE bitbag_cms_block_taxonomies (block_id INT NOT NULL, taxon_id INT NOT NULL, INDEX IDX_10C3E429E9ED820C (block_id), INDEX IDX_10C3E429DE13F470 (taxon_id), PRIMARY KEY(block_id, taxon_id)) DEFAULT CHARACTER SET utf8mb3 COLLATE `utf8mb3_unicode_ci` ENGINE = InnoDB COMMENT = \'\' '); + $this->addSql('CREATE TABLE bitbag_cms_page_products (page_id INT NOT NULL, product_id INT NOT NULL, INDEX IDX_4D64FA85C4663E4 (page_id), INDEX IDX_4D64FA854584665A (product_id), PRIMARY KEY(page_id, product_id)) DEFAULT CHARACTER SET utf8mb3 COLLATE `utf8mb3_unicode_ci` ENGINE = InnoDB COMMENT = \'\' '); + $this->addSql('CREATE TABLE bitbag_cms_block_products (block_id INT NOT NULL, product_id INT NOT NULL, INDEX IDX_C4B9089FE9ED820C (block_id), INDEX IDX_C4B9089F4584665A (product_id), PRIMARY KEY(block_id, product_id)) DEFAULT CHARACTER SET utf8mb3 COLLATE `utf8mb3_unicode_ci` ENGINE = InnoDB COMMENT = \'\' '); + $this->addSql('CREATE TABLE bitbag_cms_block_translation (id INT AUTO_INCREMENT NOT NULL, translatable_id INT NOT NULL, content LONGTEXT CHARACTER SET utf8mb3 DEFAULT NULL COLLATE `utf8mb3_unicode_ci`, locale VARCHAR(255) CHARACTER SET utf8mb3 NOT NULL COLLATE `utf8mb3_unicode_ci`, name VARCHAR(255) CHARACTER SET utf8mb3 DEFAULT NULL COLLATE `utf8mb3_unicode_ci`, link LONGTEXT CHARACTER SET utf8mb3 DEFAULT NULL COLLATE `utf8mb3_unicode_ci`, INDEX IDX_32897FDF2C2AC5D3 (translatable_id), UNIQUE INDEX bitbag_cms_block_translation_uniq_trans (translatable_id, locale), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb3 COLLATE `utf8mb3_unicode_ci` ENGINE = InnoDB COMMENT = \'\' '); + $this->addSql('ALTER TABLE bitbag_cms_block_taxonomies ADD CONSTRAINT FK_10C3E429DE13F470 FOREIGN KEY (taxon_id) REFERENCES sylius_taxon (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE bitbag_cms_block_taxonomies ADD CONSTRAINT FK_10C3E429E9ED820C FOREIGN KEY (block_id) REFERENCES bitbag_cms_block (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE bitbag_cms_page_products ADD CONSTRAINT FK_4D64FA854584665A FOREIGN KEY (product_id) REFERENCES sylius_product (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE bitbag_cms_page_products ADD CONSTRAINT FK_4D64FA85C4663E4 FOREIGN KEY (page_id) REFERENCES bitbag_cms_page (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE bitbag_cms_block_products ADD CONSTRAINT FK_C4B9089F4584665A FOREIGN KEY (product_id) REFERENCES sylius_product (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE bitbag_cms_block_products ADD CONSTRAINT FK_C4B9089FE9ED820C FOREIGN KEY (block_id) REFERENCES bitbag_cms_block (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE bitbag_cms_block_translation ADD CONSTRAINT FK_32897FDF2C2AC5D3 FOREIGN KEY (translatable_id) REFERENCES bitbag_cms_block (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE bitbag_cms_block_locales DROP FOREIGN KEY FK_E1F907BAE9ED820C'); + $this->addSql('ALTER TABLE bitbag_cms_block_locales DROP FOREIGN KEY FK_E1F907BAE559DFD1'); + $this->addSql('ALTER TABLE bitbag_cms_content_configuration DROP FOREIGN KEY FK_D899EFA7E9ED820C'); + $this->addSql('ALTER TABLE bitbag_cms_content_configuration DROP FOREIGN KEY FK_D899EFA7C4663E4'); + $this->addSql('ALTER TABLE bitbag_cms_page_locales DROP FOREIGN KEY FK_EF20FD23C4663E4'); + $this->addSql('ALTER TABLE bitbag_cms_page_locales DROP FOREIGN KEY FK_EF20FD23E559DFD1'); + $this->addSql('DROP TABLE bitbag_cms_block_locales'); + $this->addSql('DROP TABLE bitbag_cms_content_configuration'); + $this->addSql('DROP TABLE bitbag_cms_page_locales'); + $this->addSql('ALTER TABLE bitbag_cms_page_translation ADD image_id INT DEFAULT NULL, ADD name VARCHAR(255) DEFAULT NULL, ADD breadcrumb VARCHAR(255) DEFAULT NULL, ADD name_when_linked VARCHAR(255) DEFAULT NULL, ADD description_when_linked VARCHAR(1000) DEFAULT NULL, ADD content LONGTEXT DEFAULT NULL'); + $this->addSql('ALTER TABLE bitbag_cms_page_translation ADD CONSTRAINT FK_FDD074A63DA5256D FOREIGN KEY (image_id) REFERENCES bitbag_cms_media (id)'); + $this->addSql('CREATE INDEX IDX_FDD074A63DA5256D ON bitbag_cms_page_translation (image_id)'); + $this->addSql('ALTER TABLE bitbag_cms_block DROP name'); + $this->addSql('ALTER TABLE bitbag_cms_page DROP name'); + } +} diff --git a/src/Migrations/Version20240701104206.php b/src/Migrations/Version20240701104206.php new file mode 100644 index 000000000..f41f702c8 --- /dev/null +++ b/src/Migrations/Version20240701104206.php @@ -0,0 +1,30 @@ + Collection)'; + } + + public function up(Schema $schema): void + { + $this->addSql('ALTER TABLE bitbag_cms_section_translation DROP FOREIGN KEY FK_F99CA8582C2AC5D3'); + $this->addSql('DROP TABLE bitbag_cms_section_translation'); + $this->addSql('ALTER TABLE bitbag_cms_section ADD name VARCHAR(250) DEFAULT NULL'); + } + + public function down(Schema $schema): void + { + $this->addSql('CREATE TABLE bitbag_cms_section_translation (id INT AUTO_INCREMENT NOT NULL, translatable_id INT NOT NULL, name VARCHAR(255) CHARACTER SET utf8mb4 DEFAULT NULL COLLATE `utf8mb4_unicode_ci`, locale VARCHAR(255) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`, 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 COMMENT = \'\' '); + $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 DROP name'); + } +} diff --git a/src/Migrations/Version20240703083513.php b/src/Migrations/Version20240703083513.php new file mode 100644 index 000000000..7f6455242 --- /dev/null +++ b/src/Migrations/Version20240703083513.php @@ -0,0 +1,28 @@ +addSql('ALTER TABLE bitbag_cms_media ADD name VARCHAR(255) DEFAULT NULL'); + $this->addSql('ALTER TABLE bitbag_cms_media_translation DROP name'); + } + + public function down(Schema $schema): void + { + $this->addSql('ALTER TABLE bitbag_cms_media DROP name'); + $this->addSql('ALTER TABLE bitbag_cms_media_translation ADD name VARCHAR(255) DEFAULT NULL'); + } +} diff --git a/src/Migrations/Version20240715083336.php b/src/Migrations/Version20240715083336.php new file mode 100644 index 000000000..5a50216f1 --- /dev/null +++ b/src/Migrations/Version20240715083336.php @@ -0,0 +1,38 @@ +addSql('ALTER TABLE bitbag_cms_media_channels DROP FOREIGN KEY FK_D109622EE9ED820C'); + $this->addSql('DROP INDEX IDX_D109622EE9ED820C ON bitbag_cms_media_channels'); + $this->addSql('DROP INDEX `primary` ON bitbag_cms_media_channels'); + $this->addSql('ALTER TABLE bitbag_cms_media_channels CHANGE block_id media_id INT NOT NULL'); + $this->addSql('ALTER TABLE bitbag_cms_media_channels ADD CONSTRAINT FK_D109622EEA9FDD75 FOREIGN KEY (media_id) REFERENCES bitbag_cms_media (id) ON DELETE CASCADE'); + $this->addSql('CREATE INDEX IDX_D109622EEA9FDD75 ON bitbag_cms_media_channels (media_id)'); + $this->addSql('ALTER TABLE bitbag_cms_media_channels ADD PRIMARY KEY (media_id, channel_id)'); + } + + public function down(Schema $schema): void + { + $this->addSql('ALTER TABLE bitbag_cms_media_channels DROP FOREIGN KEY FK_D109622EEA9FDD75'); + $this->addSql('DROP INDEX IDX_D109622EEA9FDD75 ON bitbag_cms_media_channels'); + $this->addSql('DROP INDEX `PRIMARY` ON bitbag_cms_media_channels'); + $this->addSql('ALTER TABLE bitbag_cms_media_channels CHANGE media_id block_id INT NOT NULL'); + $this->addSql('ALTER TABLE bitbag_cms_media_channels ADD CONSTRAINT FK_D109622EE9ED820C FOREIGN KEY (block_id) REFERENCES bitbag_cms_media (id) ON DELETE CASCADE'); + $this->addSql('CREATE INDEX IDX_D109622EE9ED820C ON bitbag_cms_media_channels (block_id)'); + $this->addSql('ALTER TABLE bitbag_cms_media_channels ADD PRIMARY KEY (block_id, channel_id)'); + } +} diff --git a/src/Migrations/Version20240719070318.php b/src/Migrations/Version20240719070318.php new file mode 100644 index 000000000..7aa419b18 --- /dev/null +++ b/src/Migrations/Version20240719070318.php @@ -0,0 +1,42 @@ +addSql('CREATE TABLE bitbag_cms_block_products (block_id INT NOT NULL, product_id INT NOT NULL, INDEX IDX_C4B9089FE9ED820C (block_id), INDEX IDX_C4B9089F4584665A (product_id), PRIMARY KEY(block_id, product_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE bitbag_cms_block_taxons (block_id INT NOT NULL, taxon_id INT NOT NULL, INDEX IDX_E324C6CEE9ED820C (block_id), INDEX IDX_E324C6CEDE13F470 (taxon_id), PRIMARY KEY(block_id, taxon_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE bitbag_cms_block_products_in_taxons (block_id INT NOT NULL, taxon_id INT NOT NULL, INDEX IDX_DAA9DD18E9ED820C (block_id), INDEX IDX_DAA9DD18DE13F470 (taxon_id), PRIMARY KEY(block_id, taxon_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('ALTER TABLE bitbag_cms_block_products ADD CONSTRAINT FK_C4B9089FE9ED820C FOREIGN KEY (block_id) REFERENCES bitbag_cms_block (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE bitbag_cms_block_products ADD CONSTRAINT FK_C4B9089F4584665A FOREIGN KEY (product_id) REFERENCES sylius_product (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE bitbag_cms_block_taxons ADD CONSTRAINT FK_E324C6CEE9ED820C FOREIGN KEY (block_id) REFERENCES bitbag_cms_block (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE bitbag_cms_block_taxons ADD CONSTRAINT FK_E324C6CEDE13F470 FOREIGN KEY (taxon_id) REFERENCES sylius_taxon (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE bitbag_cms_block_products_in_taxons ADD CONSTRAINT FK_DAA9DD18E9ED820C FOREIGN KEY (block_id) REFERENCES bitbag_cms_block (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE bitbag_cms_block_products_in_taxons ADD CONSTRAINT FK_DAA9DD18DE13F470 FOREIGN KEY (taxon_id) REFERENCES sylius_taxon (id) ON DELETE CASCADE'); + } + + public function down(Schema $schema): void + { + $this->addSql('ALTER TABLE bitbag_cms_block_products DROP FOREIGN KEY FK_C4B9089FE9ED820C'); + $this->addSql('ALTER TABLE bitbag_cms_block_products DROP FOREIGN KEY FK_C4B9089F4584665A'); + $this->addSql('ALTER TABLE bitbag_cms_block_taxons DROP FOREIGN KEY FK_E324C6CEE9ED820C'); + $this->addSql('ALTER TABLE bitbag_cms_block_taxons DROP FOREIGN KEY FK_E324C6CEDE13F470'); + $this->addSql('ALTER TABLE bitbag_cms_block_products_in_taxons DROP FOREIGN KEY FK_DAA9DD18E9ED820C'); + $this->addSql('ALTER TABLE bitbag_cms_block_products_in_taxons DROP FOREIGN KEY FK_DAA9DD18DE13F470'); + $this->addSql('DROP TABLE bitbag_cms_block_products'); + $this->addSql('DROP TABLE bitbag_cms_block_taxons'); + $this->addSql('DROP TABLE bitbag_cms_block_products_in_taxons'); + } +} diff --git a/src/Migrations/Version20240725064430.php b/src/Migrations/Version20240725064430.php new file mode 100644 index 000000000..360db7fa9 --- /dev/null +++ b/src/Migrations/Version20240725064430.php @@ -0,0 +1,30 @@ +addSql('ALTER TABLE bitbag_cms_page_locales DROP FOREIGN KEY FK_EF20FD23C4663E4'); + $this->addSql('ALTER TABLE bitbag_cms_page_locales DROP FOREIGN KEY FK_EF20FD23E559DFD1'); + $this->addSql('DROP TABLE bitbag_cms_page_locales'); + } + + public function down(Schema $schema): void + { + $this->addSql('CREATE TABLE bitbag_cms_page_locales (page_id INT NOT NULL, locale_id INT NOT NULL, INDEX IDX_EF20FD23E559DFD1 (locale_id), INDEX IDX_EF20FD23C4663E4 (page_id), PRIMARY KEY(page_id, locale_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB COMMENT = \'\' '); + $this->addSql('ALTER TABLE bitbag_cms_page_locales ADD CONSTRAINT FK_EF20FD23C4663E4 FOREIGN KEY (page_id) REFERENCES bitbag_cms_page (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE bitbag_cms_page_locales ADD CONSTRAINT FK_EF20FD23E559DFD1 FOREIGN KEY (locale_id) REFERENCES sylius_locale (id) ON DELETE CASCADE'); + } +} diff --git a/src/Migrations/Version20240730084203.php b/src/Migrations/Version20240730084203.php new file mode 100644 index 000000000..49091e004 --- /dev/null +++ b/src/Migrations/Version20240730084203.php @@ -0,0 +1,26 @@ +addSql('CREATE TABLE bitbag_cms_template (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(250) DEFAULT NULL, type VARCHAR(250) DEFAULT NULL, content_elements JSON NOT NULL COMMENT \'(DC2Type:json)\', PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + } + + public function down(Schema $schema): void + { + $this->addSql('DROP TABLE bitbag_cms_template'); + } +} diff --git a/src/Migrations/Version20240808102216.php b/src/Migrations/Version20240808102216.php new file mode 100644 index 000000000..f94cca22b --- /dev/null +++ b/src/Migrations/Version20240808102216.php @@ -0,0 +1,30 @@ +addSql('ALTER TABLE bitbag_cms_page ADD teaser_image_id INT DEFAULT NULL, ADD teaser_title VARCHAR(255) DEFAULT NULL, ADD teaser_content LONGTEXT DEFAULT NULL'); + $this->addSql('ALTER TABLE bitbag_cms_page ADD CONSTRAINT FK_18F07F1BF56F16CF FOREIGN KEY (teaser_image_id) REFERENCES bitbag_cms_media (id) ON DELETE SET NULL'); + $this->addSql('CREATE INDEX IDX_18F07F1BF56F16CF ON bitbag_cms_page (teaser_image_id)'); + } + + public function down(Schema $schema): void + { + $this->addSql('ALTER TABLE bitbag_cms_page DROP FOREIGN KEY FK_18F07F1BF56F16CF'); + $this->addSql('DROP INDEX IDX_18F07F1BF56F16CF ON bitbag_cms_page'); + $this->addSql('ALTER TABLE bitbag_cms_page DROP teaser_image_id, DROP teaser_title, DROP teaser_content'); + } +} diff --git a/src/Migrations/Version20240809091751.php b/src/Migrations/Version20240809091751.php new file mode 100644 index 000000000..cecf54e53 --- /dev/null +++ b/src/Migrations/Version20240809091751.php @@ -0,0 +1,42 @@ +addSql('ALTER TABLE bitbag_cms_block_sections DROP FOREIGN KEY FK_5C95115DD823E37A'); + $this->addSql('ALTER TABLE bitbag_cms_block_sections DROP FOREIGN KEY FK_5C95115DE9ED820C'); + $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_media_sections DROP FOREIGN KEY FK_98BC300D823E37A'); + $this->addSql('ALTER TABLE bitbag_cms_media_sections DROP FOREIGN KEY FK_98BC300EA9FDD75'); + $this->addSql('DROP TABLE bitbag_cms_block_sections'); + $this->addSql('DROP TABLE bitbag_cms_page_sections'); + $this->addSql('DROP TABLE bitbag_cms_media_sections'); + } + + public function down(Schema $schema): void + { + $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 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 utf8mb4 COLLATE `utf8mb4_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_98BC300EA9FDD75 (media_id), INDEX IDX_98BC300D823E37A (section_id), PRIMARY KEY(media_id, section_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB COMMENT = \'\' '); + $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_block_sections ADD CONSTRAINT FK_5C95115DE9ED820C FOREIGN KEY (block_id) REFERENCES bitbag_cms_block (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_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'); + } +} diff --git a/src/Migrations/Version20240827113741.php b/src/Migrations/Version20240827113741.php new file mode 100644 index 000000000..0d433cf8e --- /dev/null +++ b/src/Migrations/Version20240827113741.php @@ -0,0 +1,185 @@ +addSql('ALTER TABLE bitbag_cms_block_taxons DROP FOREIGN KEY FK_E324C6CEDE13F470'); + $this->addSql('ALTER TABLE bitbag_cms_block_taxons DROP FOREIGN KEY FK_E324C6CEE9ED820C'); + $this->addSql('ALTER TABLE bitbag_cms_faq_translation DROP FOREIGN KEY FK_8B30DD2E2C2AC5D3'); + $this->addSql('ALTER TABLE bitbag_cms_page_channels DROP FOREIGN KEY FK_DCA426972F5A1AA'); + $this->addSql('ALTER TABLE bitbag_cms_page_channels DROP FOREIGN KEY FK_DCA4269C4663E4'); + $this->addSql('ALTER TABLE bitbag_cms_block_channels DROP FOREIGN KEY FK_8417B07372F5A1AA'); + $this->addSql('ALTER TABLE bitbag_cms_block_channels DROP FOREIGN KEY FK_8417B073E9ED820C'); + $this->addSql('ALTER TABLE bitbag_cms_block_products_in_taxons DROP FOREIGN KEY FK_DAA9DD18E9ED820C'); + $this->addSql('ALTER TABLE bitbag_cms_block_products_in_taxons DROP FOREIGN KEY FK_DAA9DD18DE13F470'); + $this->addSql('ALTER TABLE bitbag_cms_media_products DROP FOREIGN KEY FK_91A7DAC24584665A'); + $this->addSql('ALTER TABLE bitbag_cms_media_products DROP FOREIGN KEY FK_91A7DAC2EA9FDD75'); + $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_media_translation DROP FOREIGN KEY FK_1FEC58972C2AC5D3'); + $this->addSql('ALTER TABLE bitbag_cms_page_translation DROP FOREIGN KEY FK_FDD074A62C2AC5D3'); + $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_block_products DROP FOREIGN KEY FK_C4B9089F4584665A'); + $this->addSql('ALTER TABLE bitbag_cms_block_products DROP FOREIGN KEY FK_C4B9089FE9ED820C'); + $this->addSql('ALTER TABLE bitbag_cms_page DROP FOREIGN KEY FK_18F07F1BF56F16CF'); + $this->addSql('ALTER TABLE bitbag_cms_block_locales DROP FOREIGN KEY FK_E1F907BAE559DFD1'); + $this->addSql('ALTER TABLE bitbag_cms_block_locales DROP FOREIGN KEY FK_E1F907BAE9ED820C'); + $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('ALTER TABLE bitbag_cms_content_configuration DROP FOREIGN KEY FK_D899EFA7E9ED820C'); + $this->addSql('ALTER TABLE bitbag_cms_content_configuration DROP FOREIGN KEY FK_D899EFA7C4663E4'); + $this->addSql('ALTER TABLE bitbag_cms_media_channels DROP FOREIGN KEY FK_D109622E72F5A1AA'); + $this->addSql('ALTER TABLE bitbag_cms_media_channels DROP FOREIGN KEY FK_D109622EEA9FDD75'); + $this->addSql('ALTER TABLE bitbag_cms_faq_channels DROP FOREIGN KEY FK_FF6D59AC72F5A1AA'); + $this->addSql('ALTER TABLE bitbag_cms_faq_channels DROP FOREIGN KEY FK_FF6D59AC81BEC8C2'); + + $this->addSql('RENAME TABLE bitbag_cms_template TO sylius_cms_template'); + $this->addSql('RENAME TABLE bitbag_cms_media TO sylius_cms_media'); + $this->addSql('RENAME TABLE bitbag_cms_block TO sylius_cms_block'); + $this->addSql('RENAME TABLE bitbag_cms_block_taxons TO sylius_cms_block_taxons'); + $this->addSql('RENAME TABLE bitbag_cms_page_channels TO sylius_cms_page_channels'); + $this->addSql('RENAME TABLE bitbag_cms_block_channels TO sylius_cms_block_channels'); + $this->addSql('RENAME TABLE bitbag_cms_block_products_in_taxons TO sylius_cms_block_products_in_taxons'); + $this->addSql('RENAME TABLE bitbag_cms_section_pages TO sylius_cms_section_pages'); + $this->addSql('RENAME TABLE bitbag_cms_media_translation TO sylius_cms_media_translation'); + $this->addSql('RENAME TABLE bitbag_cms_page_translation TO sylius_cms_page_translation'); + $this->addSql('RENAME TABLE bitbag_cms_section_blocks TO sylius_cms_section_blocks'); + $this->addSql('RENAME TABLE bitbag_cms_block_products TO sylius_cms_block_products'); + $this->addSql('RENAME TABLE bitbag_cms_page TO sylius_cms_page'); + $this->addSql('RENAME TABLE bitbag_cms_section TO sylius_cms_section'); + $this->addSql('RENAME TABLE bitbag_cms_block_locales TO sylius_cms_block_locales'); + $this->addSql('RENAME TABLE bitbag_cms_section_media TO sylius_cms_section_media'); + $this->addSql('RENAME TABLE bitbag_cms_content_configuration TO sylius_cms_content_configuration'); + $this->addSql('RENAME TABLE bitbag_cms_media_channels TO sylius_cms_media_channels'); + + $this->addSql('ALTER TABLE sylius_cms_block_channels ADD CONSTRAINT FK_7026602FE9ED820C FOREIGN KEY (block_id) REFERENCES sylius_cms_block (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE sylius_cms_block_channels ADD CONSTRAINT FK_7026602F72F5A1AA FOREIGN KEY (channel_id) REFERENCES sylius_channel (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE sylius_cms_block_locales ADD CONSTRAINT FK_49C0AACE9ED820C FOREIGN KEY (block_id) REFERENCES sylius_cms_block (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE sylius_cms_block_locales ADD CONSTRAINT FK_49C0AACE559DFD1 FOREIGN KEY (locale_id) REFERENCES sylius_locale (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE sylius_cms_block_products ADD CONSTRAINT FK_3088D8C3E9ED820C FOREIGN KEY (block_id) REFERENCES sylius_cms_block (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE sylius_cms_block_products ADD CONSTRAINT FK_3088D8C34584665A FOREIGN KEY (product_id) REFERENCES sylius_product (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE sylius_cms_block_taxons ADD CONSTRAINT FK_5397DD03E9ED820C FOREIGN KEY (block_id) REFERENCES sylius_cms_block (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE sylius_cms_block_taxons ADD CONSTRAINT FK_5397DD03DE13F470 FOREIGN KEY (taxon_id) REFERENCES sylius_taxon (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE sylius_cms_block_products_in_taxons ADD CONSTRAINT FK_B4D0B7CEE9ED820C FOREIGN KEY (block_id) REFERENCES sylius_cms_block (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE sylius_cms_block_products_in_taxons ADD CONSTRAINT FK_B4D0B7CEDE13F470 FOREIGN KEY (taxon_id) REFERENCES sylius_taxon (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE sylius_cms_content_configuration ADD CONSTRAINT FK_BB97608DE9ED820C FOREIGN KEY (block_id) REFERENCES sylius_cms_block (id)'); + $this->addSql('ALTER TABLE sylius_cms_content_configuration ADD CONSTRAINT FK_BB97608DC4663E4 FOREIGN KEY (page_id) REFERENCES sylius_cms_page (id)'); + $this->addSql('ALTER TABLE sylius_cms_media_channels ADD CONSTRAINT FK_2538B272EA9FDD75 FOREIGN KEY (media_id) REFERENCES sylius_cms_media (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE sylius_cms_media_channels ADD CONSTRAINT FK_2538B27272F5A1AA FOREIGN KEY (channel_id) REFERENCES sylius_channel (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE sylius_cms_media_translation ADD CONSTRAINT FK_AAAC4A922C2AC5D3 FOREIGN KEY (translatable_id) REFERENCES sylius_cms_media (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE sylius_cms_page ADD CONSTRAINT FK_2C2740B2F56F16CF FOREIGN KEY (teaser_image_id) REFERENCES sylius_cms_media (id) ON DELETE SET NULL'); + $this->addSql('ALTER TABLE sylius_cms_page_channels ADD CONSTRAINT FK_E8AF4F7FC4663E4 FOREIGN KEY (page_id) REFERENCES sylius_cms_page (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE sylius_cms_page_channels ADD CONSTRAINT FK_E8AF4F7F72F5A1AA FOREIGN KEY (channel_id) REFERENCES sylius_channel (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE sylius_cms_page_translation ADD CONSTRAINT FK_6D0D401B2C2AC5D3 FOREIGN KEY (translatable_id) REFERENCES sylius_cms_page (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE sylius_cms_section_pages ADD CONSTRAINT FK_2C0728F8D823E37A FOREIGN KEY (section_id) REFERENCES sylius_cms_section (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE sylius_cms_section_pages ADD CONSTRAINT FK_2C0728F8C4663E4 FOREIGN KEY (page_id) REFERENCES sylius_cms_page (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE sylius_cms_section_blocks ADD CONSTRAINT FK_5DE81928D823E37A FOREIGN KEY (section_id) REFERENCES sylius_cms_section (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE sylius_cms_section_blocks ADD CONSTRAINT FK_5DE81928E9ED820C FOREIGN KEY (block_id) REFERENCES sylius_cms_block (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE sylius_cms_section_media ADD CONSTRAINT FK_665F6C81D823E37A FOREIGN KEY (section_id) REFERENCES sylius_cms_section (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE sylius_cms_section_media ADD CONSTRAINT FK_665F6C81EA9FDD75 FOREIGN KEY (media_id) REFERENCES sylius_cms_media (id) ON DELETE CASCADE'); + + $this->addSql('DROP TABLE bitbag_cms_faq_translation'); + $this->addSql('DROP TABLE bitbag_cms_media_products'); + $this->addSql('DROP TABLE bitbag_cms_faq'); + $this->addSql('DROP TABLE bitbag_cms_faq_channels'); + } + + public function down(Schema $schema): void + { + $this->addSql('ALTER TABLE sylius_cms_block_channels DROP FOREIGN KEY FK_7026602FE9ED820C'); + $this->addSql('ALTER TABLE sylius_cms_block_channels DROP FOREIGN KEY FK_7026602F72F5A1AA'); + $this->addSql('ALTER TABLE sylius_cms_block_locales DROP FOREIGN KEY FK_49C0AACE9ED820C'); + $this->addSql('ALTER TABLE sylius_cms_block_locales DROP FOREIGN KEY FK_49C0AACE559DFD1'); + $this->addSql('ALTER TABLE sylius_cms_block_products DROP FOREIGN KEY FK_3088D8C3E9ED820C'); + $this->addSql('ALTER TABLE sylius_cms_block_products DROP FOREIGN KEY FK_3088D8C34584665A'); + $this->addSql('ALTER TABLE sylius_cms_block_taxons DROP FOREIGN KEY FK_5397DD03E9ED820C'); + $this->addSql('ALTER TABLE sylius_cms_block_taxons DROP FOREIGN KEY FK_5397DD03DE13F470'); + $this->addSql('ALTER TABLE sylius_cms_block_products_in_taxons DROP FOREIGN KEY FK_B4D0B7CEE9ED820C'); + $this->addSql('ALTER TABLE sylius_cms_block_products_in_taxons DROP FOREIGN KEY FK_B4D0B7CEDE13F470'); + $this->addSql('ALTER TABLE sylius_cms_content_configuration DROP FOREIGN KEY FK_BB97608DE9ED820C'); + $this->addSql('ALTER TABLE sylius_cms_content_configuration DROP FOREIGN KEY FK_BB97608DC4663E4'); + $this->addSql('ALTER TABLE sylius_cms_media_channels DROP FOREIGN KEY FK_2538B272EA9FDD75'); + $this->addSql('ALTER TABLE sylius_cms_media_channels DROP FOREIGN KEY FK_2538B27272F5A1AA'); + $this->addSql('ALTER TABLE sylius_cms_media_translation DROP FOREIGN KEY FK_AAAC4A922C2AC5D3'); + $this->addSql('ALTER TABLE sylius_cms_page DROP FOREIGN KEY FK_2C2740B2F56F16CF'); + $this->addSql('ALTER TABLE sylius_cms_page_channels DROP FOREIGN KEY FK_E8AF4F7FC4663E4'); + $this->addSql('ALTER TABLE sylius_cms_page_channels DROP FOREIGN KEY FK_E8AF4F7F72F5A1AA'); + $this->addSql('ALTER TABLE sylius_cms_page_translation DROP FOREIGN KEY FK_6D0D401B2C2AC5D3'); + $this->addSql('ALTER TABLE sylius_cms_section_pages DROP FOREIGN KEY FK_2C0728F8D823E37A'); + $this->addSql('ALTER TABLE sylius_cms_section_pages DROP FOREIGN KEY FK_2C0728F8C4663E4'); + $this->addSql('ALTER TABLE sylius_cms_section_blocks DROP FOREIGN KEY FK_5DE81928D823E37A'); + $this->addSql('ALTER TABLE sylius_cms_section_blocks DROP FOREIGN KEY FK_5DE81928E9ED820C'); + $this->addSql('ALTER TABLE sylius_cms_section_media DROP FOREIGN KEY FK_665F6C81D823E37A'); + $this->addSql('ALTER TABLE sylius_cms_section_media DROP FOREIGN KEY FK_665F6C81EA9FDD75'); + + $this->addSql('RENAME TABLE sylius_cms_template TO bitbag_cms_template'); + $this->addSql('RENAME TABLE sylius_cms_media TO bitbag_cms_media'); + $this->addSql('RENAME TABLE sylius_cms_block TO bitbag_cms_block'); + $this->addSql('RENAME TABLE sylius_cms_block_taxons TO bitbag_cms_block_taxons'); + $this->addSql('RENAME TABLE sylius_cms_page_channels TO bitbag_cms_page_channels'); + $this->addSql('RENAME TABLE sylius_cms_block_channels TO bitbag_cms_block_channels'); + $this->addSql('RENAME TABLE sylius_cms_block_products_in_taxons TO bitbag_cms_block_products_in_taxons'); + $this->addSql('RENAME TABLE sylius_cms_section_pages TO bitbag_cms_section_pages'); + $this->addSql('RENAME TABLE sylius_cms_media_translation TO bitbag_cms_media_translation'); + $this->addSql('RENAME TABLE sylius_cms_page_translation TO bitbag_cms_page_translation'); + $this->addSql('RENAME TABLE sylius_cms_section_blocks TO bitbag_cms_section_blocks'); + $this->addSql('RENAME TABLE sylius_cms_block_products TO bitbag_cms_block_products'); + $this->addSql('RENAME TABLE sylius_cms_page TO bitbag_cms_page'); + $this->addSql('RENAME TABLE sylius_cms_section TO bitbag_cms_section'); + $this->addSql('RENAME TABLE sylius_cms_block_locales TO bitbag_cms_block_locales'); + $this->addSql('RENAME TABLE sylius_cms_section_media TO bitbag_cms_section_media'); + $this->addSql('RENAME TABLE sylius_cms_content_configuration TO bitbag_cms_content_configuration'); + $this->addSql('RENAME TABLE sylius_cms_media_channels TO bitbag_cms_media_channels'); + + $this->addSql('ALTER TABLE bitbag_cms_block_taxons ADD CONSTRAINT FK_E324C6CEDE13F470 FOREIGN KEY (taxon_id) REFERENCES sylius_taxon (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE bitbag_cms_block_taxons ADD CONSTRAINT FK_E324C6CEE9ED820C FOREIGN KEY (block_id) REFERENCES bitbag_cms_block (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE bitbag_cms_page_channels ADD CONSTRAINT FK_DCA426972F5A1AA FOREIGN KEY (channel_id) REFERENCES sylius_channel (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE bitbag_cms_page_channels ADD CONSTRAINT FK_DCA4269C4663E4 FOREIGN KEY (page_id) REFERENCES bitbag_cms_page (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE bitbag_cms_block_channels ADD CONSTRAINT FK_8417B07372F5A1AA FOREIGN KEY (channel_id) REFERENCES sylius_channel (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE bitbag_cms_block_channels ADD CONSTRAINT FK_8417B073E9ED820C FOREIGN KEY (block_id) REFERENCES bitbag_cms_block (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE bitbag_cms_block_products_in_taxons ADD CONSTRAINT FK_DAA9DD18E9ED820C FOREIGN KEY (block_id) REFERENCES bitbag_cms_block (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE bitbag_cms_block_products_in_taxons ADD CONSTRAINT FK_DAA9DD18DE13F470 FOREIGN KEY (taxon_id) REFERENCES sylius_taxon (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_media_translation ADD CONSTRAINT FK_1FEC58972C2AC5D3 FOREIGN KEY (translatable_id) REFERENCES bitbag_cms_media (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE bitbag_cms_page_translation ADD CONSTRAINT FK_FDD074A62C2AC5D3 FOREIGN KEY (translatable_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_block_products ADD CONSTRAINT FK_C4B9089F4584665A FOREIGN KEY (product_id) REFERENCES sylius_product (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE bitbag_cms_block_products ADD CONSTRAINT FK_C4B9089FE9ED820C FOREIGN KEY (block_id) REFERENCES bitbag_cms_block (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE bitbag_cms_page ADD CONSTRAINT FK_18F07F1BF56F16CF FOREIGN KEY (teaser_image_id) REFERENCES bitbag_cms_media (id) ON DELETE SET NULL'); + $this->addSql('ALTER TABLE bitbag_cms_block_locales ADD CONSTRAINT FK_E1F907BAE559DFD1 FOREIGN KEY (locale_id) REFERENCES sylius_locale (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE bitbag_cms_block_locales ADD CONSTRAINT FK_E1F907BAE9ED820C 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_content_configuration ADD CONSTRAINT FK_D899EFA7E9ED820C FOREIGN KEY (block_id) REFERENCES bitbag_cms_block (id)'); + $this->addSql('ALTER TABLE bitbag_cms_content_configuration ADD CONSTRAINT FK_D899EFA7C4663E4 FOREIGN KEY (page_id) REFERENCES bitbag_cms_page (id)'); + $this->addSql('ALTER TABLE bitbag_cms_media_channels ADD CONSTRAINT FK_D109622E72F5A1AA FOREIGN KEY (channel_id) REFERENCES sylius_channel (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE bitbag_cms_media_channels ADD CONSTRAINT FK_D109622EEA9FDD75 FOREIGN KEY (media_id) REFERENCES bitbag_cms_media (id) ON DELETE CASCADE'); + + $this->addSql('CREATE TABLE bitbag_cms_faq_translation (id INT AUTO_INCREMENT NOT NULL, translatable_id INT NOT NULL, question LONGTEXT CHARACTER SET utf8 NOT NULL COLLATE `utf8_unicode_ci`, answer LONGTEXT CHARACTER SET utf8 NOT NULL COLLATE `utf8_unicode_ci`, locale VARCHAR(255) CHARACTER SET utf8 NOT NULL COLLATE `utf8_unicode_ci`, INDEX IDX_8B30DD2E2C2AC5D3 (translatable_id), UNIQUE INDEX bitbag_cms_faq_translation_uniq_trans (translatable_id, locale), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB COMMENT = \'\' '); + $this->addSql('CREATE TABLE bitbag_cms_media_products (media_id INT NOT NULL, product_id INT NOT NULL, INDEX IDX_91A7DAC2EA9FDD75 (media_id), INDEX IDX_91A7DAC24584665A (product_id), PRIMARY KEY(media_id, product_id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB COMMENT = \'\' '); + $this->addSql('CREATE TABLE bitbag_cms_faq (id INT AUTO_INCREMENT NOT NULL, code VARCHAR(255) CHARACTER SET utf8 NOT NULL COLLATE `utf8_unicode_ci`, position INT NOT NULL, enabled TINYINT(1) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB COMMENT = \'\' '); + $this->addSql('CREATE TABLE bitbag_cms_faq_channels (faq_id INT NOT NULL, channel_id INT NOT NULL, INDEX IDX_FF6D59AC81BEC8C2 (faq_id), INDEX IDX_FF6D59AC72F5A1AA (channel_id), PRIMARY KEY(faq_id, channel_id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB COMMENT = \'\' '); + + $this->addSql('ALTER TABLE bitbag_cms_faq_translation ADD CONSTRAINT FK_8B30DD2E2C2AC5D3 FOREIGN KEY (translatable_id) REFERENCES bitbag_cms_faq (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE bitbag_cms_media_products ADD CONSTRAINT FK_91A7DAC24584665A FOREIGN KEY (product_id) REFERENCES sylius_product (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE bitbag_cms_media_products ADD CONSTRAINT FK_91A7DAC2EA9FDD75 FOREIGN KEY (media_id) REFERENCES bitbag_cms_media (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE bitbag_cms_faq_channels ADD CONSTRAINT FK_FF6D59AC72F5A1AA FOREIGN KEY (channel_id) REFERENCES sylius_channel (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE bitbag_cms_faq_channels ADD CONSTRAINT FK_FF6D59AC81BEC8C2 FOREIGN KEY (faq_id) REFERENCES bitbag_cms_faq (id) ON DELETE CASCADE'); + } +} diff --git a/src/Migrations/Version20240903103926.php b/src/Migrations/Version20240903103926.php new file mode 100644 index 000000000..5b466df32 --- /dev/null +++ b/src/Migrations/Version20240903103926.php @@ -0,0 +1,252 @@ +addSql('DROP INDEX uniq_321c84cf77153098 ON sylius_cms_block'); + $this->addSql('CREATE UNIQUE INDEX UNIQ_9D2248BC77153098 ON sylius_cms_block (code)'); + $this->addSql('ALTER TABLE sylius_cms_block_channels DROP FOREIGN KEY FK_7026602F72F5A1AA'); + $this->addSql('ALTER TABLE sylius_cms_block_channels DROP FOREIGN KEY FK_7026602FE9ED820C'); + $this->addSql('DROP INDEX idx_8417b073e9ed820c ON sylius_cms_block_channels'); + $this->addSql('CREATE INDEX IDX_7026602FE9ED820C ON sylius_cms_block_channels (block_id)'); + $this->addSql('DROP INDEX idx_8417b07372f5a1aa ON sylius_cms_block_channels'); + $this->addSql('CREATE INDEX IDX_7026602F72F5A1AA ON sylius_cms_block_channels (channel_id)'); + $this->addSql('ALTER TABLE sylius_cms_block_channels ADD CONSTRAINT FK_7026602F72F5A1AA FOREIGN KEY (channel_id) REFERENCES sylius_channel (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE sylius_cms_block_channels ADD CONSTRAINT FK_7026602FE9ED820C FOREIGN KEY (block_id) REFERENCES sylius_cms_block (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE sylius_cms_block_locales DROP FOREIGN KEY FK_49C0AACE559DFD1'); + $this->addSql('ALTER TABLE sylius_cms_block_locales DROP FOREIGN KEY FK_49C0AACE9ED820C'); + $this->addSql('DROP INDEX idx_e1f907bae9ed820c ON sylius_cms_block_locales'); + $this->addSql('CREATE INDEX IDX_49C0AACE9ED820C ON sylius_cms_block_locales (block_id)'); + $this->addSql('DROP INDEX idx_e1f907bae559dfd1 ON sylius_cms_block_locales'); + $this->addSql('CREATE INDEX IDX_49C0AACE559DFD1 ON sylius_cms_block_locales (locale_id)'); + $this->addSql('ALTER TABLE sylius_cms_block_locales ADD CONSTRAINT FK_49C0AACE559DFD1 FOREIGN KEY (locale_id) REFERENCES sylius_locale (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE sylius_cms_block_locales ADD CONSTRAINT FK_49C0AACE9ED820C FOREIGN KEY (block_id) REFERENCES sylius_cms_block (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE sylius_cms_block_products DROP FOREIGN KEY FK_3088D8C3E9ED820C'); + $this->addSql('ALTER TABLE sylius_cms_block_products DROP FOREIGN KEY FK_3088D8C34584665A'); + $this->addSql('DROP INDEX idx_c4b9089fe9ed820c ON sylius_cms_block_products'); + $this->addSql('CREATE INDEX IDX_3088D8C3E9ED820C ON sylius_cms_block_products (block_id)'); + $this->addSql('DROP INDEX idx_c4b9089f4584665a ON sylius_cms_block_products'); + $this->addSql('CREATE INDEX IDX_3088D8C34584665A ON sylius_cms_block_products (product_id)'); + $this->addSql('ALTER TABLE sylius_cms_block_products ADD CONSTRAINT FK_3088D8C3E9ED820C FOREIGN KEY (block_id) REFERENCES sylius_cms_block (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE sylius_cms_block_products ADD CONSTRAINT FK_3088D8C34584665A FOREIGN KEY (product_id) REFERENCES sylius_product (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE sylius_cms_block_taxons DROP FOREIGN KEY FK_5397DD03E9ED820C'); + $this->addSql('ALTER TABLE sylius_cms_block_taxons DROP FOREIGN KEY FK_5397DD03DE13F470'); + $this->addSql('DROP INDEX idx_e324c6cee9ed820c ON sylius_cms_block_taxons'); + $this->addSql('CREATE INDEX IDX_5397DD03E9ED820C ON sylius_cms_block_taxons (block_id)'); + $this->addSql('DROP INDEX idx_e324c6cede13f470 ON sylius_cms_block_taxons'); + $this->addSql('CREATE INDEX IDX_5397DD03DE13F470 ON sylius_cms_block_taxons (taxon_id)'); + $this->addSql('ALTER TABLE sylius_cms_block_taxons ADD CONSTRAINT FK_5397DD03E9ED820C FOREIGN KEY (block_id) REFERENCES sylius_cms_block (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE sylius_cms_block_taxons ADD CONSTRAINT FK_5397DD03DE13F470 FOREIGN KEY (taxon_id) REFERENCES sylius_taxon (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE sylius_cms_block_products_in_taxons DROP FOREIGN KEY FK_B4D0B7CEDE13F470'); + $this->addSql('ALTER TABLE sylius_cms_block_products_in_taxons DROP FOREIGN KEY FK_B4D0B7CEE9ED820C'); + $this->addSql('DROP INDEX idx_daa9dd18e9ed820c ON sylius_cms_block_products_in_taxons'); + $this->addSql('CREATE INDEX IDX_B4D0B7CEE9ED820C ON sylius_cms_block_products_in_taxons (block_id)'); + $this->addSql('DROP INDEX idx_daa9dd18de13f470 ON sylius_cms_block_products_in_taxons'); + $this->addSql('CREATE INDEX IDX_B4D0B7CEDE13F470 ON sylius_cms_block_products_in_taxons (taxon_id)'); + $this->addSql('ALTER TABLE sylius_cms_block_products_in_taxons ADD CONSTRAINT FK_B4D0B7CEDE13F470 FOREIGN KEY (taxon_id) REFERENCES sylius_taxon (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE sylius_cms_block_products_in_taxons ADD CONSTRAINT FK_B4D0B7CEE9ED820C FOREIGN KEY (block_id) REFERENCES sylius_cms_block (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE sylius_cms_content_configuration DROP FOREIGN KEY FK_BB97608DC4663E4'); + $this->addSql('ALTER TABLE sylius_cms_content_configuration DROP FOREIGN KEY FK_BB97608DE9ED820C'); + $this->addSql('DROP INDEX idx_d899efa7e9ed820c ON sylius_cms_content_configuration'); + $this->addSql('CREATE INDEX IDX_BB97608DE9ED820C ON sylius_cms_content_configuration (block_id)'); + $this->addSql('DROP INDEX idx_d899efa7c4663e4 ON sylius_cms_content_configuration'); + $this->addSql('CREATE INDEX IDX_BB97608DC4663E4 ON sylius_cms_content_configuration (page_id)'); + $this->addSql('ALTER TABLE sylius_cms_content_configuration ADD CONSTRAINT FK_BB97608DC4663E4 FOREIGN KEY (page_id) REFERENCES sylius_cms_page (id)'); + $this->addSql('ALTER TABLE sylius_cms_content_configuration ADD CONSTRAINT FK_BB97608DE9ED820C FOREIGN KEY (block_id) REFERENCES sylius_cms_block (id)'); + $this->addSql('DROP INDEX uniq_db2bb2e177153098 ON sylius_cms_media'); + $this->addSql('CREATE UNIQUE INDEX UNIQ_74157E9277153098 ON sylius_cms_media (code)'); + $this->addSql('DROP INDEX uniq_db2bb2e1b548b0f ON sylius_cms_media'); + $this->addSql('CREATE UNIQUE INDEX UNIQ_74157E92B548B0F ON sylius_cms_media (path)'); + $this->addSql('ALTER TABLE sylius_cms_media_channels DROP FOREIGN KEY FK_2538B27272F5A1AA'); + $this->addSql('ALTER TABLE sylius_cms_media_channels DROP FOREIGN KEY FK_2538B272EA9FDD75'); + $this->addSql('DROP INDEX idx_d109622eea9fdd75 ON sylius_cms_media_channels'); + $this->addSql('CREATE INDEX IDX_2538B272EA9FDD75 ON sylius_cms_media_channels (media_id)'); + $this->addSql('DROP INDEX idx_d109622e72f5a1aa ON sylius_cms_media_channels'); + $this->addSql('CREATE INDEX IDX_2538B27272F5A1AA ON sylius_cms_media_channels (channel_id)'); + $this->addSql('ALTER TABLE sylius_cms_media_channels ADD CONSTRAINT FK_2538B27272F5A1AA FOREIGN KEY (channel_id) REFERENCES sylius_channel (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE sylius_cms_media_channels ADD CONSTRAINT FK_2538B272EA9FDD75 FOREIGN KEY (media_id) REFERENCES sylius_cms_media (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE sylius_cms_media_translation DROP FOREIGN KEY FK_AAAC4A922C2AC5D3'); + $this->addSql('DROP INDEX idx_1fec58972c2ac5d3 ON sylius_cms_media_translation'); + $this->addSql('CREATE INDEX IDX_AAAC4A922C2AC5D3 ON sylius_cms_media_translation (translatable_id)'); + $this->addSql('DROP INDEX bitbag_cms_media_translation_uniq_trans ON sylius_cms_media_translation'); + $this->addSql('CREATE UNIQUE INDEX sylius_cms_media_translation_uniq_trans ON sylius_cms_media_translation (translatable_id, locale)'); + $this->addSql('ALTER TABLE sylius_cms_media_translation ADD CONSTRAINT FK_AAAC4A922C2AC5D3 FOREIGN KEY (translatable_id) REFERENCES sylius_cms_media (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE sylius_cms_page DROP FOREIGN KEY FK_2C2740B2F56F16CF'); + $this->addSql('DROP INDEX uniq_18f07f1b77153098 ON sylius_cms_page'); + $this->addSql('CREATE UNIQUE INDEX UNIQ_2C2740B277153098 ON sylius_cms_page (code)'); + $this->addSql('DROP INDEX idx_18f07f1bf56f16cf ON sylius_cms_page'); + $this->addSql('CREATE INDEX IDX_2C2740B2F56F16CF ON sylius_cms_page (teaser_image_id)'); + $this->addSql('ALTER TABLE sylius_cms_page ADD CONSTRAINT FK_2C2740B2F56F16CF FOREIGN KEY (teaser_image_id) REFERENCES sylius_cms_media (id) ON DELETE SET NULL'); + $this->addSql('ALTER TABLE sylius_cms_page_channels DROP FOREIGN KEY FK_E8AF4F7F72F5A1AA'); + $this->addSql('ALTER TABLE sylius_cms_page_channels DROP FOREIGN KEY FK_E8AF4F7FC4663E4'); + $this->addSql('DROP INDEX idx_dca4269c4663e4 ON sylius_cms_page_channels'); + $this->addSql('CREATE INDEX IDX_E8AF4F7FC4663E4 ON sylius_cms_page_channels (page_id)'); + $this->addSql('DROP INDEX idx_dca426972f5a1aa ON sylius_cms_page_channels'); + $this->addSql('CREATE INDEX IDX_E8AF4F7F72F5A1AA ON sylius_cms_page_channels (channel_id)'); + $this->addSql('ALTER TABLE sylius_cms_page_channels ADD CONSTRAINT FK_E8AF4F7F72F5A1AA FOREIGN KEY (channel_id) REFERENCES sylius_channel (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE sylius_cms_page_channels ADD CONSTRAINT FK_E8AF4F7FC4663E4 FOREIGN KEY (page_id) REFERENCES sylius_cms_page (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE sylius_cms_page_translation DROP FOREIGN KEY FK_6D0D401B2C2AC5D3'); + $this->addSql('DROP INDEX idx_fdd074a62c2ac5d3 ON sylius_cms_page_translation'); + $this->addSql('CREATE INDEX IDX_6D0D401B2C2AC5D3 ON sylius_cms_page_translation (translatable_id)'); + $this->addSql('DROP INDEX bitbag_cms_page_translation_uniq_trans ON sylius_cms_page_translation'); + $this->addSql('CREATE UNIQUE INDEX sylius_cms_page_translation_uniq_trans ON sylius_cms_page_translation (translatable_id, locale)'); + $this->addSql('ALTER TABLE sylius_cms_page_translation ADD CONSTRAINT FK_6D0D401B2C2AC5D3 FOREIGN KEY (translatable_id) REFERENCES sylius_cms_page (id) ON DELETE CASCADE'); + $this->addSql('DROP INDEX uniq_421d079777153098 ON sylius_cms_section'); + $this->addSql('CREATE UNIQUE INDEX UNIQ_D4DD0C0777153098 ON sylius_cms_section (code)'); + $this->addSql('ALTER TABLE sylius_cms_section_pages DROP FOREIGN KEY FK_2C0728F8D823E37A'); + $this->addSql('ALTER TABLE sylius_cms_section_pages DROP FOREIGN KEY FK_2C0728F8C4663E4'); + $this->addSql('DROP INDEX idx_c96225eed823e37a ON sylius_cms_section_pages'); + $this->addSql('CREATE INDEX IDX_2C0728F8D823E37A ON sylius_cms_section_pages (section_id)'); + $this->addSql('DROP INDEX idx_c96225eec4663e4 ON sylius_cms_section_pages'); + $this->addSql('CREATE INDEX IDX_2C0728F8C4663E4 ON sylius_cms_section_pages (page_id)'); + $this->addSql('ALTER TABLE sylius_cms_section_pages ADD CONSTRAINT FK_2C0728F8D823E37A FOREIGN KEY (section_id) REFERENCES sylius_cms_section (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE sylius_cms_section_pages ADD CONSTRAINT FK_2C0728F8C4663E4 FOREIGN KEY (page_id) REFERENCES sylius_cms_page (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE sylius_cms_section_blocks DROP FOREIGN KEY FK_5DE81928D823E37A'); + $this->addSql('ALTER TABLE sylius_cms_section_blocks DROP FOREIGN KEY FK_5DE81928E9ED820C'); + $this->addSql('DROP INDEX idx_a9d9c974d823e37a ON sylius_cms_section_blocks'); + $this->addSql('CREATE INDEX IDX_5DE81928D823E37A ON sylius_cms_section_blocks (section_id)'); + $this->addSql('DROP INDEX idx_a9d9c974e9ed820c ON sylius_cms_section_blocks'); + $this->addSql('CREATE INDEX IDX_5DE81928E9ED820C ON sylius_cms_section_blocks (block_id)'); + $this->addSql('ALTER TABLE sylius_cms_section_blocks ADD CONSTRAINT FK_5DE81928D823E37A FOREIGN KEY (section_id) REFERENCES sylius_cms_section (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE sylius_cms_section_blocks ADD CONSTRAINT FK_5DE81928E9ED820C FOREIGN KEY (block_id) REFERENCES sylius_cms_block (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE sylius_cms_section_media DROP FOREIGN KEY FK_665F6C81EA9FDD75'); + $this->addSql('ALTER TABLE sylius_cms_section_media DROP FOREIGN KEY FK_665F6C81D823E37A'); + $this->addSql('DROP INDEX idx_833a6197d823e37a ON sylius_cms_section_media'); + $this->addSql('CREATE INDEX IDX_665F6C81D823E37A ON sylius_cms_section_media (section_id)'); + $this->addSql('DROP INDEX idx_833a6197ea9fdd75 ON sylius_cms_section_media'); + $this->addSql('CREATE INDEX IDX_665F6C81EA9FDD75 ON sylius_cms_section_media (media_id)'); + $this->addSql('ALTER TABLE sylius_cms_section_media ADD CONSTRAINT FK_665F6C81EA9FDD75 FOREIGN KEY (media_id) REFERENCES sylius_cms_media (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE sylius_cms_section_media ADD CONSTRAINT FK_665F6C81D823E37A FOREIGN KEY (section_id) REFERENCES sylius_cms_section (id) ON DELETE CASCADE'); + } + + public function down(Schema $schema): void + { + $this->addSql('ALTER TABLE sylius_cms_block_products_in_taxons DROP FOREIGN KEY FK_B4D0B7CEE9ED820C'); + $this->addSql('ALTER TABLE sylius_cms_block_products_in_taxons DROP FOREIGN KEY FK_B4D0B7CEDE13F470'); + $this->addSql('DROP INDEX idx_b4d0b7cee9ed820c ON sylius_cms_block_products_in_taxons'); + $this->addSql('CREATE INDEX IDX_DAA9DD18E9ED820C ON sylius_cms_block_products_in_taxons (block_id)'); + $this->addSql('DROP INDEX idx_b4d0b7cede13f470 ON sylius_cms_block_products_in_taxons'); + $this->addSql('CREATE INDEX IDX_DAA9DD18DE13F470 ON sylius_cms_block_products_in_taxons (taxon_id)'); + $this->addSql('ALTER TABLE sylius_cms_block_products_in_taxons ADD CONSTRAINT FK_B4D0B7CEE9ED820C FOREIGN KEY (block_id) REFERENCES sylius_cms_block (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE sylius_cms_block_products_in_taxons ADD CONSTRAINT FK_B4D0B7CEDE13F470 FOREIGN KEY (taxon_id) REFERENCES sylius_taxon (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE sylius_cms_media_channels DROP FOREIGN KEY FK_2538B272EA9FDD75'); + $this->addSql('ALTER TABLE sylius_cms_media_channels DROP FOREIGN KEY FK_2538B27272F5A1AA'); + $this->addSql('DROP INDEX idx_2538b27272f5a1aa ON sylius_cms_media_channels'); + $this->addSql('CREATE INDEX IDX_D109622E72F5A1AA ON sylius_cms_media_channels (channel_id)'); + $this->addSql('DROP INDEX idx_2538b272ea9fdd75 ON sylius_cms_media_channels'); + $this->addSql('CREATE INDEX IDX_D109622EEA9FDD75 ON sylius_cms_media_channels (media_id)'); + $this->addSql('ALTER TABLE sylius_cms_media_channels ADD CONSTRAINT FK_2538B272EA9FDD75 FOREIGN KEY (media_id) REFERENCES sylius_cms_media (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE sylius_cms_media_channels ADD CONSTRAINT FK_2538B27272F5A1AA FOREIGN KEY (channel_id) REFERENCES sylius_channel (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE sylius_cms_section_pages DROP FOREIGN KEY FK_2C0728F8D823E37A'); + $this->addSql('ALTER TABLE sylius_cms_section_pages DROP FOREIGN KEY FK_2C0728F8C4663E4'); + $this->addSql('DROP INDEX idx_2c0728f8d823e37a ON sylius_cms_section_pages'); + $this->addSql('CREATE INDEX IDX_C96225EED823E37A ON sylius_cms_section_pages (section_id)'); + $this->addSql('DROP INDEX idx_2c0728f8c4663e4 ON sylius_cms_section_pages'); + $this->addSql('CREATE INDEX IDX_C96225EEC4663E4 ON sylius_cms_section_pages (page_id)'); + $this->addSql('ALTER TABLE sylius_cms_section_pages ADD CONSTRAINT FK_2C0728F8D823E37A FOREIGN KEY (section_id) REFERENCES sylius_cms_section (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE sylius_cms_section_pages ADD CONSTRAINT FK_2C0728F8C4663E4 FOREIGN KEY (page_id) REFERENCES sylius_cms_page (id) ON DELETE CASCADE'); + $this->addSql('DROP INDEX uniq_74157e9277153098 ON sylius_cms_media'); + $this->addSql('CREATE UNIQUE INDEX UNIQ_DB2BB2E177153098 ON sylius_cms_media (code)'); + $this->addSql('DROP INDEX uniq_74157e92b548b0f ON sylius_cms_media'); + $this->addSql('CREATE UNIQUE INDEX UNIQ_DB2BB2E1B548B0F ON sylius_cms_media (path)'); + $this->addSql('ALTER TABLE sylius_cms_page DROP FOREIGN KEY FK_2C2740B2F56F16CF'); + $this->addSql('DROP INDEX idx_2c2740b2f56f16cf ON sylius_cms_page'); + $this->addSql('CREATE INDEX IDX_18F07F1BF56F16CF ON sylius_cms_page (teaser_image_id)'); + $this->addSql('DROP INDEX uniq_2c2740b277153098 ON sylius_cms_page'); + $this->addSql('CREATE UNIQUE INDEX UNIQ_18F07F1B77153098 ON sylius_cms_page (code)'); + $this->addSql('ALTER TABLE sylius_cms_page ADD CONSTRAINT FK_2C2740B2F56F16CF FOREIGN KEY (teaser_image_id) REFERENCES sylius_cms_media (id) ON DELETE SET NULL'); + $this->addSql('ALTER TABLE sylius_cms_block_channels DROP FOREIGN KEY FK_7026602FE9ED820C'); + $this->addSql('ALTER TABLE sylius_cms_block_channels DROP FOREIGN KEY FK_7026602F72F5A1AA'); + $this->addSql('DROP INDEX idx_7026602f72f5a1aa ON sylius_cms_block_channels'); + $this->addSql('CREATE INDEX IDX_8417B07372F5A1AA ON sylius_cms_block_channels (channel_id)'); + $this->addSql('DROP INDEX idx_7026602fe9ed820c ON sylius_cms_block_channels'); + $this->addSql('CREATE INDEX IDX_8417B073E9ED820C ON sylius_cms_block_channels (block_id)'); + $this->addSql('ALTER TABLE sylius_cms_block_channels ADD CONSTRAINT FK_7026602FE9ED820C FOREIGN KEY (block_id) REFERENCES sylius_cms_block (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE sylius_cms_block_channels ADD CONSTRAINT FK_7026602F72F5A1AA FOREIGN KEY (channel_id) REFERENCES sylius_channel (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE sylius_cms_block_products DROP FOREIGN KEY FK_3088D8C3E9ED820C'); + $this->addSql('ALTER TABLE sylius_cms_block_products DROP FOREIGN KEY FK_3088D8C34584665A'); + $this->addSql('DROP INDEX idx_3088d8c3e9ed820c ON sylius_cms_block_products'); + $this->addSql('CREATE INDEX IDX_C4B9089FE9ED820C ON sylius_cms_block_products (block_id)'); + $this->addSql('DROP INDEX idx_3088d8c34584665a ON sylius_cms_block_products'); + $this->addSql('CREATE INDEX IDX_C4B9089F4584665A ON sylius_cms_block_products (product_id)'); + $this->addSql('ALTER TABLE sylius_cms_block_products ADD CONSTRAINT FK_3088D8C3E9ED820C FOREIGN KEY (block_id) REFERENCES sylius_cms_block (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE sylius_cms_block_products ADD CONSTRAINT FK_3088D8C34584665A FOREIGN KEY (product_id) REFERENCES sylius_product (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE sylius_cms_block_locales DROP FOREIGN KEY FK_49C0AACE9ED820C'); + $this->addSql('ALTER TABLE sylius_cms_block_locales DROP FOREIGN KEY FK_49C0AACE559DFD1'); + $this->addSql('DROP INDEX idx_49c0aace9ed820c ON sylius_cms_block_locales'); + $this->addSql('CREATE INDEX IDX_E1F907BAE9ED820C ON sylius_cms_block_locales (block_id)'); + $this->addSql('DROP INDEX idx_49c0aace559dfd1 ON sylius_cms_block_locales'); + $this->addSql('CREATE INDEX IDX_E1F907BAE559DFD1 ON sylius_cms_block_locales (locale_id)'); + $this->addSql('ALTER TABLE sylius_cms_block_locales ADD CONSTRAINT FK_49C0AACE9ED820C FOREIGN KEY (block_id) REFERENCES sylius_cms_block (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE sylius_cms_block_locales ADD CONSTRAINT FK_49C0AACE559DFD1 FOREIGN KEY (locale_id) REFERENCES sylius_locale (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE sylius_cms_media_translation DROP FOREIGN KEY FK_AAAC4A922C2AC5D3'); + $this->addSql('DROP INDEX idx_aaac4a922c2ac5d3 ON sylius_cms_media_translation'); + $this->addSql('CREATE INDEX IDX_1FEC58972C2AC5D3 ON sylius_cms_media_translation (translatable_id)'); + $this->addSql('DROP INDEX sylius_cms_media_translation_uniq_trans ON sylius_cms_media_translation'); + $this->addSql('CREATE UNIQUE INDEX bitbag_cms_media_translation_uniq_trans ON sylius_cms_media_translation (translatable_id, locale)'); + $this->addSql('ALTER TABLE sylius_cms_media_translation ADD CONSTRAINT FK_AAAC4A922C2AC5D3 FOREIGN KEY (translatable_id) REFERENCES sylius_cms_media (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE sylius_cms_page_channels DROP FOREIGN KEY FK_E8AF4F7FC4663E4'); + $this->addSql('ALTER TABLE sylius_cms_page_channels DROP FOREIGN KEY FK_E8AF4F7F72F5A1AA'); + $this->addSql('DROP INDEX idx_e8af4f7fc4663e4 ON sylius_cms_page_channels'); + $this->addSql('CREATE INDEX IDX_DCA4269C4663E4 ON sylius_cms_page_channels (page_id)'); + $this->addSql('DROP INDEX idx_e8af4f7f72f5a1aa ON sylius_cms_page_channels'); + $this->addSql('CREATE INDEX IDX_DCA426972F5A1AA ON sylius_cms_page_channels (channel_id)'); + $this->addSql('ALTER TABLE sylius_cms_page_channels ADD CONSTRAINT FK_E8AF4F7FC4663E4 FOREIGN KEY (page_id) REFERENCES sylius_cms_page (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE sylius_cms_page_channels ADD CONSTRAINT FK_E8AF4F7F72F5A1AA FOREIGN KEY (channel_id) REFERENCES sylius_channel (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE sylius_cms_content_configuration DROP FOREIGN KEY FK_BB97608DE9ED820C'); + $this->addSql('ALTER TABLE sylius_cms_content_configuration DROP FOREIGN KEY FK_BB97608DC4663E4'); + $this->addSql('DROP INDEX idx_bb97608de9ed820c ON sylius_cms_content_configuration'); + $this->addSql('CREATE INDEX IDX_D899EFA7E9ED820C ON sylius_cms_content_configuration (block_id)'); + $this->addSql('DROP INDEX idx_bb97608dc4663e4 ON sylius_cms_content_configuration'); + $this->addSql('CREATE INDEX IDX_D899EFA7C4663E4 ON sylius_cms_content_configuration (page_id)'); + $this->addSql('ALTER TABLE sylius_cms_content_configuration ADD CONSTRAINT FK_BB97608DE9ED820C FOREIGN KEY (block_id) REFERENCES sylius_cms_block (id)'); + $this->addSql('ALTER TABLE sylius_cms_content_configuration ADD CONSTRAINT FK_BB97608DC4663E4 FOREIGN KEY (page_id) REFERENCES sylius_cms_page (id)'); + $this->addSql('ALTER TABLE sylius_cms_section_media DROP FOREIGN KEY FK_665F6C81D823E37A'); + $this->addSql('ALTER TABLE sylius_cms_section_media DROP FOREIGN KEY FK_665F6C81EA9FDD75'); + $this->addSql('DROP INDEX idx_665f6c81ea9fdd75 ON sylius_cms_section_media'); + $this->addSql('CREATE INDEX IDX_833A6197EA9FDD75 ON sylius_cms_section_media (media_id)'); + $this->addSql('DROP INDEX idx_665f6c81d823e37a ON sylius_cms_section_media'); + $this->addSql('CREATE INDEX IDX_833A6197D823E37A ON sylius_cms_section_media (section_id)'); + $this->addSql('ALTER TABLE sylius_cms_section_media ADD CONSTRAINT FK_665F6C81D823E37A FOREIGN KEY (section_id) REFERENCES sylius_cms_section (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE sylius_cms_section_media ADD CONSTRAINT FK_665F6C81EA9FDD75 FOREIGN KEY (media_id) REFERENCES sylius_cms_media (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE sylius_cms_section_blocks DROP FOREIGN KEY FK_5DE81928D823E37A'); + $this->addSql('ALTER TABLE sylius_cms_section_blocks DROP FOREIGN KEY FK_5DE81928E9ED820C'); + $this->addSql('DROP INDEX idx_5de81928d823e37a ON sylius_cms_section_blocks'); + $this->addSql('CREATE INDEX IDX_A9D9C974D823E37A ON sylius_cms_section_blocks (section_id)'); + $this->addSql('DROP INDEX idx_5de81928e9ed820c ON sylius_cms_section_blocks'); + $this->addSql('CREATE INDEX IDX_A9D9C974E9ED820C ON sylius_cms_section_blocks (block_id)'); + $this->addSql('ALTER TABLE sylius_cms_section_blocks ADD CONSTRAINT FK_5DE81928D823E37A FOREIGN KEY (section_id) REFERENCES sylius_cms_section (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE sylius_cms_section_blocks ADD CONSTRAINT FK_5DE81928E9ED820C FOREIGN KEY (block_id) REFERENCES sylius_cms_block (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE sylius_cms_page_translation DROP FOREIGN KEY FK_6D0D401B2C2AC5D3'); + $this->addSql('DROP INDEX sylius_cms_page_translation_uniq_trans ON sylius_cms_page_translation'); + $this->addSql('CREATE UNIQUE INDEX bitbag_cms_page_translation_uniq_trans ON sylius_cms_page_translation (translatable_id, locale)'); + $this->addSql('DROP INDEX idx_6d0d401b2c2ac5d3 ON sylius_cms_page_translation'); + $this->addSql('CREATE INDEX IDX_FDD074A62C2AC5D3 ON sylius_cms_page_translation (translatable_id)'); + $this->addSql('ALTER TABLE sylius_cms_page_translation ADD CONSTRAINT FK_6D0D401B2C2AC5D3 FOREIGN KEY (translatable_id) REFERENCES sylius_cms_page (id) ON DELETE CASCADE'); + $this->addSql('DROP INDEX uniq_d4dd0c0777153098 ON sylius_cms_section'); + $this->addSql('CREATE UNIQUE INDEX UNIQ_421D079777153098 ON sylius_cms_section (code)'); + $this->addSql('DROP INDEX uniq_9d2248bc77153098 ON sylius_cms_block'); + $this->addSql('CREATE UNIQUE INDEX UNIQ_321C84CF77153098 ON sylius_cms_block (code)'); + $this->addSql('ALTER TABLE sylius_cms_block_taxons DROP FOREIGN KEY FK_5397DD03E9ED820C'); + $this->addSql('ALTER TABLE sylius_cms_block_taxons DROP FOREIGN KEY FK_5397DD03DE13F470'); + $this->addSql('DROP INDEX idx_5397dd03de13f470 ON sylius_cms_block_taxons'); + $this->addSql('CREATE INDEX IDX_E324C6CEDE13F470 ON sylius_cms_block_taxons (taxon_id)'); + $this->addSql('DROP INDEX idx_5397dd03e9ed820c ON sylius_cms_block_taxons'); + $this->addSql('CREATE INDEX IDX_E324C6CEE9ED820C ON sylius_cms_block_taxons (block_id)'); + $this->addSql('ALTER TABLE sylius_cms_block_taxons ADD CONSTRAINT FK_5397DD03E9ED820C FOREIGN KEY (block_id) REFERENCES sylius_cms_block (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE sylius_cms_block_taxons ADD CONSTRAINT FK_5397DD03DE13F470 FOREIGN KEY (taxon_id) REFERENCES sylius_taxon (id) ON DELETE CASCADE'); + } +} diff --git a/src/Migrations/Version20240910113936.php b/src/Migrations/Version20240910113936.php new file mode 100644 index 000000000..f65ad059e --- /dev/null +++ b/src/Migrations/Version20240910113936.php @@ -0,0 +1,36 @@ +addSql('ALTER TABLE sylius_cms_page DROP FOREIGN KEY FK_2C2740B2F56F16CF'); + $this->addSql('DROP INDEX IDX_2C2740B2F56F16CF ON sylius_cms_page'); + $this->addSql('ALTER TABLE sylius_cms_page DROP teaser_image_id, DROP teaser_title, DROP teaser_content'); + $this->addSql('ALTER TABLE sylius_cms_page_translation ADD teaser_image_id INT DEFAULT NULL, ADD teaser_title VARCHAR(255) DEFAULT NULL, ADD teaser_content LONGTEXT DEFAULT NULL'); + $this->addSql('ALTER TABLE sylius_cms_page_translation ADD CONSTRAINT FK_6D0D401BF56F16CF FOREIGN KEY (teaser_image_id) REFERENCES sylius_cms_media (id) ON DELETE SET NULL'); + $this->addSql('CREATE INDEX IDX_6D0D401BF56F16CF ON sylius_cms_page_translation (teaser_image_id)'); + } + + public function down(Schema $schema): void + { + $this->addSql('ALTER TABLE sylius_cms_page ADD teaser_image_id INT DEFAULT NULL, ADD teaser_title VARCHAR(255) DEFAULT NULL, ADD teaser_content LONGTEXT DEFAULT NULL'); + $this->addSql('ALTER TABLE sylius_cms_page ADD CONSTRAINT FK_2C2740B2F56F16CF FOREIGN KEY (teaser_image_id) REFERENCES sylius_cms_media (id) ON DELETE SET NULL'); + $this->addSql('CREATE INDEX IDX_2C2740B2F56F16CF ON sylius_cms_page (teaser_image_id)'); + $this->addSql('ALTER TABLE sylius_cms_page_translation DROP FOREIGN KEY FK_6D0D401BF56F16CF'); + $this->addSql('DROP INDEX IDX_6D0D401BF56F16CF ON sylius_cms_page_translation'); + $this->addSql('ALTER TABLE sylius_cms_page_translation DROP teaser_image_id, DROP teaser_title, DROP teaser_content'); + } +} diff --git a/src/Migrations/Version20240912094638.php b/src/Migrations/Version20240912094638.php new file mode 100644 index 000000000..80e6e51ae --- /dev/null +++ b/src/Migrations/Version20240912094638.php @@ -0,0 +1,31 @@ +addSql('ALTER TABLE sylius_cms_content_configuration ADD locale VARCHAR(255) NOT NULL'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('ALTER TABLE sylius_cms_content_configuration DROP locale'); + } +} diff --git a/src/Migrations/Version20240916100051.php b/src/Migrations/Version20240916100051.php new file mode 100644 index 000000000..a7ee9501f --- /dev/null +++ b/src/Migrations/Version20240916100051.php @@ -0,0 +1,30 @@ +addSql('ALTER TABLE sylius_cms_block_locales DROP FOREIGN KEY FK_49C0AACE559DFD1'); + $this->addSql('ALTER TABLE sylius_cms_block_locales DROP FOREIGN KEY FK_49C0AACE9ED820C'); + $this->addSql('DROP TABLE sylius_cms_block_locales'); + } + + public function down(Schema $schema): void + { + $this->addSql('CREATE TABLE sylius_cms_block_locales (block_id INT NOT NULL, locale_id INT NOT NULL, INDEX IDX_49C0AACE9ED820C (block_id), INDEX IDX_49C0AACE559DFD1 (locale_id), PRIMARY KEY(block_id, locale_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB COMMENT = \'\' '); + $this->addSql('ALTER TABLE sylius_cms_block_locales ADD CONSTRAINT FK_49C0AACE559DFD1 FOREIGN KEY (locale_id) REFERENCES sylius_locale (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE sylius_cms_block_locales ADD CONSTRAINT FK_49C0AACE9ED820C FOREIGN KEY (block_id) REFERENCES sylius_cms_block (id) ON DELETE CASCADE'); + } +} diff --git a/src/Migrations/Version20240918091924.php b/src/Migrations/Version20240918091924.php new file mode 100644 index 000000000..cc3e30242 --- /dev/null +++ b/src/Migrations/Version20240918091924.php @@ -0,0 +1,28 @@ +addSql('ALTER TABLE sylius_cms_block ADD template VARCHAR(250) DEFAULT NULL'); + $this->addSql('ALTER TABLE sylius_cms_page ADD template VARCHAR(250) DEFAULT NULL'); + } + + public function down(Schema $schema): void + { + $this->addSql('ALTER TABLE sylius_cms_block DROP template'); + $this->addSql('ALTER TABLE sylius_cms_page DROP template'); + } +} diff --git a/src/Processor/ImportProcessor.php b/src/Processor/ImportProcessor.php index 2b32379a9..f06277dab 100644 --- a/src/Processor/ImportProcessor.php +++ b/src/Processor/ImportProcessor.php @@ -1,19 +1,13 @@ importerChain->getImporterForResource($resourceCode); + $importer = $this->importerChain->getImporterForResource($resourceName); $data = $this->reader->read($filePath); foreach ($data as $index => $row) { try { $importer->import($row); } catch (\Exception $exception) { - $index += 1; + ++$index; throw new ImportFailedException($exception->getMessage(), $index); } diff --git a/src/Processor/ImportProcessorInterface.php b/src/Processor/ImportProcessorInterface.php index 325e045a6..8760fc1eb 100644 --- a/src/Processor/ImportProcessorInterface.php +++ b/src/Processor/ImportProcessorInterface.php @@ -1,14 +1,8 @@ get('sylius_cms.templates.pages'))) { + $this->templates['pages'] = $params->get('sylius_cms.templates.pages'); + } + + if (is_array($params->get('sylius_cms.templates.blocks'))) { + $this->templates['blocks'] = $params->get('sylius_cms.templates.blocks'); + } + } + + public function getPageTemplates(): array + { + $keys = ['sylius.ui.default']; + $values = ['@SyliusCmsPlugin/Shop/Page/show.html.twig']; + + return array_combine( + array_merge($keys, $this->templates['pages']), + array_merge($values, $this->templates['pages']), + ); + } + + public function getBlockTemplates(): array + { + $keys = ['sylius.ui.default']; + $values = ['@SyliusCmsPlugin/Shop/Block/show.html.twig']; + + return array_combine( + array_merge($keys, $this->templates['blocks']), + array_merge($values, $this->templates['blocks']), + ); + } +} diff --git a/src/Provider/ResourceTemplateProviderInterface.php b/src/Provider/ResourceTemplateProviderInterface.php new file mode 100644 index 000000000..34536ea24 --- /dev/null +++ b/src/Provider/ResourceTemplateProviderInterface.php @@ -0,0 +1,12 @@ +setHeaderOffset(0)->getIterator(); + return Reader::createFromPath($filePath)->setHeaderOffset(0)->getIterator(); } } diff --git a/src/Reader/ReaderInterface.php b/src/Reader/ReaderInterface.php index 71eb55e79..4aaa54490 100755 --- a/src/Reader/ReaderInterface.php +++ b/src/Reader/ReaderInterface.php @@ -1,14 +1,8 @@ getBlocks()); + /** @var BlockInterface $block */ + foreach (SorterById::sort($collection->getBlocks()->toArray()) as $block) { + $content .= $this->contentElementRendererStrategy->render($block); + if (++$iterator === $countToRender) { + break; + } + } + + return $content; + } + + public function supports(CollectionInterface $collection): bool + { + return 0 < $collection->getBlocks()?->count(); + } +} diff --git a/src/Renderer/Collection/CollectionMediaRenderer.php b/src/Renderer/Collection/CollectionMediaRenderer.php new file mode 100644 index 000000000..1330dfba4 --- /dev/null +++ b/src/Renderer/Collection/CollectionMediaRenderer.php @@ -0,0 +1,40 @@ +getMedia()); + /** @var MediaInterface $media */ + foreach (SorterById::sort($collection->getMedia()->toArray()) as $media) { + Assert::notNull($media->getCode()); + $content .= $this->renderMediaRuntime->renderMedia($media->getCode()); + if (++$iterator === $countToRender) { + break; + } + } + + return $content; + } + + public function supports(CollectionInterface $collection): bool + { + return 0 < $collection->getMedia()?->count(); + } +} diff --git a/src/Renderer/Collection/CollectionPagesRenderer.php b/src/Renderer/Collection/CollectionPagesRenderer.php new file mode 100644 index 000000000..1f11d0eb8 --- /dev/null +++ b/src/Renderer/Collection/CollectionPagesRenderer.php @@ -0,0 +1,39 @@ +getPages()); + /** @var PageInterface $page */ + foreach (SorterById::sort($collection->getPages()->toArray(), 'desc') as $page) { + $content .= $this->pageLinkRenderer->render($page); + if (++$iterator === $countToRender) { + break; + } + } + + return $content; + } + + public function supports(CollectionInterface $collection): bool + { + return 0 < $collection->getPages()?->count(); + } +} diff --git a/src/Renderer/Collection/CollectionRendererInterface.php b/src/Renderer/Collection/CollectionRendererInterface.php new file mode 100644 index 000000000..0e92b2e52 --- /dev/null +++ b/src/Renderer/Collection/CollectionRendererInterface.php @@ -0,0 +1,14 @@ +renderers as $renderer) { + if ($renderer->supports($collection)) { + return $renderer->render($collection, $countToRender); + } + } + + return ''; + } +} diff --git a/src/Renderer/CollectionRendererStrategyInterface.php b/src/Renderer/CollectionRendererStrategyInterface.php new file mode 100644 index 000000000..f541d7d6c --- /dev/null +++ b/src/Renderer/CollectionRendererStrategyInterface.php @@ -0,0 +1,12 @@ +template = $template; + } + + public function setTwigEnvironment(Environment $twig): void + { + $this->twig = $twig; + } +} diff --git a/src/Renderer/ContentElement/ContentElementRendererInterface.php b/src/Renderer/ContentElement/ContentElementRendererInterface.php new file mode 100644 index 000000000..add27e6dd --- /dev/null +++ b/src/Renderer/ContentElement/ContentElementRendererInterface.php @@ -0,0 +1,14 @@ +getType(); + } + + public function render(ContentConfigurationInterface $contentConfiguration): string + { + $configuration = $contentConfiguration->getConfiguration(); + $headingType = $configuration['heading_type']; + $headingContent = $configuration['heading']; + + return $this->twig->render('@SyliusCmsPlugin/Shop/ContentElement/index.html.twig', [ + 'content_element' => $this->template, + 'heading_type' => $headingType, + 'heading_content' => $headingContent, + ]); + } +} diff --git a/src/Renderer/ContentElement/MultipleMediaContentElementRenderer.php b/src/Renderer/ContentElement/MultipleMediaContentElementRenderer.php new file mode 100644 index 000000000..940221ee5 --- /dev/null +++ b/src/Renderer/ContentElement/MultipleMediaContentElementRenderer.php @@ -0,0 +1,51 @@ +getType(); + } + + public function render(ContentConfigurationInterface $contentConfiguration): string + { + $media = []; + $codes = $contentConfiguration->getConfiguration()['multiple_media']; + + /** @var MediaInterface[] $mediaEntities */ + $mediaEntities = $this->mediaRepository->findBy(['code' => $codes]); + $mediaEntitiesByCode = array_reduce($mediaEntities, static function (array $result, MediaInterface $media) { + $result[$media->getCode()] = $media; + + return $result; + }, []); + + foreach ($codes as $code) { + $media[] = [ + 'renderedContent' => $this->renderMediaRuntime->renderMedia($code), + 'entity' => $mediaEntitiesByCode[$code], + ]; + } + + return $this->twig->render('@SyliusCmsPlugin/Shop/ContentElement/index.html.twig', [ + 'content_element' => $this->template, + 'media' => $media, + ]); + } +} diff --git a/src/Renderer/ContentElement/PagesCollectionContentElementRenderer.php b/src/Renderer/ContentElement/PagesCollectionContentElementRenderer.php new file mode 100644 index 000000000..09899c3b2 --- /dev/null +++ b/src/Renderer/ContentElement/PagesCollectionContentElementRenderer.php @@ -0,0 +1,39 @@ +getType(); + } + + public function render(ContentConfigurationInterface $contentConfiguration): string + { + $code = $contentConfiguration->getConfiguration()['pages_collection']; + if (null === $code) { + return ''; + } + + /** @var CollectionInterface|null $collection */ + $collection = $this->collectionRepository->findOneBy(['code' => $code]); + + return $this->twig->render('@SyliusCmsPlugin/Shop/ContentElement/index.html.twig', [ + 'content_element' => $this->template, + 'collection' => $collection?->getPages(), + ]); + } +} diff --git a/src/Renderer/ContentElement/ProductsCarouselByTaxonContentElementRenderer.php b/src/Renderer/ContentElement/ProductsCarouselByTaxonContentElementRenderer.php new file mode 100644 index 000000000..a8963857b --- /dev/null +++ b/src/Renderer/ContentElement/ProductsCarouselByTaxonContentElementRenderer.php @@ -0,0 +1,43 @@ +getType(); + } + + public function render(ContentConfigurationInterface $contentConfiguration): string + { + $taxonCode = $contentConfiguration->getConfiguration()['products_carousel_by_taxon']; + + /** @var TaxonInterface|null $taxon */ + $taxon = $this->taxonRepository->findOneBy(['code' => $taxonCode]); + if (null === $taxon) { + return ''; + } + + $products = $this->productRepository->findByTaxon($taxon); + + return $this->twig->render('@SyliusCmsPlugin/Shop/ContentElement/index.html.twig', [ + 'content_element' => $this->template, + 'products' => $products, + ]); + } +} diff --git a/src/Renderer/ContentElement/ProductsCarouselContentElementRenderer.php b/src/Renderer/ContentElement/ProductsCarouselContentElementRenderer.php new file mode 100644 index 000000000..058f234d4 --- /dev/null +++ b/src/Renderer/ContentElement/ProductsCarouselContentElementRenderer.php @@ -0,0 +1,37 @@ +getType(); + } + + public function render(ContentConfigurationInterface $contentConfiguration): string + { + $configuration = $contentConfiguration->getConfiguration(); + $productsCodes = $configuration['products_carousel']['products']; + $products = $this->productRepository->findBy(['code' => $productsCodes]); + if (empty($products)) { + return ''; + } + + return $this->twig->render('@SyliusCmsPlugin/Shop/ContentElement/index.html.twig', [ + 'content_element' => $this->template, + 'products' => $products, + ]); + } +} diff --git a/src/Renderer/ContentElement/ProductsGridByTaxonContentElementRenderer.php b/src/Renderer/ContentElement/ProductsGridByTaxonContentElementRenderer.php new file mode 100644 index 000000000..3f8743e16 --- /dev/null +++ b/src/Renderer/ContentElement/ProductsGridByTaxonContentElementRenderer.php @@ -0,0 +1,43 @@ +getType(); + } + + public function render(ContentConfigurationInterface $contentConfiguration): string + { + $taxonCode = $contentConfiguration->getConfiguration()['products_grid_by_taxon']; + + /** @var TaxonInterface|null $taxon */ + $taxon = $this->taxonRepository->findOneBy(['code' => $taxonCode]); + if (null === $taxon) { + return ''; + } + + $products = $this->productRepository->findByTaxon($taxon); + + return $this->twig->render('@SyliusCmsPlugin/Shop/ContentElement/index.html.twig', [ + 'content_element' => $this->template, + 'products' => $products, + ]); + } +} diff --git a/src/Renderer/ContentElement/ProductsGridContentElementRenderer.php b/src/Renderer/ContentElement/ProductsGridContentElementRenderer.php new file mode 100644 index 000000000..5fd30d311 --- /dev/null +++ b/src/Renderer/ContentElement/ProductsGridContentElementRenderer.php @@ -0,0 +1,34 @@ +getType(); + } + + public function render(ContentConfigurationInterface $contentConfiguration): string + { + $configuration = $contentConfiguration->getConfiguration(); + $productsCodes = $configuration['products_grid']['products']; + $products = $this->productRepository->findBy(['code' => $productsCodes]); + + return $this->twig->render('@SyliusCmsPlugin/Shop/ContentElement/index.html.twig', [ + 'content_element' => $this->template, + 'products' => $products, + ]); + } +} diff --git a/src/Renderer/ContentElement/SingleMediaContentElementRenderer.php b/src/Renderer/ContentElement/SingleMediaContentElementRenderer.php new file mode 100644 index 000000000..fb005ab1d --- /dev/null +++ b/src/Renderer/ContentElement/SingleMediaContentElementRenderer.php @@ -0,0 +1,42 @@ +getType(); + } + + public function render(ContentConfigurationInterface $contentConfiguration): string + { + $code = $contentConfiguration->getConfiguration()['single_media']; + if (null === $code) { + return ''; + } + + $media = [ + 'renderedContent' => $this->renderMediaRuntime->renderMedia($code), + 'entity' => $this->mediaRepository->findOneBy(['code' => $code]), + ]; + + return $this->twig->render('@SyliusCmsPlugin/Shop/ContentElement/index.html.twig', [ + 'content_element' => $this->template, + 'media' => $media, + ]); + } +} diff --git a/src/Renderer/ContentElement/SpacerContentElementRenderer.php b/src/Renderer/ContentElement/SpacerContentElementRenderer.php new file mode 100644 index 000000000..99dbc8c69 --- /dev/null +++ b/src/Renderer/ContentElement/SpacerContentElementRenderer.php @@ -0,0 +1,26 @@ +getType(); + } + + public function render(ContentConfigurationInterface $contentConfiguration): string + { + $configuration = (int) $contentConfiguration->getConfiguration()['spacer']; + + return $this->twig->render('@SyliusCmsPlugin/Shop/ContentElement/index.html.twig', [ + 'content_element' => $this->template, + 'spacer_height' => $configuration, + ]); + } +} diff --git a/src/Renderer/ContentElement/TaxonsListContentElementRenderer.php b/src/Renderer/ContentElement/TaxonsListContentElementRenderer.php new file mode 100644 index 000000000..78c463b49 --- /dev/null +++ b/src/Renderer/ContentElement/TaxonsListContentElementRenderer.php @@ -0,0 +1,34 @@ +getType(); + } + + public function render(ContentConfigurationInterface $contentConfiguration): string + { + $configuration = $contentConfiguration->getConfiguration(); + $taxonsCodes = $configuration['taxons_list']['taxons']; + $taxons = $this->taxonRepository->findBy(['code' => $taxonsCodes]); + + return $this->twig->render('@SyliusCmsPlugin/Shop/ContentElement/index.html.twig', [ + 'content_element' => $this->template, + 'taxons' => $taxons, + ]); + } +} diff --git a/src/Renderer/ContentElement/TextareaContentElementRenderer.php b/src/Renderer/ContentElement/TextareaContentElementRenderer.php new file mode 100644 index 000000000..2b666d076 --- /dev/null +++ b/src/Renderer/ContentElement/TextareaContentElementRenderer.php @@ -0,0 +1,24 @@ +getType(); + } + + public function render(ContentConfigurationInterface $contentConfiguration): string + { + return $this->twig->render('@SyliusCmsPlugin/Shop/ContentElement/index.html.twig', [ + 'content_element' => $this->template, + 'content' => $contentConfiguration->getConfiguration()['textarea'], + ]); + } +} diff --git a/src/Renderer/ContentElementRendererStrategy.php b/src/Renderer/ContentElementRendererStrategy.php new file mode 100644 index 000000000..2f4fc6bc9 --- /dev/null +++ b/src/Renderer/ContentElementRendererStrategy.php @@ -0,0 +1,45 @@ +getContentElements() as $contentElement) { + if ($contentElement->getLocale() !== $this->localeContext->getLocaleCode()) { + continue; + } + + foreach ($this->renderers as $renderer) { + if ($renderer->supports($contentElement)) { + $content .= html_entity_decode($renderer->render($contentElement), \ENT_QUOTES); + + break; + } + } + } + + return $this->contentParser->parse($content); + } +} diff --git a/src/Renderer/ContentElementRendererStrategyInterface.php b/src/Renderer/ContentElementRendererStrategyInterface.php new file mode 100644 index 000000000..8f937d985 --- /dev/null +++ b/src/Renderer/ContentElementRendererStrategyInterface.php @@ -0,0 +1,13 @@ +twig->render( + $template ?? self::DEFAULT_TEMPLATE, + [ + 'link' => $this->urlGenerator->generate( + 'sylius_cms_shop_page_show', + ['slug' => $page->getSlug()], + UrlGeneratorInterface::ABSOLUTE_URL, + ), + 'name' => $page->getName(), + ], + ); + } +} diff --git a/src/Renderer/PageLinkRendererInterface.php b/src/Renderer/PageLinkRendererInterface.php new file mode 100644 index 000000000..ed9c23385 --- /dev/null +++ b/src/Renderer/PageLinkRendererInterface.php @@ -0,0 +1,12 @@ +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() ; } - public function findByProductCode( - string $productCode, - string $localeCode, - string $channelCode, - ): array { + public function findByNamePart(string $phrase): array + { return $this->createQueryBuilder('o') - ->leftJoin('o.translations', 'translation') - ->innerJoin('o.products', 'product') - ->innerJoin('o.channels', 'channels') - ->andWhere('translation.locale = :localeCode') - ->andWhere('product.code = :productCode') - ->andWhere('o.enabled = true') - ->andWhere('channels.code = :channelCode') - ->setParameter('localeCode', $localeCode) - ->setParameter('productCode', $productCode) - ->setParameter('channelCode', $channelCode) + ->andWhere('o.name LIKE :name') + ->setParameter('name', '%' . $phrase . '%') ->getQuery() ->getResult() ; diff --git a/src/Repository/BlockRepositoryInterface.php b/src/Repository/BlockRepositoryInterface.php index 53bb70c68..0860e3e86 100755 --- a/src/Repository/BlockRepositoryInterface.php +++ b/src/Repository/BlockRepositoryInterface.php @@ -1,34 +1,20 @@ createQueryBuilder('o') + ->andWhere('o.name LIKE :name') + ->setParameter('name', '%' . $phrase . '%') + ->getQuery() + ->getResult() + ; + } + + public function findByNamePartAndType(string $phrase, string $type): array + { + return $this->createQueryBuilder('o') + ->andWhere('o.name LIKE :name') + ->andWhere('o.type = :type') + ->setParameter('name', '%' . $phrase . '%') + ->setParameter('type', $type) + ->getQuery() + ->getResult() + ; + } + + public function findOneByCode(string $code): ?CollectionInterface + { + return $this->createQueryBuilder('o') + ->andWhere('o.code = :code') + ->setParameter('code', $code) + ->getQuery() + ->getOneOrNullResult() + ; + } + + public function findByCodes(string $codes): array + { + return $this->createQueryBuilder('o') + ->andWhere('o.code IN(:codes)') + ->setParameter('codes', explode(',', $codes)) + ->getQuery() + ->getResult() + ; + } +} diff --git a/src/Repository/CollectionRepositoryInterface.php b/src/Repository/CollectionRepositoryInterface.php new file mode 100755 index 000000000..5f16731cc --- /dev/null +++ b/src/Repository/CollectionRepositoryInterface.php @@ -0,0 +1,19 @@ +createQueryBuilder('o') - ->addSelect('translation') - ->leftJoin('o.translations', 'translation', 'WITH', 'translation.locale = :localeCode') - ->setParameter('localeCode', $localeCode) - ; - } - - public function findEnabledOrderedByPosition(string $localeCode, string $channelCode): array - { - return $this->createQueryBuilder('o') - ->leftJoin('o.translations', 'translation') - ->innerJoin('o.channels', 'channels') - ->where('translation.locale = :localeCode') - ->andWhere('o.enabled = true') - ->andWhere('channels.code = :channelCode') - ->orderBy('o.position', 'ASC') - ->setParameter('localeCode', $localeCode) - ->setParameter('channelCode', $channelCode) - ->getQuery() - ->getResult() - ; - } - - public function findOneEnabledByCode(string $code): ?FrequentlyAskedQuestionInterface - { - return $this->createQueryBuilder('o') - ->where('o.code = :code') - ->andWhere('o.enabled = true') - ->setParameter('code', $code) - ->getQuery() - ->getOneOrNullResult() - ; - } -} diff --git a/src/Repository/FrequentlyAskedQuestionRepositoryInterface.php b/src/Repository/FrequentlyAskedQuestionRepositoryInterface.php deleted file mode 100755 index bc3c19298..000000000 --- a/src/Repository/FrequentlyAskedQuestionRepositoryInterface.php +++ /dev/null @@ -1,24 +0,0 @@ -createQueryBuilder('o') - ->leftJoin('o.translations', 'translation') ->innerJoin('o.channels', 'channels') - ->where('translation.locale = :localeCode') ->andWhere('o.code = :code') ->andWhere('o.enabled = true') ->andWhere('channels.code = :channelCode') ->setParameter('code', $code) - ->setParameter('localeCode', $localeCode) ->setParameter('channelCode', $channelCode) ->getQuery() ->getOneOrNullResult() ; } - public function findBySectionCode( - string $sectionCode, - string $localeCode, - string $channelCode, - ): array { - return $this->createQueryBuilder('o') - ->leftJoin('o.translations', 'translation') - ->innerJoin('o.sections', 'section') - ->innerJoin('o.channels', 'channels') - ->andWhere('translation.locale = :localeCode') - ->andWhere('section.code = :sectionCode') - ->andWhere('o.enabled = true') - ->andWhere('channels.code = :channelCode') - ->setParameter('localeCode', $localeCode) - ->setParameter('sectionCode', $sectionCode) - ->setParameter('channelCode', $channelCode) - ->getQuery() - ->getResult() - ; - } - - public function findByProductCode( - string $productCode, - string $localeCode, - string $channelCode, - ): array { + public function findByNamePart(string $phrase, array $mediaType): array + { return $this->createQueryBuilder('o') - ->leftJoin('o.translations', 'translation') - ->innerJoin('o.products', 'product') - ->innerJoin('o.channels', 'channels') - ->andWhere('translation.locale = :localeCode') - ->andWhere('product.code = :productCode') - ->andWhere('o.enabled = true') - ->andWhere('channels.code = :channelCode') - ->setParameter('localeCode', $localeCode) - ->setParameter('productCode', $productCode) - ->setParameter('channelCode', $channelCode) + ->andWhere('o.name LIKE :name') + ->andWhere('o.type IN (:mediaType)') + ->setParameter('name', '%' . $phrase . '%') + ->setParameter('mediaType', $mediaType) ->getQuery() ->getResult() ; diff --git a/src/Repository/MediaRepositoryInterface.php b/src/Repository/MediaRepositoryInterface.php index 17505e3cf..12c5cd94d 100755 --- a/src/Repository/MediaRepositoryInterface.php +++ b/src/Repository/MediaRepositoryInterface.php @@ -1,17 +1,11 @@ createQueryBuilder('o') - ->addSelect('translation') - ->leftJoin('o.translations', 'translation', 'WITH', 'translation.locale = :localeCode') - ->leftJoin('o.sections', 'sections') - ->setParameter('localeCode', $localeCode) - ; - } + use TranslationBasedAwareTrait; public function findEnabled(bool $enabled): array { return $this->createQueryBuilder('o') - ->addSelect('translation') - ->innerJoin('o.translations', 'translation') ->andWhere('o.enabled = :enabled') ->setParameter('enabled', $enabled) ->getQuery() @@ -39,15 +22,12 @@ public function findEnabled(bool $enabled): array ; } - public function findOneEnabledByCode(string $code, ?string $localeCode): ?PageInterface + public function findOneEnabledByCode(string $code): ?PageInterface { return $this->createQueryBuilder('o') - ->leftJoin('o.translations', 'translation') - ->where('translation.locale = :localeCode') ->andWhere('o.code = :code') ->andWhere('o.enabled = true') ->setParameter('code', $code) - ->setParameter('localeCode', $localeCode) ->getQuery() ->getOneOrNullResult() ; @@ -73,97 +53,38 @@ 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): array { return $this->createQueryBuilder('o') - ->leftJoin('o.translations', 'translation') - ->innerJoin('o.sections', 'section') - ->where('translation.locale = :localeCode') - ->andWhere('section.code = :sectionCode') + ->innerJoin('o.collections', 'collection') + ->andWhere('collection.code = :collectionCode') ->andWhere('o.enabled = true') - ->setParameter('sectionCode', $sectionCode) - ->setParameter('localeCode', $localeCode) + ->setParameter('collectionCode', $collectionCode) ->getQuery() ->getResult() ; } - public function findByProduct( - ProductInterface $product, - string $channelCode, - ?\DateTimeInterface $date = null, - ): array { - $qb = $this->createQueryBuilder('o') - ->innerJoin('o.products', 'product') - ->innerJoin('o.channels', 'channel') - ->where('o.enabled = true') - ->andWhere('product = :product') - ->andWhere('channel.code = :channelCode') - ->setParameter('product', $product) - ->setParameter('channelCode', $channelCode) - ; - - if (null !== $date) { - $this->addDateFilter($qb, $date); - } - - return $qb + public function findByNamePart(string $phrase): array + { + return $this->createQueryBuilder('o') + ->andWhere('o.name LIKE :name') + ->setParameter('name', '%' . $phrase . '%') ->getQuery() ->getResult() ; } - - public function findByProductAndSectionCode( - ProductInterface $product, - string $sectionCode, - string $channelCode, - ?\DateTimeInterface $date = null, - ): array { - $qb = $this->createQueryBuilder('o') - ->innerJoin('o.products', 'product') - ->innerJoin('o.sections', 'section') - ->innerJoin('o.channels', 'channel') - ->where('o.enabled = true') - ->andWhere('product = :product') - ->andWhere('section.code = :sectionCode') - ->andWhere('channel.code = :channelCode') - ->setParameter('product', $product) - ->setParameter('sectionCode', $sectionCode) - ->setParameter('channelCode', $channelCode) - ; - - if (null !== $date) { - $this->addDateFilter($qb, $date); - } - - return $qb->getQuery() - ->getResult() - ; - } - - private function addDateFilter(QueryBuilder $qb, \DateTimeInterface $date): void - { - $qb - ->andWhere( - $qb->expr()->orX( - 'o.publishAt is NULL', - 'o.publishAt <= :date', - ), - ) - ->setParameter('date', $date) - ; - } } diff --git a/src/Repository/PageRepositoryInterface.php b/src/Repository/PageRepositoryInterface.php index afa541021..98fbf7863 100755 --- a/src/Repository/PageRepositoryInterface.php +++ b/src/Repository/PageRepositoryInterface.php @@ -1,27 +1,18 @@ createQueryBuilder('o') - ->addSelect('translation') - ->leftJoin('o.translations', 'translation', 'WITH', 'translation.locale = :localeCode') - ->setParameter('localeCode', $localeCode) - ; - } - - public function findByNamePart(string $phrase, ?string $locale = null): array - { - return $this->createTranslationBasedQueryBuilder($locale) - ->andWhere('translation.name LIKE :name') - ->setParameter('name', '%' . $phrase . '%') - ->getQuery() - ->getResult() - ; - } - - 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') - ->leftJoin('o.translations', 'translation') - ->where('translation.locale = :localeCode') - ->andWhere('o.code = :code') - ->setParameter('code', $code) - ->setParameter('localeCode', $localeCode) - ->getQuery() - ->getOneOrNullResult() - ; - } - - public function findByCodesAndLocale(string $codes, string $localeCode): array - { - return $this->createQueryBuilder('o') - ->leftJoin('o.translations', 'translation') - ->where('translation.locale = :localeCode') - ->andWhere('o.code IN(:codes)') - ->setParameter('codes', explode(',', $codes)) - ->setParameter('localeCode', $localeCode) - ->getQuery() - ->getResult() - ; - } -} diff --git a/src/Repository/SectionRepositoryInterface.php b/src/Repository/SectionRepositoryInterface.php deleted file mode 100755 index 7dc03e4bf..000000000 --- a/src/Repository/SectionRepositoryInterface.php +++ /dev/null @@ -1,26 +0,0 @@ -createQueryBuilder('o') + ->andWhere('o.name LIKE :name') + ->andWhere('o.type = :type') + ->setParameters([ + 'name' => '%' . $phrase . '%', + 'type' => $type, + ]) + ->getQuery() + ->getResult() + ; + } +} diff --git a/src/Repository/TemplateRepositoryInterface.php b/src/Repository/TemplateRepositoryInterface.php new file mode 100644 index 000000000..c6f6aef3f --- /dev/null +++ b/src/Repository/TemplateRepositoryInterface.php @@ -0,0 +1,10 @@ +createQueryBuilder('o') + ->addSelect('translation') + ->leftJoin('o.translations', 'translation') + ; + + if (null !== $locale) { + $queryBuilder + ->andWhere('translation.locale = :locale') + ->setParameter('locale', $locale) + ; + } + + return $queryBuilder; + } +} diff --git a/src/Resolver/BlockResourceResolver.php b/src/Resolver/BlockResourceResolver.php index baf6ab6a8..1c42495ef 100755 --- a/src/Resolver/BlockResourceResolver.php +++ b/src/Resolver/BlockResourceResolver.php @@ -1,18 +1,12 @@ collectionRepository->findOneByCode($code); + + if (false === $collection instanceof CollectionInterface) { + $this->logger->warning(sprintf( + 'Collection with "%s" code was not found in the database.', + $code, + )); + + return null; + } + + return $collection; + } +} diff --git a/src/Resolver/CollectionResourceResolverInterface.php b/src/Resolver/CollectionResourceResolverInterface.php new file mode 100755 index 000000000..c8785580f --- /dev/null +++ b/src/Resolver/CollectionResourceResolverInterface.php @@ -0,0 +1,12 @@ +collectionsAssigner->assign($collectionable, $collectionCodes); + } +} diff --git a/src/Resolver/Importer/ImporterCollectionsResolverInterface.php b/src/Resolver/Importer/ImporterCollectionsResolverInterface.php new file mode 100644 index 000000000..d54af5f79 --- /dev/null +++ b/src/Resolver/Importer/ImporterCollectionsResolverInterface.php @@ -0,0 +1,12 @@ +localesAssigner->assign($localesAware, $channelsCodes); + } +} diff --git a/src/Resolver/Importer/ImporterLocalesResolverInterface.php b/src/Resolver/Importer/ImporterLocalesResolverInterface.php new file mode 100644 index 000000000..cb587bfd7 --- /dev/null +++ b/src/Resolver/Importer/ImporterLocalesResolverInterface.php @@ -0,0 +1,12 @@ +productsInTaxonsAssigner->assign($productsInTaxonsAware, $taxonsCodes); + } +} diff --git a/src/Resolver/Importer/ImporterProductsInTaxonsResolverInterface.php b/src/Resolver/Importer/ImporterProductsInTaxonsResolverInterface.php new file mode 100644 index 000000000..68948f0fd --- /dev/null +++ b/src/Resolver/Importer/ImporterProductsInTaxonsResolverInterface.php @@ -0,0 +1,12 @@ +taxonsAssigner->assign($taxonsAware, $taxonsCodes); + } +} diff --git a/src/Resolver/Importer/ImporterTaxonsResolverInterface.php b/src/Resolver/Importer/ImporterTaxonsResolverInterface.php new file mode 100644 index 000000000..e996bff2d --- /dev/null +++ b/src/Resolver/Importer/ImporterTaxonsResolverInterface.php @@ -0,0 +1,12 @@ +sectionsAssigner->assign($sectionable, $sectionCodes); - } -} diff --git a/src/Resolver/ImporterSectionsResolverInterface.php b/src/Resolver/ImporterSectionsResolverInterface.php deleted file mode 100644 index 877ef441e..000000000 --- a/src/Resolver/ImporterSectionsResolverInterface.php +++ /dev/null @@ -1,18 +0,0 @@ -channelContext->getChannel()->getCode()); $media = $this->mediaRepository->findOneEnabledByCode( $code, - $this->localeContext->getLocaleCode(), $this->channelContext->getChannel()->getCode(), ); diff --git a/src/Resolver/MediaResourceResolverInterface.php b/src/Resolver/MediaResourceResolverInterface.php index 3d5931ef0..1f379eba5 100755 --- a/src/Resolver/MediaResourceResolverInterface.php +++ b/src/Resolver/MediaResourceResolverInterface.php @@ -1,16 +1,10 @@ pageRepository->findOneEnabledByCode($code, $this->localeContext->getLocaleCode()); + $page = $this->pageRepository->findOneEnabledByCode($code); if (false === $page instanceof PageInterface) { $this->logger->warning(sprintf( diff --git a/src/Resolver/PageResourceResolverInterface.php b/src/Resolver/PageResourceResolverInterface.php index 5ada14ede..454a6fffc 100755 --- a/src/Resolver/PageResourceResolverInterface.php +++ b/src/Resolver/PageResourceResolverInterface.php @@ -1,16 +1,10 @@ factory, $factoryMethod]; if (is_callable($callback) && method_exists($this->factory, $factoryMethod)) { - return call_user_func($callback); + return $callback(); } throw new BadFunctionCallException('Provided method' . $factoryMethod . ' is not callable'); diff --git a/src/Resolver/ResourceResolverInterface.php b/src/Resolver/ResourceResolverInterface.php index 33beb1227..aa151a10d 100644 --- a/src/Resolver/ResourceResolverInterface.php +++ b/src/Resolver/ResourceResolverInterface.php @@ -1,14 +1,8 @@ { + const typeField = document.getElementById('sylius_cms_collection_type'); + const fields = { + page: document.getElementById('collection-type-pages'), + block: document.getElementById('collection-type-blocks'), + media: document.getElementById('collection-type-media') + }; + + const hideAllFields = () => { + Object.values(fields).forEach(field => field.style.display = 'none'); + }; + + const showField = (type) => { + hideAllFields(); + if (fields[type]) { + fields[type].style.display = 'block'; + } + }; + + showField(typeField.value); + + typeField.addEventListener('change', (event) => { + showField(event.target.value); + }); + }); + } +} diff --git a/src/Resources/assets/admin/js/cms/cms-content-configuration.js b/src/Resources/assets/admin/js/cms/cms-content-configuration.js new file mode 100644 index 000000000..a0754ccaa --- /dev/null +++ b/src/Resources/assets/admin/js/cms/cms-content-configuration.js @@ -0,0 +1,129 @@ +$(document).ready(function() { + const localeSelector = $('.locale-selector'); + const contentElementsContainer = $('.content-elements-container'); + + function updateContentElementsVisibility() { + const selectedLocale = localeSelector.val(); + + contentElementsContainer.find('.bb-collection-item').each(function() { + const $element = $(this); + const elementLocale = $element.find('input[name$="[locale]"]').val(); + + if (elementLocale === selectedLocale) { + $element.show(); + } else { + $element.hide(); + } + }); + } + + localeSelector.on('change', function() { + updateContentElementsVisibility(); + }); + + contentElementsContainer.on('contentElementAdded', function() { + updateContentElementsVisibility(); + }); + + updateContentElementsVisibility(); + + $('.cms-media-autocomplete, .sylius-autocomplete').each((index, element) => { + $(element).autoComplete(); + }); + + const ckeditorConfig = { + toolbar: [ + ["Cut", "Copy", "Paste", "PasteText", "PasteFromWord", "-", "Undo", "Redo"], + ["Scayt"], ["Link", "Unlink", "Anchor"], + ["Image", "MediaVideo", "MediaImage", "Table", "HorizontalRule", "SpecialChar"], + ["Maximize"], ["Source"], "/", + ["Bold", "Italic", "Strike", "-", "RemoveFormat"], + ["NumberedList", "BulletedList", "-", "Outdent", "Indent", "-", "Blockquote"], + ["Styles", "Format", "About"] + ], + enterMode: 3, + forcePasteAsPlainText: "allow-word", + allowedContent: true, + extraPlugins: ["mediaVideo", "mediaImage"], + removePlugins: ["exportpdf"], + filebrowserUploadUrl: "/admin/editor/upload-image", + bodyId: "cms-ckeditor", + language: "en-us" + }; + + let pageElements = '#sylius_cms_page_contentElements'; + let blockElements = '#sylius_cms_block_contentElements'; + let collectionHolder = $(pageElements).length ? pageElements : blockElements; + + let itemElement = document.querySelector(`${collectionHolder} [data-form-collection="item"]`); + + if (!$(collectionHolder).length) { + return; + } + + $(document).on('collection-form-add', () => { + $('.cms-media-autocomplete, .sylius-autocomplete').each((index, element) => { + if ($._data($(element).get(0), 'events') === undefined) { + $(element).autoComplete(); + } + }); + + $(`${collectionHolder} [data-form-collection="item"]`).each((index, element) => { + $(document).loadContentConfiguration(element); + }); + + $('.bb-collection-item:last-child').find('input[name$="[locale]"]').val(localeSelector.val()); + }); + $.fn.extend({ + loadContentConfiguration(target) { + target.querySelector(`${collectionHolder} select[name*="type"]`).onchange = function () { + const parent = this.parentElement; + const newConfig = document.createElement('div'); + const selectedOption = this.selectedOptions[0]; + newConfig.innerHTML = selectedOption.getAttribute('data-configuration'); + const oldConfig = parent.nextElementSibling; + parent.parentElement.replaceChild(newConfig, oldConfig); + let oldConfigInput = oldConfig.querySelector('input'); + if (!oldConfigInput) { + oldConfigInput = oldConfig.querySelector('textarea'); + } + const oldConfigInputName = oldConfigInput.getAttribute('name'); + let newConfigInputs = newConfig.querySelectorAll('input'); + if (!newConfigInputs.length) { + newConfigInputs = newConfig.querySelectorAll('textarea'); + } + newConfigInputs.forEach(element => { + let newConfigInputName = element.getAttribute('name'); + if (!newConfigInputName) { + return; + } + newConfigInputName = oldConfigInputName.replace( + oldConfigInputName.substring(oldConfigInputName.indexOf('[configuration]') + 15), + newConfigInputName.substring(newConfigInputName.indexOf('configuration') + 13), + ); + $(element).attr('name', newConfigInputName); + $(newConfig).find('.cms-media-autocomplete').autoComplete(); + $(newConfig).find('.sylius-autocomplete').autoComplete(); + + if (this.value === 'textarea') { + const index = target.getAttribute('data-form-collection-index'); + const textareaId = `${collectionHolder}_${index}_configuration_textarea`; + + element.id = textareaId; + + if (typeof CKEDITOR !== 'undefined') { + CKEDITOR.replace(textareaId, ckeditorConfig); + } + } + }); + } + } + }); + $(`${collectionHolder} [data-form-collection="item"]`).each((index, element) => { + $(document).loadContentConfiguration(element); + }); + + if (itemElement) { + $(document).loadContentConfiguration(itemElement); + } +}); diff --git a/src/Resources/assets/admin/js/bitbag/bitbag-media-autocomplete.js b/src/Resources/assets/admin/js/cms/cms-media-autocomplete.js similarity index 92% rename from src/Resources/assets/admin/js/bitbag/bitbag-media-autocomplete.js rename to src/Resources/assets/admin/js/cms/cms-media-autocomplete.js index d132c78b3..d2750e75f 100644 --- a/src/Resources/assets/admin/js/bitbag/bitbag-media-autocomplete.js +++ b/src/Resources/assets/admin/js/cms/cms-media-autocomplete.js @@ -1,8 +1,3 @@ -/* - 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 -*/ import triggerCustomEvent from '../../../common/js/utilities/triggerCustomEvent'; export class HandleAutoComplete { @@ -33,7 +28,7 @@ export class HandleAutoComplete { init() { if (typeof this.config !== 'object') { - throw new Error('Bitbag CMS Plugin - HandleAutoComplete class config is not a valid object'); + throw new Error('Sylius CMS Plugin - HandleAutoComplete class config is not a valid object'); } this.mediaContainers.forEach((mediaContainer) => { this._handleSavedValue(mediaContainer); @@ -113,7 +108,7 @@ export class HandleAutoComplete { triggerCustomEvent(mediaContainer, 'cms.media.saved.reload.completed', data); } catch (error) { - console.error(`BitBag CMS Plugin - HandleAutoComplete class error : ${error}`); + console.error(`Sylius CMS Plugin - HandleAutoComplete class error : ${error}`); triggerCustomEvent(mediaContainer, 'cms.media.saved.reload.error', error); } finally { mediaContainer.classList.remove('loading'); @@ -139,7 +134,7 @@ export class HandleAutoComplete { triggerCustomEvent(mediaContainer, 'cms.media.display.completed', data); } catch (error) { - console.error(`BitBag CMS Plugin - HandleAutoComplete class error : ${error}`); + console.error(`Sylius CMS Plugin - HandleAutoComplete class error : ${error}`); triggerCustomEvent(mediaContainer, 'cms.media.display.error', error); } finally { mediaContainer.classList.remove('loading'); diff --git a/src/Resources/assets/admin/js/bitbag/bitbag-page-slug.js b/src/Resources/assets/admin/js/cms/cms-page-slug.js similarity index 68% rename from src/Resources/assets/admin/js/bitbag/bitbag-page-slug.js rename to src/Resources/assets/admin/js/cms/cms-page-slug.js index d0a8cb4d1..e27df10c4 100644 --- a/src/Resources/assets/admin/js/bitbag/bitbag-page-slug.js +++ b/src/Resources/assets/admin/js/cms/cms-page-slug.js @@ -1,9 +1,3 @@ -/* - 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 -*/ - import triggerCustomEvent from '../../../common/js/utilities/triggerCustomEvent'; export class HandleSlugUpdate { @@ -11,22 +5,28 @@ export class HandleSlugUpdate { config = { wrappersIndicator: 'data-bb-cms-wrapper', lockFieldIndicator: 'data-bb-cms-toggle-slug', - bbTarget: 'bitbag_sylius_cms_plugin_page', + bbTarget: 'sylius_cms_page', + nameField: 'sylius_cms_page_name', } ) { this.wrappers = document.querySelectorAll(`[${config.wrappersIndicator}]`); this.lockFieldIndicator = `[${config.lockFieldIndicator}]`; this.bbTarget = config.bbTarget; this.config = config; + this.nameField = document.getElementById(`${config.nameField}`); } init() { if (typeof this.config !== 'object') { - throw new Error('Bitbag CMS Plugin - HandleSlugUpdate class config is not a valid object'); + throw new Error('Sylius CMS Plugin - HandleSlugUpdate class config is not a valid object'); } if (typeof this.lockFieldIndicator !== 'string' || typeof this.bbTarget !== 'string') { - throw new Error('Bitbag CMS Plugin - HandleSlugUpdate class config key values are not valid strings'); + throw new Error('Sylius CMS Plugin - HandleSlugUpdate class config key values are not valid strings'); + } + + if (!this.nameField ) { + throw new Error('Sylius CMS Plugin - HandleSlugUpdate name field not found'); } this._handleFields(); @@ -35,29 +35,30 @@ export class HandleSlugUpdate { _handleFields() { this.wrappers.forEach((item) => { const locale = item.dataset.locale; - const textField = item.querySelector(`#${this.bbTarget}_translations_${locale}_name`); - const slugField = item.querySelector(`#${this.bbTarget}_translations_${locale}_slug`); - const lockField = item.querySelector(this.lockFieldIndicator); - if (!textField || !slugField || !locale) { + let slugField = item.querySelector(`#${this.bbTarget}_translations_${locale}_slug`); + if (!slugField) { + slugField = item.querySelector(`#${this.bbTarget}_slug`); + } + + if (!slugField) { return; } let timeout; - textField.addEventListener('input', (e) => { + this.nameField.addEventListener('input', (e) => { e.preventDefault(); - if (slugField.readOnly) { - return; + if (!slugField.readOnly) { + clearTimeout(timeout); + timeout = setTimeout(() => { + this._updateSlug(slugField, this.nameField.value); + }, 1000); } - - clearTimeout(timeout); - timeout = setTimeout(() => { - this._updateSlug(slugField, textField.value); - }, 1000); }); + const lockField = item.querySelector(this.lockFieldIndicator); if (!lockField) { return; } @@ -83,7 +84,7 @@ export class HandleSlugUpdate { const response = await request.json(); return response.slug; } catch (error) { - console.error(`BitBag CMS Plugin - HandleSlugUpdate class error : ${error}`); + console.error(`Sylius CMS Plugin - HandleSlugUpdate class error : ${error}`); } } diff --git a/src/Resources/assets/admin/js/bitbag/bitbag-cms-preview.js b/src/Resources/assets/admin/js/cms/cms-preview.js similarity index 82% rename from src/Resources/assets/admin/js/bitbag/bitbag-cms-preview.js rename to src/Resources/assets/admin/js/cms/cms-preview.js index 76f0de1a4..a2c82eb93 100644 --- a/src/Resources/assets/admin/js/bitbag/bitbag-cms-preview.js +++ b/src/Resources/assets/admin/js/cms/cms-preview.js @@ -1,9 +1,3 @@ -/* - 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 -*/ - import triggerCustomEvent from '../../../common/js/utilities/triggerCustomEvent'; export class HandlePreview { @@ -24,14 +18,14 @@ export class HandlePreview { } init() { if (typeof this.config !== 'object') { - throw new Error('Bitbag CMS Plugin - HandlePreview class config is not a valid object'); + throw new Error('Sylius CMS Plugin - HandlePreview class config is not a valid object'); } if ( typeof this.localeSelector !== 'string' || typeof this.channelSelector !== 'string' || typeof this.modalSelector !== 'string' ) { - throw new Error('Bitbag CMS Plugin - HandlePreview class config key values are not valid strings'); + throw new Error('Sylius CMS Plugin - HandlePreview class config key values are not valid strings'); } this._resourcePreview(); } @@ -42,28 +36,29 @@ export class HandlePreview { } _$_CKEDITOR_UPDATE_INSTANCES() { - [...CKEDITOR.instances].forEach((instance) => instance.updateElement()); + if (typeof CKEDITOR !== 'undefined') { + Object.values(CKEDITOR.instances).forEach((instance) => instance.updateElement()); + } } - _resourcePreview() { this.button.addEventListener('click', (e) => { e.preventDefault(); - this._$_CKEDITOR_UPDATE_INSTANCES; + this._$_CKEDITOR_UPDATE_INSTANCES(); this._createPreview(); this._$_CKEDITOR_MODAL_SHOW(); }); document.querySelector(`[${this.channelSelector}]`).addEventListener('change', (e) => { e.preventDefault(); - this._$_CKEDITOR_UPDATE_INSTANCES; + this._$_CKEDITOR_UPDATE_INSTANCES(); this._createPreview(); this._$_CKEDITOR_MODAL_SHOW(); }); document.querySelector(`[${this.localeSelector}]`).addEventListener('change', (e) => { e.preventDefault(); - this._$_CKEDITOR_UPDATE_INSTANCES; + this._$_CKEDITOR_UPDATE_INSTANCES(); this._createPreview(); this._$_CKEDITOR_MODAL_SHOW(); }); @@ -94,7 +89,7 @@ export class HandlePreview { this.modal.querySelector('iframe').src = blobUrl; triggerCustomEvent(this.modal, 'cms.create.preview.completed', res); } catch (error) { - console.error(`BitBag CMS Plugin - HandlePreview class error : ${error}`); + console.error(`Sylius CMS Plugin - HandlePreview class error : ${error}`); triggerCustomEvent(this.modal, 'cms.create.preview.error', error); } finally { this.modal.querySelector('.ui.loadable').classList.remove('loading'); diff --git a/src/Resources/assets/admin/js/cms/cms-template.js b/src/Resources/assets/admin/js/cms/cms-template.js new file mode 100644 index 000000000..e2033b1ec --- /dev/null +++ b/src/Resources/assets/admin/js/cms/cms-template.js @@ -0,0 +1,91 @@ +export class HandleTemplate { + init() { + $(document).ready(() => { + const cmsLoadTemplate = $('[data-bb-cms-load-content-template]'); + const cmsPageTemplate = $('#sylius_cms_page_contentTemplate'); + const cmsBlockTemplate = $('#sylius_cms_block_contentTemplate'); + + let locales = []; + $('.locale-selector option').each(function() { + locales.push($(this).val()); + }); + + cmsPageTemplate.on('change', function() { + if ($(this).val()) { + $('#load-template-confirmation-modal').modal('show'); + } + }); + + cmsBlockTemplate.on('change', function() { + if ($(this).val()) { + $('#load-template-confirmation-modal').modal('show'); + } + }); + + $('#load-template-confirmation-button').on('click', function () { + const templateId = cmsPageTemplate.val() ?? cmsBlockTemplate.val(); + if (!templateId) { + return; + } + + const endpointUrl = cmsLoadTemplate.data('bb-cms-load-content-template').replace('REPLACE_ID', templateId); + if (!endpointUrl) { + return; + } + + $.ajax({ + url: endpointUrl, + type: 'GET', + success: function(data) { + if (data.status === 'success') { + $('[id^="sylius_cms_"][id$="contentElements"]') + .children('[data-form-collection="list"]') + .html(''); + + $.each(data.content, function () { + locales.forEach(function (locale) { + $('[data-form-collection="add"]').trigger('click'); + }); + }); + + const elements = $('.bb-collection-item'); + let idx = 0; + $.each(data.content, function (index, element) { + locales.forEach(function (locale) { + console.log(locale); + elements.eq(idx).find('select:first').val(element.type); + elements.eq(idx).find('select:first').change(); + elements.eq(idx).find('input[name$="[locale]"]').val(locale); + idx++; + }); + }); + + $('.content-elements-container').find('.bb-collection-item').each(function() { + const $element = $(this); + const elementLocale = $element.find('input[name$="[locale]"]').val(); + + if (elementLocale === $('.locale-selector').val()) { + $element.show(); + } else { + $element.hide(); + } + }); + } else { + console.error(data.message); + } + }, + error: function(jqXHR, textStatus, errorThrown) { + console.error('Error:', textStatus, errorThrown); + } + }); + }); + + $('#load-template-cancel-button').on('click', function () { + cmsPageTemplate.val(''); + cmsBlockTemplate.val(''); + }); + }); + } +} + +export default HandleTemplate; diff --git a/src/Resources/assets/admin/js/bitbag/bitbag-upload-csv.js b/src/Resources/assets/admin/js/cms/cms-upload-csv.js similarity index 70% rename from src/Resources/assets/admin/js/bitbag/bitbag-upload-csv.js rename to src/Resources/assets/admin/js/cms/cms-upload-csv.js index bf2a9c145..00d4664ac 100644 --- a/src/Resources/assets/admin/js/bitbag/bitbag-upload-csv.js +++ b/src/Resources/assets/admin/js/cms/cms-upload-csv.js @@ -1,9 +1,3 @@ -/* - 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 HandleCsvUpload { constructor(config = {textField: 'data-bb-cms-text', fileField: 'data-bb-cms-file'}) { this.config = config; @@ -13,7 +7,7 @@ export class HandleCsvUpload { init() { if (typeof this.config !== 'object') { - throw new Error('Bitbag CMS Plugin - HandleCsvUpload class config is not a valid object'); + throw new Error('Sylius CMS Plugin - HandleCsvUpload class config is not a valid object'); } this._handleFields(); diff --git a/src/Resources/assets/admin/js/cms/index.js b/src/Resources/assets/admin/js/cms/index.js new file mode 100644 index 000000000..5ab24a4ec --- /dev/null +++ b/src/Resources/assets/admin/js/cms/index.js @@ -0,0 +1,7 @@ +import './cms-content-configuration'; +export {HandleCsvUpload} from './cms-upload-csv'; +export {HandleSlugUpdate} from './cms-page-slug'; +export {HandlePreview} from './cms-preview'; +export {HandleAutoComplete} from './cms-media-autocomplete'; +export {HandleChooseCollectionType} from './cms-choose-collection-type'; +export {HandleTemplate} from './cms-template'; diff --git a/src/Resources/assets/admin/js/index.js b/src/Resources/assets/admin/js/index.js index 3f4948984..19cd8bf67 100644 --- a/src/Resources/assets/admin/js/index.js +++ b/src/Resources/assets/admin/js/index.js @@ -1,4 +1,11 @@ -import {HandleCsvUpload, HandleSlugUpdate, HandlePreview, HandleAutoComplete} from './bitbag'; +import { + HandleCsvUpload, + HandleSlugUpdate, + HandlePreview, + HandleAutoComplete, + HandleChooseCollectionType, + HandleTemplate +} from './cms'; if (document.querySelector('[data-bb-target="cms-import"]')) { new HandleCsvUpload().init(); @@ -15,3 +22,11 @@ if (document.querySelectorAll('[data-bb-cms-preview-btn]').length > 0) { if (document.querySelector('[data-bb-target="cms-handle-autocomplete"]')) { new HandleAutoComplete().init(); } + +if (document.querySelector('.collection-type-items')) { + new HandleChooseCollectionType().init(); +} + +if (document.querySelector('[data-bb-cms-load-content-template]')) { + new HandleTemplate().init(); +} diff --git a/src/Resources/assets/admin/scss/_css.scss b/src/Resources/assets/admin/scss/_css.scss index 2489ccbb6..344383c19 100644 --- a/src/Resources/assets/admin/scss/_css.scss +++ b/src/Resources/assets/admin/scss/_css.scss @@ -1,21 +1,21 @@ -#bitbag-cms-resource-preview-modal { +#cms-resource-preview-modal { height: 100%; } -#bitbag-cms-resource-preview-modal iframe { +#cms-resource-preview-modal iframe { width: 100%; height: 100vh; } -#bitbag-cms-resource-preview-modal .ui.header { +#cms-resource-preview-modal .ui.header { padding-bottom: 0; } -.bitbag-cms-import .ui.action.input input[type='file'] { +.cms-import .ui.action.input input[type='file'] { display: none; } -.bitbag-cms-import .ui.action.input input[type='text'] { +.cms-import .ui.action.input input[type='text'] { width: auto; } @@ -96,10 +96,28 @@ } } -.bitbag-media-autocomplete .dropdown.icon { +.cms-media-autocomplete .dropdown.icon { pointer-events: none; } -.bitbag-media-autocomplete .search { +.cms-media-autocomplete .search { cursor: pointer !important; } + +.bb-collection-item { + margin-bottom: 1em; + + &-delete { + margin-top: 5px !important; + } +} + +.cke_notifications_area { + display: none; +} + +.help-text { + font-size: 12px; + margin-top: -10px; + opacity: 0.5; +} diff --git a/src/Resources/assets/shop/scss/_carousel.scss b/src/Resources/assets/shop/scss/_carousel.scss new file mode 100644 index 000000000..312bb1934 --- /dev/null +++ b/src/Resources/assets/shop/scss/_carousel.scss @@ -0,0 +1,27 @@ +.carousel-wrapper { + position: relative; + + .products-carousel { + margin: 0 -1em; + } + + .products-carousel-nav { + .products-carousel-left { + left: 30px; + } + + .products-carousel-right { + right: 30px; + } + + .products-carousel-left, .products-carousel-right { + position: absolute; + top: 50%; + transform: translateY(-50%); + } + } + + .products-carousel-item { + padding: 5px 1em; + } +} diff --git a/src/Resources/assets/shop/scss/block/show.scss b/src/Resources/assets/shop/scss/block/show.scss index 22735f346..b9487635c 100644 --- a/src/Resources/assets/shop/scss/block/show.scss +++ b/src/Resources/assets/shop/scss/block/show.scss @@ -1,3 +1,8 @@ -.bitbag-block img { - max-width: 100%; +.cms-block { + margin-bottom: 20px; + + img { + max-width: 100%; + } } + diff --git a/src/Resources/assets/shop/scss/content_element/_pages_collection.scss b/src/Resources/assets/shop/scss/content_element/_pages_collection.scss new file mode 100644 index 000000000..e69de29bb diff --git a/src/Resources/assets/shop/scss/content_element/main.scss b/src/Resources/assets/shop/scss/content_element/main.scss new file mode 100644 index 000000000..14e0f5558 --- /dev/null +++ b/src/Resources/assets/shop/scss/content_element/main.scss @@ -0,0 +1,5 @@ +@import "pages_collection"; + +[class^="cms_content_element__"]:not(:last-child) { + margin-bottom: 1rem; +} diff --git a/src/Resources/assets/shop/scss/main.scss b/src/Resources/assets/shop/scss/main.scss index 56decf059..81471a8a3 100644 --- a/src/Resources/assets/shop/scss/main.scss +++ b/src/Resources/assets/shop/scss/main.scss @@ -1 +1,4 @@ @import './block/main.scss'; +@import 'carousel'; +@import 'page/teaser'; +@import './content_element/main.scss'; diff --git a/src/Resources/assets/shop/scss/page/_teaser.scss b/src/Resources/assets/shop/scss/page/_teaser.scss new file mode 100644 index 000000000..1dae7a7ea --- /dev/null +++ b/src/Resources/assets/shop/scss/page/_teaser.scss @@ -0,0 +1,14 @@ +.teaser { + &__content { + margin-top: 10px; + } + + &__description { + margin-top: 5px; + } + + &__read-more { + display: block; + margin-top: 20px; + } +} diff --git a/src/Resources/config/api_resources/Block.xml b/src/Resources/config/api_resources/Block.xml index 738c929ff..7081e0991 100644 --- a/src/Resources/config/api_resources/Block.xml +++ b/src/Resources/config/api_resources/Block.xml @@ -3,42 +3,51 @@ 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 + sylius_cms:block:read:index + sylius_cms:block:read:show - + - shop:cms:write + sylius_cms:block:write sylius - + GET /shop/cms-plugin/blocks + + sylius_cms:block:read:index + - - + GET /shop/cms-plugin/blocks/{id} + + sylius_cms:block:read:show + + - - - + + + + + diff --git a/src/Resources/config/api_resources/Collection.xml b/src/Resources/config/api_resources/Collection.xml new file mode 100644 index 000000000..88986b47f --- /dev/null +++ b/src/Resources/config/api_resources/Collection.xml @@ -0,0 +1,49 @@ + + + + + + sylius_cms:collection:read:index + sylius_cms:collection:read:show + + + + + + sylius_cms:collection:write + + + + sylius + + + + GET + /shop/cms-plugin/collections + + sylius_cms:collection:read:index + + + + + + + GET + /shop/cms-plugin/collections/{id} + + sylius_cms:collection:read:show + + + + + + + + + + + + diff --git a/src/Resources/config/api_resources/Faq.xml b/src/Resources/config/api_resources/Faq.xml deleted file mode 100644 index 2b203f300..000000000 --- a/src/Resources/config/api_resources/Faq.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - shop:cms:read - - - - - - shop:cms:write - - - - sylius - - - - GET - /shop/cms-plugin/faq - - - - - - - GET - /shop/cms-plugin/faq/{id} - - - - - - - - - - diff --git a/src/Resources/config/api_resources/Media.xml b/src/Resources/config/api_resources/Media.xml index 733b47e18..a28b8999d 100644 --- a/src/Resources/config/api_resources/Media.xml +++ b/src/Resources/config/api_resources/Media.xml @@ -3,33 +3,39 @@ 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 + sylius_cms:media:read:index + sylius_cms:media:read:show - + - shop:cms:write + sylius_cms:media:write sylius - + GET /shop/cms-plugin/media + + sylius_cms:media:read:index + - - + GET /shop/cms-plugin/media/{id} + + sylius_cms:media:read:show + @@ -42,8 +48,7 @@ - - + diff --git a/src/Resources/config/api_resources/Page.xml b/src/Resources/config/api_resources/Page.xml index 04bd60772..113bd64b4 100644 --- a/src/Resources/config/api_resources/Page.xml +++ b/src/Resources/config/api_resources/Page.xml @@ -3,44 +3,51 @@ 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 + sylius_cms:page:read:index + sylius_cms:page:read:show - + - shop:cms:write + sylius_cms:page:write sylius - + GET /shop/cms-plugin/pages + + sylius_cms:page:read:index + - - + GET /shop/cms-plugin/pages/{id} + + sylius_cms:page:read:show + + - - + + diff --git a/src/Resources/config/api_resources/Section.xml b/src/Resources/config/api_resources/Section.xml deleted file mode 100644 index f2b44066d..000000000 --- a/src/Resources/config/api_resources/Section.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - shop:cms:read - - - - - - shop:cms:write - - - - sylius - - - - GET - /shop/cms-plugin/sections - - - - - - - GET - /shop/cms-plugin/sections/{id} - - - - - - - diff --git a/src/Resources/config/api_resources/Template.xml b/src/Resources/config/api_resources/Template.xml new file mode 100644 index 000000000..a6e41e630 --- /dev/null +++ b/src/Resources/config/api_resources/Template.xml @@ -0,0 +1,47 @@ + + + + + + sylius_cms:template:read:index + sylius_cms:template:read:show + + + + + + sylius_cms:template:write + + + + sylius + + + + GET + /shop/cms-plugin/templates + + sylius_cms:template:read:index + + + + + + + GET + /shop/cms-plugin/templates/{id} + + sylius_cms:template:read:show + + + + + + + + + + diff --git a/src/Resources/config/config.yml b/src/Resources/config/config.yml index 169ee6614..b8875f1af 100755 --- a/src/Resources/config/config.yml +++ b/src/Resources/config/config.yml @@ -1,41 +1,39 @@ imports: - - { resource: "@BitBagSyliusCmsPlugin/Resources/config/resources.yml" } - - { resource: "@BitBagSyliusCmsPlugin/Resources/config/fos_ck_editor/fos_ck_editor.yml" } - - { resource: "@BitBagSyliusCmsPlugin/Resources/config/grids.yml" } - - { resource: "@BitBagSyliusCmsPlugin/Resources/config/services.xml" } + - { resource: "@SyliusCmsPlugin/Resources/config/fos_ck_editor/fos_ck_editor.yml" } + - { resource: "@SyliusCmsPlugin/Resources/config/grids.yml" } + - { resource: "@SyliusCmsPlugin/Resources/config/services.xml" } + - { resource: "@SyliusCmsPlugin/Resources/config/fixtures/*.yaml"} parameters: sylius.sitemap.path: "%kernel.project_dir%/var/sitemap" - bitbag_validation_group: [bitbag] - bitbag_sylius_cms_plugin.form.type.block.validation_groups: "%bitbag_validation_group%" - bitbag_sylius_cms_plugin.form.type.translation.block.validation_groups: "%bitbag_validation_group%" - bitbag_sylius_cms_plugin.form.type.block_image.validation_groups: "%bitbag_validation_group%" - bitbag_sylius_cms_plugin.form.type.page.validation_groups: "%bitbag_validation_group%" - 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.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 + sylius_validation_group: [cms] + sylius_cms.form.type.block.validation_groups: "%sylius_validation_group%" + sylius_cms.form.type.content_configuration.validation_groups: "%sylius_validation_group%" + sylius_cms.form.type.block_image.validation_groups: "%sylius_validation_group%" + sylius_cms.form.type.page.validation_groups: "%sylius_validation_group%" + sylius_cms.form.type.translation.page.validation_groups: "%sylius_validation_group%" + sylius_cms.form.type.collection.validation_groups: "%sylius_validation_group%" + sylius_cms.form.type.translation.media.validation_groups: "%sylius_validation_group%" + sylius_cms.form.type.media.validation_groups: "%sylius_validation_group%" + sylius_cms.form.type.template.validation_groups: "%sylius_validation_group%" + sylius_cms.uploader.filesystem: sylius_cms_media jms_serializer: metadata: directories: - bitbag-section: - namespace_prefix: "BitBag\\SyliusCmsPlugin" - path: "@BitBagSyliusCmsPlugin/Resources/config/serializer" + cms-section: + namespace_prefix: "Sylius\\CmsPlugin" + path: "@SyliusCmsPlugin/Resources/config/serializer" knp_gaufrette: adapters: - bitbag_sylius_cms_plugin_media: + sylius_cms_media: local: directory: "%sylius_core.public_dir%" create: true filesystems: - bitbag_sylius_cms_plugin_media: - adapter: "%bitbag_sylius_cms_plugin.uploader.filesystem%" + sylius_cms_media: + adapter: "%sylius_cms.uploader.filesystem%" liip_imagine: loaders: @@ -49,5 +47,5 @@ sylius_ui: sylius.admin.layout.javascripts: blocks: version_script: - template: "@BitBagSyliusCmsPlugin/Asset/_cmsVersionScript.html.twig" + template: "@SyliusCmsPlugin/Asset/_cmsVersionScript.html.twig" priority: 30 diff --git a/src/Resources/config/doctrine/Block.orm.xml b/src/Resources/config/doctrine/Block.orm.xml index 9cebf77ef..91497e036 100644 --- a/src/Resources/config/doctrine/Block.orm.xml +++ b/src/Resources/config/doctrine/Block.orm.xml @@ -5,28 +5,43 @@ xsi:schemaLocation="https://doctrine-project.org/schemas/orm/doctrine-mapping https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> - + + + + + - - + + + + - + - - + + + + + + + + + + + @@ -36,8 +51,8 @@ - - + + @@ -47,13 +62,13 @@ - - + + - + diff --git a/src/Resources/config/doctrine/BlockTranslation.orm.xml b/src/Resources/config/doctrine/BlockTranslation.orm.xml deleted file mode 100644 index b3ebfa897..000000000 --- a/src/Resources/config/doctrine/BlockTranslation.orm.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/Resources/config/doctrine/Collection.orm.xml b/src/Resources/config/doctrine/Collection.orm.xml new file mode 100644 index 000000000..ce82918e4 --- /dev/null +++ b/src/Resources/config/doctrine/Collection.orm.xml @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Resources/config/doctrine/ContentConfiguration.orm.xml b/src/Resources/config/doctrine/ContentConfiguration.orm.xml new file mode 100644 index 000000000..88e004be2 --- /dev/null +++ b/src/Resources/config/doctrine/ContentConfiguration.orm.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Resources/config/doctrine/FrequentlyAskedQuestion.orm.xml b/src/Resources/config/doctrine/FrequentlyAskedQuestion.orm.xml deleted file mode 100644 index 77bdfb725..000000000 --- a/src/Resources/config/doctrine/FrequentlyAskedQuestion.orm.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/Resources/config/doctrine/FrequentlyAskedQuestionTranslation.orm.xml b/src/Resources/config/doctrine/FrequentlyAskedQuestionTranslation.orm.xml deleted file mode 100644 index 6502ef579..000000000 --- a/src/Resources/config/doctrine/FrequentlyAskedQuestionTranslation.orm.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/Resources/config/doctrine/Media.orm.xml b/src/Resources/config/doctrine/Media.orm.xml index 562b1a164..7ce6df21c 100644 --- a/src/Resources/config/doctrine/Media.orm.xml +++ b/src/Resources/config/doctrine/Media.orm.xml @@ -5,13 +5,15 @@ xsi:schemaLocation="https://doctrine-project.org/schemas/orm/doctrine-mapping https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> - + + + @@ -24,32 +26,12 @@ - - - - - - - - - - - - - - - - - - - - - + - + - + @@ -57,5 +39,7 @@ + + diff --git a/src/Resources/config/doctrine/MediaTranslation.orm.xml b/src/Resources/config/doctrine/MediaTranslation.orm.xml index 8c6b48578..a68cb35ac 100644 --- a/src/Resources/config/doctrine/MediaTranslation.orm.xml +++ b/src/Resources/config/doctrine/MediaTranslation.orm.xml @@ -5,13 +5,11 @@ 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/Page.orm.xml b/src/Resources/config/doctrine/Page.orm.xml index 44e28cb8c..2db129e9b 100644 --- a/src/Resources/config/doctrine/Page.orm.xml +++ b/src/Resources/config/doctrine/Page.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"> - + @@ -15,6 +15,10 @@ + + + + @@ -25,30 +29,10 @@ - - - - - - - - - - - - - - - - - - - - - + - + @@ -58,5 +42,14 @@ + + + + + + + + + diff --git a/src/Resources/config/doctrine/PageTranslation.orm.xml b/src/Resources/config/doctrine/PageTranslation.orm.xml index aae0fe5a7..2968a0cdd 100644 --- a/src/Resources/config/doctrine/PageTranslation.orm.xml +++ b/src/Resources/config/doctrine/PageTranslation.orm.xml @@ -5,34 +5,25 @@ 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/SectionTranslation.orm.xml b/src/Resources/config/doctrine/SectionTranslation.orm.xml deleted file mode 100644 index 0dd78094a..000000000 --- a/src/Resources/config/doctrine/SectionTranslation.orm.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - diff --git a/src/Resources/config/doctrine/Section.orm.xml b/src/Resources/config/doctrine/Template.orm.xml similarity index 54% rename from src/Resources/config/doctrine/Section.orm.xml rename to src/Resources/config/doctrine/Template.orm.xml index 29f59fff5..3804931d1 100644 --- a/src/Resources/config/doctrine/Section.orm.xml +++ b/src/Resources/config/doctrine/Template.orm.xml @@ -2,16 +2,22 @@ - + - + + + + + + + + diff --git a/src/Resources/config/fixtures/1_collection.yaml b/src/Resources/config/fixtures/1_collection.yaml new file mode 100644 index 000000000..da2edc950 --- /dev/null +++ b/src/Resources/config/fixtures/1_collection.yaml @@ -0,0 +1,31 @@ +sylius_fixtures: + suites: + default: + listeners: + orm_purger: ~ + logger: ~ + fixtures: + collection: + options: + custom: + blog: + name: "Blog" + type: "page" + homepage: + name: "Homepage" + type: "page" + homepage_banner: + name: "Homepage" + type: "media" + black_friday: + name: "Black Friday" + type: "block" + black_friday_banner: + name: "Black Friday banners" + type: "media" + blog_images: + name: "Blog images" + type: "media" + products_details: + name: "Product details" + type: "block" diff --git a/src/Resources/config/fixtures/1_media.yaml b/src/Resources/config/fixtures/1_media.yaml new file mode 100644 index 000000000..194034e5d --- /dev/null +++ b/src/Resources/config/fixtures/1_media.yaml @@ -0,0 +1,218 @@ +parameters: + fixtures_dir: "%sylius_cms.fixtures_dir%/images" + +sylius_fixtures: + suites: + default: + listeners: + orm_purger: ~ + logger: ~ + fixtures: + media: + options: + custom: + black_friday_banner: + name: "Black friday banner" + channels: + - "FASHION_WEB" + type: image + path: "%fixtures_dir%/black_friday_banner.png" + original_name: "black_friday_banner.png" + collections: + - "black_friday_banner" + translations: + en_US: + alt: "Black friday banner" + homepage_banner_1: + name: "Homepage banner 1 (black friday)" + channels: + - "FASHION_WEB" + collections: + - "homepage_banner" + - "black_friday_banner" + type: image + path: "%fixtures_dir%/homepage_banner_1.png" + original_name: "homepage_banner_1.png" + translations: + en_US: + alt: "Homepage banner 1" + homepage_banner_2: + name: "Homepage banner 2" + channels: + - "FASHION_WEB" + collections: + - "homepage_banner" + type: image + path: "%fixtures_dir%/homepage_banner_2.png" + original_name: "homepage_banner_2.png" + translations: + en_US: + alt: "Homepage_banner_2" + homepage_banner_3: + name: "Homepage banner 3" + channels: + - "FASHION_WEB" + collections: + - "homepage_banner" + type: image + path: "%fixtures_dir%/homepage_banner_3.png" + original_name: "homepage_banner_3.png" + translations: + en_US: + alt: "Homepage banner 3" + blog_banner: + name: "Blog banner" + channels: + - "FASHION_WEB" + collections: + - "blog_images" + type: image + path: "%fixtures_dir%/blog_banner.png" + original_name: "blog_banner.png" + translations: + en_US: + alt: "Blog banner" + blog_post_1_header_banner: + name: "Blog post 1 banner" + channels: + - "FASHION_WEB" + collections: + - "blog_images" + type: image + path: "%fixtures_dir%/blog_post_1_header_banner.png" + original_name: "blog_post_1_header_banner.png" + translations: + en_US: + alt: "Blog post 1 banner" + blog_post_2_header_banner: + name: "Blog post 2 banner" + channels: + - "FASHION_WEB" + collections: + - "blog_images" + type: image + path: "%fixtures_dir%/blog_post_2_header_banner.png" + original_name: "blog_post_2_header_banner.png" + translations: + en_US: + alt: "Blog post 2 banner" + blog_post_3_header_banner: + name: "Blog post 3 banner" + channels: + - "FASHION_WEB" + collections: + - "blog_images" + type: image + path: "%fixtures_dir%/blog_post_3_header_banner.png" + original_name: "blog_post_3_header_banner.png" + translations: + en_US: + alt: "Blog post 3 banner" + blog_post_1_teaser_image: + name: "Blog post 1 teaser" + channels: + - "FASHION_WEB" + collections: + - "blog_images" + type: image + path: "%fixtures_dir%/blog_post_1_teaser_image.png" + original_name: "blog_post_1_teaser_image.png" + translations: + en_US: + alt: "Blog post 1 teaser" + blog_post_2_teaser_image: + name: "Blog post 2 teaser" + channels: + - "FASHION_WEB" + collections: + - "blog_images" + type: image + path: "%fixtures_dir%/blog_post_2_teaser_image.png" + original_name: "blog_post_2_teaser_image.png" + translations: + en_US: + alt: "Blog post 2 teaser" + blog_post_3_teaser_image: + name: "Blog post 3 teaser" + channels: + - "FASHION_WEB" + collections: + - "blog_images" + type: image + path: "%fixtures_dir%/blog_post_3_teaser_image.png" + original_name: "blog_post_3_teaser_image.png" + translations: + en_US: + alt: "Blog post 3 teaser" + blog_post_1_content_image_1: + name: "Blog post 1 content image 1" + channels: + - "FASHION_WEB" + collections: + - "blog_images" + type: image + path: "%fixtures_dir%/blog_post_1_content_image_1.png" + original_name: "blog_post_1_content_image_1.png" + translations: + en_US: + alt: "Blog post 1 content image 1" + blog_post_1_content_image_2: + name: "Blog post 1 content image 2" + channels: + - "FASHION_WEB" + collections: + - "blog_images" + type: image + path: "%fixtures_dir%/blog_post_1_content_image_2.png" + original_name: "blog_post_1_content_image_2.png" + translations: + en_US: + alt: "Blog post 1 content image 2" + blog_post_2_content_image_1: + name: "Blog post 2 content image 1" + channels: + - "FASHION_WEB" + collections: + - "blog_images" + type: image + path: "%fixtures_dir%/blog_post_2_content_image_1.png" + original_name: "blog_post_2_content_image_1.png" + translations: + en_US: + alt: "Blog post 2 content image 1" + blog_post_2_content_image_2: + name: "Blog post 2 content image 2" + channels: + - "FASHION_WEB" + collections: + - "blog_images" + type: image + path: "%fixtures_dir%/blog_post_2_content_image_2.png" + original_name: "blog_post_2_content_image_2.png" + translations: + en_US: + alt: "Blog post 2 content image 2" + blog_post_3_content_image_1: + name: "Blog post 3 content image 1" + channels: + - "FASHION_WEB" + collections: + - "blog_images" + type: image + path: "%fixtures_dir%/blog_post_3_content_image_1.png" + original_name: "blog_post_3_content_image_1.png" + translations: + en_US: + alt: "Blog post 3 content image 1" + blog_post_3_content_image_2: + name: "Blog post 3 content image 2" + channels: + - "FASHION_WEB" + collections: + - "blog_images" + type: image + path: "%fixtures_dir%/blog_post_3_content_image_2.png" + original_name: "blog_post_3_content_image_2.png" + translations: + en_US: + alt: "Blog post 3 content image 2" diff --git a/src/Resources/config/fixtures/1_template.yaml b/src/Resources/config/fixtures/1_template.yaml new file mode 100644 index 000000000..28bb08f58 --- /dev/null +++ b/src/Resources/config/fixtures/1_template.yaml @@ -0,0 +1,23 @@ +sylius_fixtures: + suites: + default: + listeners: + orm_purger: ~ + logger: ~ + fixtures: + template: + options: + custom: + homepage: + name: "Page template" + type: "page" + content_elements: + - type: "textarea" + - type: "multiple_media" + about: + name: "Block template" + type: "block" + content_elements: + - type: "heading" + - type: "textarea" + - type: "single_media" diff --git a/src/Resources/config/fixtures/2_block.yaml b/src/Resources/config/fixtures/2_block.yaml new file mode 100644 index 000000000..f44e860c6 --- /dev/null +++ b/src/Resources/config/fixtures/2_block.yaml @@ -0,0 +1,326 @@ +sylius_fixtures: + suites: + default: + listeners: + orm_purger: ~ + logger: ~ + fixtures: + block: + options: + custom: + homepage_textarea: + name: "Welcome in SyliusCmsPlugin!" + channels: + - "FASHION_WEB" + collections: + - "homepage" + content_elements: + en_US: + spacer1: + type: "spacer" + data: + spacer: 12 + heading: + type: "heading" + data: + heading_type: "h1" + heading: "Welcome in SyliusCmsPlugin! 🤗" + textarea: + type: "textarea" + data: + textarea: | +

+ Welcome to SyliusCmsPlugin, where style meets comfort! Explore our latest collection of trendy t-shirts, stylish dresses, and versatile caps, designed for both men and women. Whether you're dressing up or keeping it casual, our curated selection offers something for everyone. Elevate your wardrobe with pieces that reflect your unique personality and fit perfectly into your everyday life. Shop now and discover your new favorite look! +

+

+ Discover our latest collection: +

    +
  • Trendy T-Shirts - Perfect for any occasion, our t-shirts combine comfort with contemporary designs.
  • +
  • Stylish Dresses - From casual to chic, our dresses are crafted to make you feel confident and elegant.
  • +
  • Versatile Caps - Add the perfect finishing touch with our range of caps, designed to complement any outfit.
  • +
+

+ homepage_products_carousel: + name: "See our collection of brand new T-Shirts!" + channels: + - "FASHION_WEB" + collections: + - "homepage" + content_elements: + en_US: + heading: + type: "heading" + data: + heading_type: "h2" + heading: "See our collection of brand new T-Shirts! 👕" + textarea: + type: "textarea" + data: + textarea: | +

+ Our T-Shirts collection offers a blend of comfort and style, featuring a variety of designs that cater to every taste. Whether you're looking for classic basics or bold statement pieces, you'll find the perfect fit to express your unique personality. +

+ products_carousel: + type: "products_carousel" + data: + products_carousel: + products: + - "Everyday_white_basic_T_Shirt" + - "Loose_white_designer_T_Shirt" + - "Ribbed_copper_slim_fit_Tee" + - "Sport_basic_white_T_Shirt" + - "Raglan_grey_black_Tee" + - "Oversize_white_cotton_T_Shirt" + homepage_banner_1: + name: "Homepage banner 1" + channels: + - "FASHION_WEB" + collections: + - "homepage" + - "black_friday" + content_elements: + en_US: + spacer1: + type: "spacer" + data: + spacer: 20 + single_media: + type: "single_media" + data: + single_media: "homepage_banner_1" + spacer2: + type: "spacer" + data: + spacer: 20 + homepage_banner_2: + name: "Homepage banner 2" + channels: + - "FASHION_WEB" + collections: + - "homepage" + content_elements: + en_US: + single_media: + type: "single_media" + data: + single_media: "homepage_banner_2" + homepage_banner_3: + name: "Homepage banner 3" + channels: + - "FASHION_WEB" + collections: + - "homepage" + content_elements: + en_US: + single_media: + type: "single_media" + data: + single_media: "homepage_banner_3" + spacer1: + type: "spacer" + data: + spacer: 10 + homepage_products_carousel_by_taxon: + name: "How about jeans?" + channels: + - "FASHION_WEB" + collections: + - "homepage" + content_elements: + en_US: + spacer1: + type: "spacer" + data: + spacer: 10 + heading: + type: "heading" + data: + heading_type: "h2" + heading: "How about jeans? 👖" + textarea: + type: "textarea" + data: + textarea: | +

+ Discover our Jeans collection, where comfort meets timeless style. Whether you're looking for the perfect pair to wear every day or something more fashion-forward, our jeans are designed to fit seamlessly into your wardrobe. +

+

+ Key features of our Dresses collection: + +

    +
  • Variety of Fits: From skinny to relaxed, we have a fit for every body type.
  • +
  • Premium Denim: Durable, high-quality fabrics that offer both comfort and longevity.
  • +
  • Versatile Styles: Classic washes, distressed details, and contemporary cuts to suit any occasion.
  • +
  • Perfect Stretch: Just the right amount of stretch for a comfortable, flattering fit.
  • +
+

+

+ Elevate your denim game with our collection and find your new favorite pair today! +

+ products_carousel_by_taxon: + type: "products_carousel_by_taxon" + data: + products_carousel_by_taxon: "jeans" + homepage_products_grid: + name: "Meet our caps brand" + channels: + - "FASHION_WEB" + collections: + - "homepage" + content_elements: + en_US: + heading: + type: "heading" + data: + heading_type: "h2" + heading: "Meet our caps brand 🧢" + textarea: + type: "textarea" + data: + textarea: | +

+ Our Caps collection combines functionality with fashion, offering a range of designs that suit any style. Whether you need a sporty edge or a casual accessory, our caps are the perfect finishing touch for any outfit. +

+ products_grid: + type: "products_grid" + data: + products_grid: + products: + - "Knitted_burgundy_winter_cap" + - "Knitted_wool_blend_green_cap" + - "Knitted_white_pompom_cap" + - "Cashmere_blend_violet_beanie" + homepage_products_grid_by_taxon: + name: "See also our dress collection!" + channels: + - "FASHION_WEB" + collections: + - "homepage" + content_elements: + en_US: + heading: + type: "heading" + data: + heading_type: "h2" + heading: "See also our dress collection! 👗" + textarea: + type: "textarea" + data: + textarea: | +

+ Explore our Dresses collection, where style and sophistication come together in perfect harmony. Whether you're dressing for a special occasion or simply want to elevate your everyday look, our dresses offer something for every moment. +

+

+ Key features of our Dresses collection: + +

    +
  • Versatile Styles: From casual day dresses to elegant evening wear.
  • +
  • High-Quality Fabrics: Soft, breathable materials that move with you.
  • +
  • Flattering Fits: Designed to enhance your natural shape and boost confidence.
  • +
  • Unique Designs: Standout patterns and colors that reflect the latest trends.
  • +
+

+

+ Find the perfect dress to match your style and make every day a little more special! +

+ products_grid_by_taxon: + type: "products_grid_by_taxon" + data: + products_grid_by_taxon: "dresses" + homepage_taxons_list: + name: "Not interested in caps? See all our brands" + channels: + - "FASHION_WEB" + collections: + - "homepage" + content_elements: + en_US: + heading: + type: "heading" + data: + heading_type: "h2" + heading: "Not interested in caps? See all our brands:" + textarea: + type: "textarea" + data: + textarea: | +

+ Check out our other collections to complete your look! Explore our diverse range of T-Shirts, where comfort meets contemporary style, perfect for any occasion. Don't miss our Caps collection, offering the ideal blend of fashion and functionality to top off your outfit. And for those special moments, our Dresses collection features stylish options that will make you feel confident and elegant. Discover your new favorites today! +

+ taxons_list: + type: "taxons_list" + data: + taxons_list: + taxons: + - "t_shirts" + - "caps" + - "dresses" + - "jeans" + black_friday_banner_taxon: + name: "Black friday banner (taxons)" + channels: + - "FASHION_WEB" + collections: + - "black_friday" + taxons: + - "t_shirts" + - "mens_t_shirts" + - "womens_t_shirts" + content_elements: + en_US: + single_media: + type: "single_media" + data: + single_media: "black_friday_banner" + black_friday_banner_product: + name: "Black friday banner (products)" + channels: + - "FASHION_WEB" + collections: + - "black_friday" + products_in_taxons: + - "mens_t_shirts" + - "womens_t_shirts" + content_elements: + en_US: + single_media: + type: "single_media" + data: + single_media: "black_friday_banner" + spacer1: + type: "spacer" + data: + spacer: 20 + specified_products_in_taxons: + name: "You may also like" + channels: + - "FASHION_WEB" + collections: + - "products_details" + products_in_taxons: + - "mens_t_shirts" + - "womens_t_shirts" + content_elements: + en_US: + spacer1: + type: "spacer" + data: + spacer: 20 + heading1: + type: "heading" + data: + heading_type: "h2" + heading: "You may also like:" + products_carousel_by_taxon: + type: "products_carousel_by_taxon" + data: + products_carousel_by_taxon: "t_shirts" + heading2: + type: "heading" + data: + heading_type: "h2" + heading: "Our best sales:" + products_grid_by_taxon: + type: "products_grid_by_taxon" + data: + products_grid_by_taxon: "caps" diff --git a/src/Resources/config/fixtures/2_page.yaml b/src/Resources/config/fixtures/2_page.yaml new file mode 100644 index 000000000..c7fc88cba --- /dev/null +++ b/src/Resources/config/fixtures/2_page.yaml @@ -0,0 +1,556 @@ +sylius_fixtures: + suites: + default: + listeners: + orm_purger: ~ + logger: ~ + fixtures: + page: + options: + custom: + faq: + name: "Frequently Asked Questions" + channels: + - "FASHION_WEB" + translations: + en_US: + slug: "faq" + meta_title: "FAQ" + meta_keywords: "faq" + content_elements: + en_US: + question1: + type: "heading" + data: + heading_type: "h3" + heading: "What sizes are available for your clothing items?" + answer1: + type: "textarea" + data: + textarea: "

We are committed to sustainability and offer a selection of t-shirts and jeans made from eco-friendly materials. Look for our sustainability badge on the product pages for more information.>We offer a wide range of sizes for our t-shirts, caps, dresses, and jeans, from XS to XXL. Specific sizing information can be found on each product page.

" + question2: + type: "heading" + data: + heading_type: "h3" + heading: "Are your products unisex?" + answer2: + type: "textarea" + data: + textarea: "

Yes, many of our t-shirts and caps are designed to be unisex, providing stylish options for both men and women. Our dresses are designed specifically for women, while our jeans come in both men’s and women’s fits.

" + question3: + type: "heading" + data: + heading_type: "h3" + heading: "What materials are your t-shirts and jeans made from?" + answer3: + type: "textarea" + data: + textarea: "

Our t-shirts are crafted from soft, high-quality cotton blends, while our jeans are made from durable denim with just the right amount of stretch for comfort.

" + question4: + type: "heading" + data: + heading_type: "h3" + heading: "How should I care for my t-shirts and jeans to ensure they last?" + answer4: + type: "textarea" + data: + textarea: "

We recommend washing your t-shirts and jeans in cold water and tumble drying on low heat to preserve their fit and color. Always check the care label for specific instructions.

" + question5: + type: "heading" + data: + heading_type: "h3" + heading: "Do you offer international shipping?" + answer5: + type: "textarea" + data: + textarea: "

Yes, we offer international shipping to many countries. Shipping fees and delivery times will vary depending on your location.

" + question6: + type: "heading" + data: + heading_type: "h3" + heading: "Can I return or exchange an item if it doesn’t fit?" + answer6: + type: "textarea" + data: + textarea: "

Absolutely! We have a hassle-free return and exchange policy. If your item doesn’t fit, you can return it within 30 days for a full refund or exchange.

" + question7: + type: "heading" + data: + heading_type: "h3" + heading: "Do you offer any discounts for bulk purchases?" + answer7: + type: "textarea" + data: + textarea: "

Yes, we offer discounts on bulk orders. Please contact our customer service team for more information on bulk pricing and special offers.

" + question8: + type: "heading" + data: + heading_type: "h3" + heading: "How do I find the right size for your caps?" + answer8: + type: "textarea" + data: + textarea: "

Most of our caps are adjustable to fit a variety of head sizes. Each product page includes specific sizing information and instructions on how to adjust the fit.

" + question9: + type: "heading" + data: + heading_type: "h3" + heading: "Are your dresses suitable for formal occasions?" + answer9: + type: "textarea" + data: + textarea: "

Yes, our Dresses collection includes a variety of styles, from casual daywear to elegant dresses perfect for formal events.

" + question10: + type: "heading" + data: + heading_type: "h3" + heading: "Do you have any eco-friendly or sustainable options?" + answer10: + type: "textarea" + data: + textarea: "

We are committed to sustainability and offer a selection of t-shirts and jeans made from eco-friendly materials. Look for our sustainability badge on the product pages for more information.

" + blog: + name: "Blog" + channels: + - "FASHION_WEB" + translations: + en_US: + slug: "blog" + meta_title: "Blog" + content_elements: + en_US: + single_media: + type: "single_media" + data: + single_media: "blog_banner" + textarea: + type: "textarea" + data: + textarea: "

Whether you need a sporty edge or a casual accessory, our stuff is the perfect finishing touch for any outfit.

" + pages_collection: + type: "pages_collection" + data: + pages_collection: "blog" + blog_post_1: + name: "#1: Your Ultimate Guide to Beach and Holiday Fashion: Hats, Shirts, Sunglasses, and Shoes" + channels: + - "FASHION_WEB" + collections: + - "blog" + translations: + en_US: + slug: "blog-post-1" + meta_title: "Your Ultimate Guide to Beach and Holiday Fashion: Hats, Shirts, Sunglasses, and Shoes" + teaser_title: "Your Ultimate Guide to Beach and Holiday Fashion" + teaser_content: "
When planning your beach holiday wardrobe, fashion and function go hand in hand. Whether you're lounging by the pool, strolling along sandy shores, or heading out for a casual seaside dinner, nailing the perfect look is key to a stylish yet comfortable vacation. In this blog post, we’ll dive into the must-have modern fashion pieces that will elevate your beach holiday style. From chic hats to breezy shirts, trendy sunglasses to versatile shoes—let's break down how to build the perfect holiday wardrobe.
" + teaser_image: "blog_post_1_teaser_image" + content_elements: + en_US: + single_media: + type: "single_media" + data: + single_media: "blog_post_1_header_banner" + spacer0: + type: "spacer" + data: + spacer: 10 + heading1: + type: "heading" + data: + heading_type: "h2" + heading: "Your Ultimate Guide to Beach and Holiday Fashion: Hats, Shirts, Sunglasses, and Shoes" + intro: + type: "textarea" + data: + textarea: | +

When planning your beach holiday wardrobe, fashion and function go hand in hand. Whether you're lounging by the pool, strolling along sandy shores, or heading out for a casual seaside dinner, nailing the perfect look is key to a stylish yet comfortable vacation. In this blog post, we’ll dive into the must-have modern fashion pieces that will elevate your beach holiday style. From chic hats to breezy shirts, trendy sunglasses to versatile shoes—let's break down how to build the perfect holiday wardrobe.

+ subheading1: + type: "heading" + data: + heading_type: "h3" + heading: "Stylish Hats: More Than Just Sun Protection" + text1: + type: "textarea" + data: + textarea: | +

No beach wardrobe is complete without a fashionable hat. While sun protection is a must, the right hat can instantly elevate your outfit. Whether you prefer a classic wide-brimmed hat or something a bit more trendy like a bucket hat, here are some top options for your holiday look:

+
    +
  • Wide-brimmed Straw Hats: Ideal for a more elegant, laid-back beach look, offering maximum sun protection.
  • +
  • Bucket Hats: Perfect for a casual, sporty vibe. They’ve made a huge comeback and are great for packing light.
  • +
  • Fedoras: A touch of sophistication with a beachy twist. Pair it with your sundress or shirt for a relaxed, chic look.
  • +
+

These styles aren’t just practical — they’re fashion statements.

+ spacer1: + type: "spacer" + data: + spacer: 20 + image_1: + type: "single_media" + data: + single_media: "blog_post_1_content_image_1" + spacer2: + type: "spacer" + data: + spacer: 10 + subheading2: + type: "heading" + data: + heading_type: "h3" + heading: "Breezy Shirts: Keeping It Cool and Comfortable" + text2: + type: "textarea" + data: + textarea: | +

Shirts are the unsung heroes of beach and holiday wardrobes. You want something light, breathable, and versatile enough to take you from day to night. Here are some modern shirt styles to consider:

+
    +
  • Linen Shirts: Lightweight and airy, linen shirts are perfect for staying cool in hot weather. Their natural, textured look adds a laid-back charm.
  • +
  • Oversized Button-Downs: Easy to throw over swimwear or pair with shorts. These are ideal for a relaxed yet stylish beach vibe.
  • +
  • Bold Prints and Patterns: Don’t be afraid to experiment with tropical prints or stripes, which scream beach holiday!
  • +
+

The beauty of these shirts is their versatility, easily styled for daytime beach wear or a casual evening out.

+ spacer3: + type: "spacer" + data: + spacer: 10 + products_grid: + type: "products_grid" + data: + products_grid: + products: + - "Raglan_grey_&_black_Tee" + - "Loose_white_designer_T_Shirt" + - "Sport_basic_white_T_Shirt" + - "Ribbed_copper_slim_fit_Tee" + subheading3: + type: "heading" + data: + heading_type: "h3" + heading: "Trendy Sunglasses: Protect Your Eyes in Style" + text3: + type: "textarea" + data: + textarea: | +

Sunglasses are not only essential for protecting your eyes from the sun but are also a critical accessory in pulling together your holiday look. This season’s sunglasses trends are all about bold shapes and eye-catching designs:

+
    +
  • Oversized Frames: Channeling a retro vibe, oversized frames add glamour to any beach outfit.
  • +
  • Aviators: Timeless and cool, aviators are a classic style that suits almost everyone.
  • +
  • Colored Lenses: This playful trend can add a pop of color to your holiday look. Think shades of pink, blue, or yellow.
  • +
+

The right pair of sunglasses doesn’t just protect — it adds personality and polish to your overall look.

+ spacer4: + type: "spacer" + data: + spacer: 20 + image_2: + type: "single_media" + data: + single_media: "blog_post_1_content_image_2" + spacer5: + type: "spacer" + data: + spacer: 10 + subheading4: + type: "heading" + data: + heading_type: "h3" + heading: "Footwear: From Sand to Streets" + text4: + type: "textarea" + data: + textarea: | +

When it comes to holiday shoes, versatility is key. You need shoes that are comfortable for walking but also stylish enough to transition from the beach to the bar. Here are the best shoe styles for your beach holiday:

+
    +
  • Espadrilles: These comfortable, breathable shoes are perfect for the beach, yet stylish enough for an evening stroll.
  • +
  • Slide Sandals: Easy to slip on and off, slide sandals are the ultimate convenience for days spent on the sand. Plus, they come in various chic designs and materials.
  • +
  • Sneakers: For those exploring coastal towns or going on holiday adventures, a pair of fashionable yet comfortable sneakers is a must-have.
  • +
+

With these footwear options, you can easily switch between sandy beaches and urban explorations without compromising on style.

+ outro_heading: + type: "heading" + data: + heading_type: "h3" + heading: "Conclusion" + outro_text: + type: "textarea" + data: + textarea: | +

Building the perfect beach and holiday wardrobe doesn’t have to be complicated. Focus on key pieces — hats, shirts, sunglasses, and shoes — that combine fashion and functionality. Whether you’re going for a laid-back beach look or something a little more polished for evening outings, these modern fashion essentials will have you looking and feeling your best on your holiday. So pack smart, and enjoy your time in the sun with confidence and style!

+ blog_post_2: + name: "#2: Beach Suits for Everyone: Stylish and Functional Options for Women, Men, and Children" + channels: + - "FASHION_WEB" + collections: + - "blog" + translations: + en_US: + slug: "blog-post-2" + meta_title: "Beach Suits for Everyone: Stylish and Functional Options for Women, Men, and Children" + teaser_title: "Beach Suits for Everyone" + teaser_content: "
Finding the perfect beach suit isn’t just about looking good — it’s also about comfort and versatility. Whether you’re swimming, playing beach volleyball, or simply relaxing by the water, the right beachwear can make a world of difference. In this guide, we’ll explore the top beach suit trends for women, men, and children, ensuring that the whole family is stylishly prepared for any seaside adventure. From flattering swimsuits to practical designs for kids, we've got you covered.
" + teaser_image: "blog_post_2_teaser_image" + content_elements: + en_US: + single_media: + type: "single_media" + data: + single_media: "blog_post_2_header_banner" + spacer0: + type: "spacer" + data: + spacer: 10 + heading1: + type: "heading" + data: + heading_type: "h2" + heading: "Beach Suits for Everyone: Stylish and Functional Options for Women, Men, and Children" + intro: + type: "textarea" + data: + textarea: | +

Finding the perfect beach suit isn’t just about looking good — it’s also about comfort and versatility. Whether you’re swimming, playing beach volleyball, or simply relaxing by the water, the right beachwear can make a world of difference. In this guide, we’ll explore the top beach suit trends for women, men, and children, ensuring that the whole family is stylishly prepared for any seaside adventure. From flattering swimsuits to practical designs for kids, we've got you covered.

+ subheading1: + type: "heading" + data: + heading_type: "h3" + heading: "Women’s Beach Suits: Chic and Comfortable" + text1: + type: "textarea" + data: + textarea: | +

Women’s beachwear has come a long way from basic bikinis. Modern trends offer a wide array of styles that suit different body types, preferences, and activities. Here are some top picks for stylish and functional women’s beach suits:

+
    +
  • High-Waisted Bikinis: Offering a retro vibe, these are flattering for most figures and provide extra coverage, making them both stylish and comfortable.
  • +
  • One-Piece Swimsuits: Perfect for active days at the beach, one-piece suits have made a huge comeback. Look for designs with cutouts or bold prints to stay trendy.
  • +
  • Tankinis: A combination of a tank top and bikini bottoms, tankinis are ideal for those seeking more coverage without sacrificing style.
  • +
+

These options ensure that you’ll not only feel confident in your swimwear but also be ready for anything, from swimming to sunbathing.

+ spacer1: + type: "spacer" + data: + spacer: 20 + image_1: + type: "single_media" + data: + single_media: "blog_post_2_content_image_1" + spacer2: + type: "spacer" + data: + spacer: 10 + subheading2: + type: "heading" + data: + heading_type: "h3" + heading: "Men’s Beach Suits: From Casual to Sporty" + text2: + type: "textarea" + data: + textarea: | +

Men’s beachwear has evolved from basic board shorts to more diverse and stylish options. Whether you’re looking for something functional for water sports or something casual for lounging, here are the best beach suit options for men:

+
    +
  • Board Shorts: A classic option, board shorts are great for both swimming and casual beach activities. Opt for quick-dry materials for extra comfort.
  • +
  • Swim Trunks: These shorter, more tailored versions of board shorts have become increasingly popular. They offer a modern look without compromising on comfort.
  • +
  • Rash Guards: If you’re planning on spending time surfing or participating in water sports, a rash guard is a must. Not only does it protect your skin from the sun, but it also helps prevent irritation from sand and saltwater.
  • +
+

These suits provide the perfect combination of practicality and style, ensuring men can enjoy their beach day in comfort.

+ spacer3: + type: "spacer" + data: + spacer: 10 + products_grid: + type: "products_grid_by_taxon" + data: + products_grid_by_taxon: "dresses" + subheading3: + type: "heading" + data: + heading_type: "h3" + heading: "Beach Suits for Kids: Fun and Functional" + text3: + type: "textarea" + data: + textarea: | +

When it comes to children’s beachwear, the focus is on sun protection and comfort. However, that doesn’t mean kids can’t be stylish while they play in the sand! Here are some great options for children’s beach suits:

+
    +
  • Rash Guards and Swim Shirts: For both boys and girls, rash guards or swim shirts offer excellent sun protection. Look for ones with UV protection built in to keep your kids safe from the sun.
  • +
  • One-Piece Swimsuits for Girls: A classic and practical choice, one-piece swimsuits provide full coverage and are easy for active beach days.
  • +
  • Swim Shorts for Boys: Swim shorts in fun, bold prints are perfect for boys who are constantly on the move. Look for quick-drying fabrics that can handle everything from swimming to sandcastle building.
  • +
+

These suits ensure that kids can enjoy the beach safely, comfortably, and with a sense of style.

+ spacer4: + type: "spacer" + data: + spacer: 20 + image_2: + type: "single_media" + data: + single_media: "blog_post_2_content_image_2" + spacer5: + type: "spacer" + data: + spacer: 10 + subheading4: + type: "heading" + data: + heading_type: "h3" + heading: "Choosing the Right Fabrics and Features for All Ages" + text4: + type: "textarea" + data: + textarea: | +

No matter who you're shopping for — women, men, or children — choosing the right materials and features is key to getting the most out of your beachwear. Here are some essential things to look out for when buying beach suits:

+
    +
  • Quick-Drying Fabrics: For both comfort and convenience, quick-drying fabrics are a must. They prevent chafing and make transitions from beach to lunch much smoother.
  • +
  • Sun Protection: Many modern beach suits come with built-in UV protection, which is particularly important for kids but also useful for adults.
  • +
  • Adjustable Straps and Waistbands: For both women’s and men’s suits, adjustable straps or waistbands can make a huge difference in terms of comfort. Look for these features to ensure the perfect fit.
  • +
+

With the right fabrics and functional features, your beach suits will last longer and provide maximum comfort throughout your holiday.

+ outro_heading: + type: "heading" + data: + heading_type: "h3" + heading: "Conclusion" + outro_text: + type: "textarea" + data: + textarea: | +

Finding the perfect beach suit for the entire family doesn't have to be a challenge. With stylish and practical options available for women, men, and children, everyone can feel comfortable and confident at the beach. Whether you're looking for sun protection, the perfect fit, or the latest trends, these beach suits offer everything you need for a fun-filled holiday by the sea. So pack up your beach bag and get ready to make a splash with your new, fashionable beachwear!

+ + blog_post_3: + name: "#3: Beach-Ready Fashion for Men and Boys: T-Shirts, Shorts, and Shoes" + channels: + - "FASHION_WEB" + collections: + - "blog" + translations: + en_US: + slug: "blog-post-3" + meta_title: "Beach-Ready Fashion for Men and Boys: T-Shirts, Shorts, and Shoes" + teaser_title: "Beach-Ready Fashion for Men and Boys" + teaser_content: "
When hitting the beach, comfort is key, but that doesn't mean style has to take a backseat. Whether you’re a man looking for the perfect holiday wardrobe or shopping for your boys, you’ll want to find pieces that combine practicality with a touch of flair. In this guide, we’ll explore the top T-shirts, shorts, and shoes for men and boys, helping you put together the ideal beach outfit. From breezy shirts to functional footwear, this is your go-to guide for looking stylish while enjoying the sun, sand, and surf.
" + teaser_image: "blog_post_3_teaser_image" + content_elements: + en_US: + single_media: + type: "single_media" + data: + single_media: "blog_post_3_header_banner" + spacer0: + type: "spacer" + data: + spacer: 10 + heading1: + type: "heading" + data: + heading_type: "h2" + heading: "Beach-Ready Fashion for Men and Boys: T-Shirts, Shorts, and Shoes" + intro: + type: "textarea" + data: + textarea: | +

When hitting the beach, comfort is key, but that doesn't mean style has to take a backseat. Whether you’re a man looking for the perfect holiday wardrobe or shopping for your boys, you’ll want to find pieces that combine practicality with a touch of flair. In this guide, we’ll explore the top T-shirts, shorts, and shoes for men and boys, helping you put together the ideal beach outfit. From breezy shirts to functional footwear, this is your go-to guide for looking stylish while enjoying the sun, sand, and surf.

+ subheading1: + type: "heading" + data: + heading_type: "h3" + heading: "T-Shirts for Men: Style Meets Comfort" + text1: + type: "textarea" + data: + textarea: | +

A well-chosen T-shirt is an essential part of any beach look for men. The right fabric and fit can keep you cool while still looking sharp, even in the hottest weather. Here are some modern T-shirt styles that are perfect for the beach:

+
    +
  • Cotton Crew Necks: A simple cotton T-shirt is a timeless option for casual beachwear. Look for lightweight fabrics to keep cool while still offering comfort.
  • +
  • Linen Tees: For those really hot days, a linen T-shirt is perfect. It’s breathable and gives off a laid-back, effortless vibe.
  • +
  • Graphic Tees: Add a bit of personality to your beach outfit with a fun graphic tee. Whether it’s a tropical print or a favorite logo, graphic tees keep things interesting and on-trend.
  • +
+

These styles ensure you look good while staying comfortable, whether you’re lounging on the beach or heading to a seaside café.

+ spacer1: + type: "spacer" + data: + spacer: 20 + image_1: + type: "single_media" + data: + single_media: "blog_post_3_content_image_1" + spacer2: + type: "spacer" + data: + spacer: 10 + subheading2: + type: "heading" + data: + heading_type: "h3" + heading: "T-Shirts for Boys: Fun and Functional" + text2: + type: "textarea" + data: + textarea: | +

When it comes to boys’ T-shirts, you need pieces that are both practical and playful. Boys are always on the move, so their beach wardrobe should reflect that. Here are some great T-shirt options for boys:

+
    +
  • Activewear Tees: Moisture-wicking fabrics are perfect for boys who love to run around at the beach. These tees keep them dry and comfortable throughout the day.
  • +
  • Bold Prints and Patterns: Whether it’s sharks, surfboards, or palm trees, boys’ T-shirts should be fun. Look for bold prints that capture the excitement of summer.
  • +
  • Rash Guard Shirts: For sun protection, rash guard shirts are a must. These snug-fitting shirts protect against UV rays and are ideal for active days in the water.
  • +
+

These T-shirts combine comfort with style, ensuring boys can play and swim while staying protected and cool.

+ spacer3: + type: "spacer" + data: + spacer: 10 + products_carousel_by_taxon: + type: "products_carousel_by_taxon" + data: + products_carousel_by_taxon: "t_shirts" + subheading3: + type: "heading" + data: + heading_type: "h3" + heading: "Shorts for Men: Practicality with a Stylish Twist" + text3: + type: "textarea" + data: + textarea: | +

Choosing the right pair of shorts for the beach is crucial. Men need something that’s easy to move in but also stylish enough for post-beach activities. Here are some top picks for beach shorts:

+
    +
  • Board Shorts: Classic and functional, board shorts are perfect for swimming and beach sports. They’re usually made of quick-drying fabric and come in various lengths, so you can choose what’s most comfortable for you.
  • +
  • Chino Shorts: If you’re planning to hit a beachside restaurant or bar after your swim, chino shorts are a great option. They’re stylish yet casual, making them versatile for both water and land.
  • +
  • Hybrid Shorts: These are a combination of swim trunks and casual shorts. Hybrid shorts are designed to dry quickly, allowing you to wear them straight from the beach to a casual outing without needing to change.
  • +
+

With these options, you’ll always look good while staying comfortable and ready for any beachside activity.

+ spacer4: + type: "spacer" + data: + spacer: 20 + image_2: + type: "single_media" + data: + single_media: "blog_post_3_content_image_2" + spacer5: + type: "spacer" + data: + spacer: 10 + subheading4: + type: "heading" + data: + heading_type: "h3" + heading: "Shorts for Boys: Durable and Play-Friendly" + text4: + type: "textarea" + data: + textarea: | +

Boys need shorts that can withstand a day full of activities, from swimming to sandcastle building. Comfort, durability, and style should all come together. Here are some great beach short options for boys:

+
    +
  • Swim Trunks with Built-In Liners: Swim trunks with mesh liners are perfect for active boys. They’re designed for swimming, but they also dry quickly and offer freedom of movement.
  • +
  • Cargo Shorts: Ideal for boys who love pockets! Cargo shorts are not only durable but also practical, with plenty of space to stash beach finds.
  • +
  • Elastic Waist Shorts: For younger boys, elastic waistbands make it easy to slip shorts on and off. Look for lightweight, quick-dry materials for ultimate beach comfort.
  • +
+

These options ensure boys can enjoy their time at the beach with full freedom of movement while looking cute and cool.

+ outro_heading: + type: "heading" + data: + heading_type: "h3" + heading: "Conclusion" + outro_text: + type: "textarea" + data: + textarea: | +

With the right T-shirts, shorts, and shoes, men and boys can enjoy their time at the beach in both style and comfort. From cool, breathable shirts to functional and fashionable shorts, and durable footwear, there are plenty of options to ensure everyone looks great while feeling good. Whether it’s a casual beach day or an adventure-filled holiday, these fashion staples will have you covered from sand to shore. So pack smart and get ready to enjoy the sun, sea, and sand in style!

diff --git a/src/Resources/config/fixtures/images/black_friday_banner.png b/src/Resources/config/fixtures/images/black_friday_banner.png new file mode 100644 index 000000000..f9bbf7066 Binary files /dev/null and b/src/Resources/config/fixtures/images/black_friday_banner.png differ diff --git a/src/Resources/config/fixtures/images/blog_banner.png b/src/Resources/config/fixtures/images/blog_banner.png new file mode 100644 index 000000000..f9bbf7066 Binary files /dev/null and b/src/Resources/config/fixtures/images/blog_banner.png differ diff --git a/src/Resources/config/fixtures/images/blog_post_1_content_image_1.png b/src/Resources/config/fixtures/images/blog_post_1_content_image_1.png new file mode 100644 index 000000000..223a5aeb8 Binary files /dev/null and b/src/Resources/config/fixtures/images/blog_post_1_content_image_1.png differ diff --git a/src/Resources/config/fixtures/images/blog_post_1_content_image_2.png b/src/Resources/config/fixtures/images/blog_post_1_content_image_2.png new file mode 100644 index 000000000..5a093a404 Binary files /dev/null and b/src/Resources/config/fixtures/images/blog_post_1_content_image_2.png differ diff --git a/src/Resources/config/fixtures/images/blog_post_1_header_banner.png b/src/Resources/config/fixtures/images/blog_post_1_header_banner.png new file mode 100644 index 000000000..0f7d390a9 Binary files /dev/null and b/src/Resources/config/fixtures/images/blog_post_1_header_banner.png differ diff --git a/src/Resources/config/fixtures/images/blog_post_1_teaser_image.png b/src/Resources/config/fixtures/images/blog_post_1_teaser_image.png new file mode 100644 index 000000000..313067635 Binary files /dev/null and b/src/Resources/config/fixtures/images/blog_post_1_teaser_image.png differ diff --git a/src/Resources/config/fixtures/images/blog_post_2_content_image_1.png b/src/Resources/config/fixtures/images/blog_post_2_content_image_1.png new file mode 100644 index 000000000..427ca7eea Binary files /dev/null and b/src/Resources/config/fixtures/images/blog_post_2_content_image_1.png differ diff --git a/src/Resources/config/fixtures/images/blog_post_2_content_image_2.png b/src/Resources/config/fixtures/images/blog_post_2_content_image_2.png new file mode 100644 index 000000000..223a5aeb8 Binary files /dev/null and b/src/Resources/config/fixtures/images/blog_post_2_content_image_2.png differ diff --git a/src/Resources/config/fixtures/images/blog_post_2_header_banner.png b/src/Resources/config/fixtures/images/blog_post_2_header_banner.png new file mode 100644 index 000000000..751f3fcfa Binary files /dev/null and b/src/Resources/config/fixtures/images/blog_post_2_header_banner.png differ diff --git a/src/Resources/config/fixtures/images/blog_post_2_teaser_image.png b/src/Resources/config/fixtures/images/blog_post_2_teaser_image.png new file mode 100644 index 000000000..9e89cb73f Binary files /dev/null and b/src/Resources/config/fixtures/images/blog_post_2_teaser_image.png differ diff --git a/src/Resources/config/fixtures/images/blog_post_3_content_image_1.png b/src/Resources/config/fixtures/images/blog_post_3_content_image_1.png new file mode 100644 index 000000000..f9bbf7066 Binary files /dev/null and b/src/Resources/config/fixtures/images/blog_post_3_content_image_1.png differ diff --git a/src/Resources/config/fixtures/images/blog_post_3_content_image_2.png b/src/Resources/config/fixtures/images/blog_post_3_content_image_2.png new file mode 100644 index 000000000..560534ce8 Binary files /dev/null and b/src/Resources/config/fixtures/images/blog_post_3_content_image_2.png differ diff --git a/src/Resources/config/fixtures/images/blog_post_3_header_banner.png b/src/Resources/config/fixtures/images/blog_post_3_header_banner.png new file mode 100644 index 000000000..112ad47c4 Binary files /dev/null and b/src/Resources/config/fixtures/images/blog_post_3_header_banner.png differ diff --git a/src/Resources/config/fixtures/images/blog_post_3_teaser_image.png b/src/Resources/config/fixtures/images/blog_post_3_teaser_image.png new file mode 100644 index 000000000..4df05876b Binary files /dev/null and b/src/Resources/config/fixtures/images/blog_post_3_teaser_image.png differ diff --git a/src/Resources/config/fixtures/images/homepage_banner_1.png b/src/Resources/config/fixtures/images/homepage_banner_1.png new file mode 100644 index 000000000..f9bbf7066 Binary files /dev/null and b/src/Resources/config/fixtures/images/homepage_banner_1.png differ diff --git a/src/Resources/config/fixtures/images/homepage_banner_2.png b/src/Resources/config/fixtures/images/homepage_banner_2.png new file mode 100644 index 000000000..751f3fcfa Binary files /dev/null and b/src/Resources/config/fixtures/images/homepage_banner_2.png differ diff --git a/src/Resources/config/fixtures/images/homepage_banner_3.png b/src/Resources/config/fixtures/images/homepage_banner_3.png new file mode 100644 index 000000000..112ad47c4 Binary files /dev/null and b/src/Resources/config/fixtures/images/homepage_banner_3.png differ diff --git a/src/Resources/config/fixtures/images/specified_products_banner.png b/src/Resources/config/fixtures/images/specified_products_banner.png new file mode 100644 index 000000000..f9bbf7066 Binary files /dev/null and b/src/Resources/config/fixtures/images/specified_products_banner.png differ diff --git a/src/Resources/config/fos_ck_editor/fos_ck_editor.yml b/src/Resources/config/fos_ck_editor/fos_ck_editor.yml index 2ef9a9dbb..989d8c4e5 100644 --- a/src/Resources/config/fos_ck_editor/fos_ck_editor.yml +++ b/src/Resources/config/fos_ck_editor/fos_ck_editor.yml @@ -1,8 +1,8 @@ fos_ck_editor: - default_config: bitbag_sylius_cms_plugin + default_config: sylius_cms configs: - bitbag_sylius_cms_plugin: - toolbar: bitbag_sylius_cms_plugin + sylius_cms: + toolbar: sylius_cms enterMode: 3 forcePasteAsPlainText: 'allow-word' allowedContent: true @@ -13,14 +13,14 @@ fos_ck_editor: - "exportpdf" plugins: mediaVideo: - path: '/bundles/bitbagsyliuscmsplugin/js/ckeditor-plugins/video/' + path: '/bundles/syliuscmsplugin/js/ckeditor-plugins/video/' filename: 'plugin.js' mediaImage: - path: '/bundles/bitbagsyliuscmsplugin/js/ckeditor-plugins/image/' + path: '/bundles/syliuscmsplugin/js/ckeditor-plugins/image/' filename: 'plugin.js' toolbars: configs: - bitbag_sylius_cms_plugin: + sylius_cms: - '@standard.clipboard' - '@standard.editing' - '@standard.links' diff --git a/src/Resources/config/grids.yml b/src/Resources/config/grids.yml index 3e22d5a0e..3bdbb63fa 100755 --- a/src/Resources/config/grids.yml +++ b/src/Resources/config/grids.yml @@ -1,8 +1,8 @@ imports: - - { resource: "@BitBagSyliusCmsPlugin/Resources/config/grids/admin.yml" } - - { resource: "@BitBagSyliusCmsPlugin/Resources/config/grids/shop.yml" } + - { resource: "@SyliusCmsPlugin/Resources/config/grids/admin.yml" } + - { resource: "@SyliusCmsPlugin/Resources/config/grids/shop.yml" } sylius_grid: templates: action: - import: "@BitBagSyliusCmsPlugin/Grid/Action/import.html.twig" + import: "@SyliusCmsPlugin/Grid/Action/import.html.twig" diff --git a/src/Resources/config/grids/admin.yml b/src/Resources/config/grids/admin.yml index 4e25dc246..cbbed98f5 100755 --- a/src/Resources/config/grids/admin.yml +++ b/src/Resources/config/grids/admin.yml @@ -1,6 +1,6 @@ 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/media.yml" } + - { resource: "@SyliusCmsPlugin/Resources/config/grids/admin/block.yml" } + - { resource: "@SyliusCmsPlugin/Resources/config/grids/admin/page.yml" } + - { resource: "@SyliusCmsPlugin/Resources/config/grids/admin/collection.yml" } + - { resource: "@SyliusCmsPlugin/Resources/config/grids/admin/media.yml" } + - { resource: "@SyliusCmsPlugin/Resources/config/grids/admin/template.yml" } diff --git a/src/Resources/config/grids/admin/block.yml b/src/Resources/config/grids/admin/block.yml index 3b98296cd..d6c7902fa 100755 --- a/src/Resources/config/grids/admin/block.yml +++ b/src/Resources/config/grids/admin/block.yml @@ -1,17 +1,21 @@ sylius_grid: grids: - bitbag_sylius_cms_plugin_admin_block: + sylius_cms_admin_block: driver: name: doctrine/orm options: - class: "%bitbag_sylius_cms_plugin.model.block.class%" - repository: - method: createListQueryBuilder - arguments: ["%locale%"] + class: "%sylius_cms.model.block.class%" sorting: code: asc limits: [10, 25, 50] fields: + name: + type: twig + label: sylius_cms.ui.name + sortable: name + path: . + options: + template: "@SyliusCmsPlugin/Grid/Field/name.html.twig" code: type: string label: sylius.ui.code @@ -23,12 +27,18 @@ sylius_grid: sortable: ~ options: template: "@SyliusUi/Grid/Field/enabled.html.twig" - sections: + collections: + type: twig + label: sylius_cms.ui.collections + path: . + options: + template: "@SyliusCmsPlugin/Grid/Field/collections.html.twig" + channels: type: twig - label: bitbag_sylius_cms_plugin.ui.sections + label: sylius_cms.ui.channels path: . options: - template: "@BitBagSyliusCmsPlugin/Grid/Field/sections.html.twig" + template: "@SyliusCmsPlugin/Grid/Field/channels.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 64% rename from src/Resources/config/grids/admin/section.yml rename to src/Resources/config/grids/admin/collection.yml index 293b6f460..0f8492a48 100755 --- a/src/Resources/config/grids/admin/section.yml +++ b/src/Resources/config/grids/admin/collection.yml @@ -1,25 +1,29 @@ sylius_grid: grids: - bitbag_sylius_cms_plugin_admin_section: + sylius_cms_admin_collection: driver: name: doctrine/orm options: - class: "%bitbag_sylius_cms_plugin.model.section.class%" - repository: - method: createListQueryBuilder - arguments: ["%locale%"] + class: "%sylius_cms.model.collection.class%" sorting: code: asc limits: [10, 25, 50] fields: + name: + type: twig + label: sylius_cms.ui.name + sortable: name + path: . + options: + template: "@SyliusCmsPlugin/Grid/Field/name.html.twig" code: type: string - label: bitbag_sylius_cms_plugin.ui.code + label: sylius_cms.ui.code sortable: ~ - name: + type: type: string - label: bitbag_sylius_cms_plugin.ui.name - sortable: translation.name + label: sylius_cms.ui.type + sortable: ~ filters: search: type: string diff --git a/src/Resources/config/grids/admin/frequently_asked_question.yml b/src/Resources/config/grids/admin/frequently_asked_question.yml deleted file mode 100755 index b024a4f69..000000000 --- a/src/Resources/config/grids/admin/frequently_asked_question.yml +++ /dev/null @@ -1,48 +0,0 @@ -sylius_grid: - grids: - bitbag_sylius_cms_plugin_admin_frequently_asked_question: - driver: - name: doctrine/orm - options: - class: "%bitbag_sylius_cms_plugin.model.frequently_asked_question.class%" - repository: - method: createListQueryBuilder - arguments: ["%locale%"] - sorting: - position: asc - limits: [10, 25, 50] - fields: - position: - type: string - label: sylius.ui.position - sortable: ~ - code: - type: string - label: sylius.ui.code - sortable: ~ - question: - type: string - label: bitbag_sylius_cms_plugin.ui.question - sortable: translation.question - answer: - type: string - label: bitbag_sylius_cms_plugin.ui.answer - sortable: translation.answer - filters: - search: - type: string - label: sylius.ui.search - options: - fields: [code] - actions: - main: - create: - type: create - item: - update: - type: update - delete: - type: delete - bulk: - delete: - type: delete diff --git a/src/Resources/config/grids/admin/media.yml b/src/Resources/config/grids/admin/media.yml index e5608163f..24de6d2fb 100644 --- a/src/Resources/config/grids/admin/media.yml +++ b/src/Resources/config/grids/admin/media.yml @@ -1,10 +1,10 @@ sylius_grid: grids: - bitbag_sylius_cms_plugin_admin_media: + sylius_cms_admin_media: driver: name: doctrine/orm options: - class: "%bitbag_sylius_cms_plugin.model.media.class%" + class: "%sylius_cms.model.media.class%" repository: method: createListQueryBuilder arguments: ["%locale%"] @@ -14,23 +14,38 @@ sylius_grid: fields: media_file: type: twig - label: bitbag_sylius_cms_plugin.ui.preview + label: sylius_cms.ui.preview path: . options: - template: "@BitBagSyliusCmsPlugin/Grid/Field/image_preview.html.twig" + template: "@SyliusCmsPlugin/Grid/Field/image_preview.html.twig" name: - type: string - label: bitbag_sylius_cms_plugin.ui.name + type: twig + label: sylius_cms.ui.name + sortable: name + path: . + options: + template: "@SyliusCmsPlugin/Grid/Field/name.html.twig" code: type: string - label: bitbag_sylius_cms_plugin.ui.code + label: sylius_cms.ui.code sortable: ~ - path: - type: string - label: bitbag_sylius_cms_plugin.ui.path - type: - type: string - label: bitbag_sylius_cms_plugin.ui.type + enabled: + type: twig + label: sylius.ui.enabled + options: + template: "@SyliusUi/Grid/Field/enabled.html.twig" + collections: + type: twig + label: sylius_cms.ui.collections + path: . + options: + template: "@SyliusCmsPlugin/Grid/Field/collections.html.twig" + channels: + type: twig + label: sylius_cms.ui.channels + path: . + options: + template: "@SyliusCmsPlugin/Grid/Field/channels.html.twig" filters: search: type: string @@ -42,9 +57,9 @@ sylius_grid: label: sylius.ui.type form_options: choices: - sylius.ui.image: !php/const BitBag\SyliusCmsPlugin\Entity\MediaInterface::IMAGE_TYPE - bitbag_sylius_cms_plugin.ui.file: !php/const BitBag\SyliusCmsPlugin\Entity\MediaInterface::FILE_TYPE - bitbag_sylius_cms_plugin.ui.video: !php/const BitBag\SyliusCmsPlugin\Entity\MediaInterface::VIDEO_TYPE + sylius.ui.image: !php/const Sylius\CmsPlugin\Entity\MediaInterface::IMAGE_TYPE + sylius_cms.ui.file: !php/const Sylius\CmsPlugin\Entity\MediaInterface::FILE_TYPE + sylius_cms.ui.video: !php/const Sylius\CmsPlugin\Entity\MediaInterface::VIDEO_TYPE actions: main: import: diff --git a/src/Resources/config/grids/admin/page.yml b/src/Resources/config/grids/admin/page.yml index 16c700ab5..fd37aa1ef 100755 --- a/src/Resources/config/grids/admin/page.yml +++ b/src/Resources/config/grids/admin/page.yml @@ -1,56 +1,57 @@ sylius_grid: grids: - bitbag_sylius_cms_plugin_admin_page: + sylius_cms_admin_page: driver: name: doctrine/orm options: - class: "%bitbag_sylius_cms_plugin.model.page.class%" - repository: - method: createListQueryBuilder - arguments: ["%locale%"] + class: "%sylius_cms.model.page.class%" sorting: code: asc limits: [10, 25, 50] fields: - page_image: + name: type: twig - label: bitbag_sylius_cms_plugin.ui.image + label: sylius_cms.ui.name + sortable: name path: . options: - template: "@BitBagSyliusCmsPlugin/Grid/Field/page_image.html.twig" + template: "@SyliusCmsPlugin/Grid/Field/name.html.twig" code: type: string - label: bitbag_sylius_cms_plugin.ui.code + label: sylius_cms.ui.code sortable: ~ - name: - type: string - label: bitbag_sylius_cms_plugin.ui.name - sortable: translation.name - slug: - type: string - label: bitbag_sylius_cms_plugin.ui.slug - sortable: translation.slug - sections: + enabled: + type: twig + label: sylius.ui.enabled + options: + template: "@SyliusUi/Grid/Field/enabled.html.twig" + collections: + type: twig + label: sylius_cms.ui.collections + path: . + options: + template: "@SyliusCmsPlugin/Grid/Field/collections.html.twig" + channels: type: twig - label: bitbag_sylius_cms_plugin.ui.sections + label: sylius_cms.ui.channels path: . options: - template: "@BitBagSyliusCmsPlugin/Grid/Field/sections.html.twig" + template: "@SyliusCmsPlugin/Grid/Field/channels.html.twig" filters: search: type: string label: sylius.ui.search options: fields: [code] - sections: + collections: type: entity - label: bitbag_sylius_cms_plugin.ui.sections + label: sylius_cms.ui.collections form_options: - class: "%bitbag_sylius_cms_plugin.model.section.class%" + class: "%sylius_cms.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/admin/template.yml b/src/Resources/config/grids/admin/template.yml new file mode 100755 index 000000000..1f82cae0f --- /dev/null +++ b/src/Resources/config/grids/admin/template.yml @@ -0,0 +1,42 @@ +sylius_grid: + grids: + sylius_cms_admin_template: + driver: + name: doctrine/orm + options: + class: "%sylius_cms.model.template.class%" + sorting: + name: asc + limits: [10, 25, 50] + fields: + name: + type: twig + label: sylius_cms.ui.name + sortable: name + path: . + options: + template: "@SyliusCmsPlugin/Grid/Field/name.html.twig" + type: + type: string + label: sylius.ui.type + sortable: ~ + filters: + search: + type: string + label: sylius.ui.search + options: + fields: [name] + enabled: + type: boolean + actions: + main: + create: + type: create + item: + update: + type: update + delete: + type: delete + bulk: + delete: + type: delete diff --git a/src/Resources/config/grids/shop.yml b/src/Resources/config/grids/shop.yml index 0c4485e93..e01ab3a15 100755 --- a/src/Resources/config/grids/shop.yml +++ b/src/Resources/config/grids/shop.yml @@ -1,2 +1,2 @@ imports: - - { resource: "@BitBagSyliusCmsPlugin/Resources/config/grids/shop/page.yml" } + - { resource: "@SyliusCmsPlugin/Resources/config/grids/shop/page.yml" } diff --git a/src/Resources/config/grids/shop/page.yml b/src/Resources/config/grids/shop/page.yml index 55c64fd27..5bfd0d705 100755 --- a/src/Resources/config/grids/shop/page.yml +++ b/src/Resources/config/grids/shop/page.yml @@ -1,14 +1,14 @@ sylius_grid: grids: - bitbag_sylius_cms_plugin_shop_page: + sylius_cms_shop_page: driver: name: doctrine/orm options: - class: "%bitbag_sylius_cms_plugin.model.page.class%" + class: "%sylius_cms.model.page.class%" 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 deleted file mode 100755 index 6812caa9d..000000000 --- a/src/Resources/config/resources.yml +++ /dev/null @@ -1,6 +0,0 @@ -imports: - - { resource: resources/block.yml } - - { resource: resources/page.yml } - - { resource: resources/frequently_asked_question.yml } - - { resource: resources/section.yml } - - { resource: resources/media.yml } diff --git a/src/Resources/config/resources/block.yml b/src/Resources/config/resources/block.yml deleted file mode 100755 index 119d65ea8..000000000 --- a/src/Resources/config/resources/block.yml +++ /dev/null @@ -1,15 +0,0 @@ -sylius_resource: - resources: - bitbag_sylius_cms_plugin.block: - driver: doctrine/orm - classes: - model: BitBag\SyliusCmsPlugin\Entity\Block - interface: BitBag\SyliusCmsPlugin\Entity\BlockInterface - form: BitBag\SyliusCmsPlugin\Form\Type\BlockType - repository: BitBag\SyliusCmsPlugin\Repository\BlockRepository - controller: BitBag\SyliusCmsPlugin\Controller\BlockController - factory: Sylius\Component\Resource\Factory\TranslatableFactory - translation: - classes: - model: BitBag\SyliusCmsPlugin\Entity\BlockTranslation - interface: BitBag\SyliusCmsPlugin\Entity\BlockTranslationInterface diff --git a/src/Resources/config/resources/frequently_asked_question.yml b/src/Resources/config/resources/frequently_asked_question.yml deleted file mode 100755 index 55f5b8dcc..000000000 --- a/src/Resources/config/resources/frequently_asked_question.yml +++ /dev/null @@ -1,14 +0,0 @@ -sylius_resource: - resources: - bitbag_sylius_cms_plugin.frequently_asked_question: - driver: doctrine/orm - classes: - model: BitBag\SyliusCmsPlugin\Entity\FrequentlyAskedQuestion - interface: BitBag\SyliusCmsPlugin\Entity\FrequentlyAskedQuestionInterface - form: BitBag\SyliusCmsPlugin\Form\Type\FrequentlyAskedQuestionType - repository: BitBag\SyliusCmsPlugin\Repository\FrequentlyAskedQuestionRepository - factory: Sylius\Component\Resource\Factory\TranslatableFactory - translation: - classes: - model: BitBag\SyliusCmsPlugin\Entity\FrequentlyAskedQuestionTranslation - interface: BitBag\SyliusCmsPlugin\Entity\FrequentlyAskedQuestionTranslationInterface diff --git a/src/Resources/config/resources/media.yml b/src/Resources/config/resources/media.yml deleted file mode 100644 index 2b183a478..000000000 --- a/src/Resources/config/resources/media.yml +++ /dev/null @@ -1,15 +0,0 @@ -sylius_resource: - resources: - bitbag_sylius_cms_plugin.media: - driver: doctrine/orm - classes: - model: BitBag\SyliusCmsPlugin\Entity\Media - interface: BitBag\SyliusCmsPlugin\Entity\MediaInterface - form: BitBag\SyliusCmsPlugin\Form\Type\MediaType - repository: BitBag\SyliusCmsPlugin\Repository\MediaRepository - controller: BitBag\SyliusCmsPlugin\Controller\MediaController - factory: Sylius\Component\Resource\Factory\TranslatableFactory - translation: - classes: - model: BitBag\SyliusCmsPlugin\Entity\MediaTranslation - interface: BitBag\SyliusCmsPlugin\Entity\MediaTranslationInterface diff --git a/src/Resources/config/resources/page.yml b/src/Resources/config/resources/page.yml deleted file mode 100755 index 3f4dbc20f..000000000 --- a/src/Resources/config/resources/page.yml +++ /dev/null @@ -1,15 +0,0 @@ -sylius_resource: - resources: - bitbag_sylius_cms_plugin.page: - driver: doctrine/orm - classes: - model: BitBag\SyliusCmsPlugin\Entity\Page - interface: BitBag\SyliusCmsPlugin\Entity\PageInterface - form: BitBag\SyliusCmsPlugin\Form\Type\PageType - repository: BitBag\SyliusCmsPlugin\Repository\PageRepository - controller: BitBag\SyliusCmsPlugin\Controller\PageController - factory: Sylius\Component\Resource\Factory\TranslatableFactory - translation: - classes: - model: BitBag\SyliusCmsPlugin\Entity\PageTranslation - interface: BitBag\SyliusCmsPlugin\Entity\PageTranslationInterface 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.yml b/src/Resources/config/routing.yml index d27bd1a9b..9c784f82e 100755 --- a/src/Resources/config/routing.yml +++ b/src/Resources/config/routing.yml @@ -1,7 +1,7 @@ -bitbag_sylius_cms_plugin_admin: - resource: "@BitBagSyliusCmsPlugin/Resources/config/routing/admin.yml" +sylius_cms_admin: + resource: "@SyliusCmsPlugin/Resources/config/routing/admin.yml" prefix: '/%sylius_admin.path_name%' -bitbag_sylius_cms_plugin_shop: - resource: "@BitBagSyliusCmsPlugin/Resources/config/routing/shop.yml" +sylius_cms_shop: + resource: "@SyliusCmsPlugin/Resources/config/routing/shop.yml" prefix: /{_locale} diff --git a/src/Resources/config/routing/admin.yml b/src/Resources/config/routing/admin.yml index 1bb6633ba..693e1199e 100755 --- a/src/Resources/config/routing/admin.yml +++ b/src/Resources/config/routing/admin.yml @@ -1,46 +1,46 @@ -bitbag_sylius_cms_plugin_admin_block: - resource: "@BitBagSyliusCmsPlugin/Resources/config/routing/admin/block.yml" +sylius_cms_admin_block: + resource: "@SyliusCmsPlugin/Resources/config/routing/admin/block.yml" -bitbag_sylius_cms_plugin_admin_page: - resource: "@BitBagSyliusCmsPlugin/Resources/config/routing/admin/page.yml" +sylius_cms_admin_page: + resource: "@SyliusCmsPlugin/Resources/config/routing/admin/page.yml" -bitbag_sylius_cms_plugin_admin_frequently_asked_question: - resource: "@BitBagSyliusCmsPlugin/Resources/config/routing/admin/frequently_asked_question.yml" +sylius_cms_admin_collection: + resource: "@SyliusCmsPlugin/Resources/config/routing/admin/collection.yml" -bitbag_sylius_cms_plugin_admin_section: - resource: "@BitBagSyliusCmsPlugin/Resources/config/routing/admin/section.yml" +sylius_cms_admin_media: + resource: "@SyliusCmsPlugin/Resources/config/routing/admin/media.yml" -bitbag_sylius_cms_plugin_admin_media: - resource: "@BitBagSyliusCmsPlugin/Resources/config/routing/admin/media.yml" +sylius_cms_admin_product: + resource: "@SyliusCmsPlugin/Resources/config/routing/admin/product.yml" -bitbag_sylius_cms_plugin_admin_product: - resource: "@BitBagSyliusCmsPlugin/Resources/config/routing/admin/product.yml" +sylius_cms_admin_taxon: + resource: "@SyliusCmsPlugin/Resources/config/routing/admin/taxon.yml" -bitbag_sylius_cms_plugin_admin_taxon: - resource: "@BitBagSyliusCmsPlugin/Resources/config/routing/admin/taxon.yml" +sylius_cms_admin_locale: + resource: "@SyliusCmsPlugin/Resources/config/routing/admin/locale.yml" -bitbag_sylius_cms_plugin_admin_locale: - resource: "@BitBagSyliusCmsPlugin/Resources/config/routing/admin/locale.yml" +sylius_cms_admin_template: + resource: "@SyliusCmsPlugin/Resources/config/routing/admin/template.yml" -bitbag_sylius_cms_plugin_admin_ajax_generate_page_slug: +sylius_cms_admin_ajax_generate_page_slug: path: /page/generate-slug methods: [GET] defaults: - _controller: bitbag_sylius_cms_plugin.controller.page_slug::generateAction + _controller: sylius_cms.controller.page_slug::generateAction -bitbag_sylius_cms_plugin_admin_import_data: +sylius_cms_admin_import_data: path: /import/{resourceName} methods: [GET, POST] defaults: - _controller: bitbag_sylius_cms_plugin.controller.action.admin.import_data + _controller: sylius_cms.controller.action.admin.import_data -bitbag_sylius_cms_plugin_admin_upload_editor_image: +sylius_cms_admin_upload_editor_image: path: /editor/upload-image defaults: - _controller: bitbag_sylius_cms_plugin.controller.action.admin.upload_editor_image + _controller: sylius_cms.controller.action.admin.upload_editor_image -bitbag_sylius_cms_plugin_admin_retrieve_package_info: +sylius_cms_admin_retrieve_package_info: path: /cms/retrieve-package-info methods: [GET] defaults: - _controller: bitbag_sylius_cms_plugin.controller.action.admin.retrieve_package_info + _controller: sylius_cms.controller.action.admin.retrieve_package_info diff --git a/src/Resources/config/routing/admin/block.yml b/src/Resources/config/routing/admin/block.yml index a9ea22c3e..d5b27c175 100755 --- a/src/Resources/config/routing/admin/block.yml +++ b/src/Resources/config/routing/admin/block.yml @@ -1,18 +1,18 @@ -bitbag_sylius_cms_plugin_admin_block: +sylius_cms_admin_block: resource: | - alias: bitbag_sylius_cms_plugin.block + alias: sylius_cms.block section: admin - templates: '@BitBagSyliusCmsPlugin/CrudUi' + templates: '@SyliusCmsPlugin/CrudUi' except: ['show'] redirect: update - grid: bitbag_sylius_cms_plugin_admin_block + grid: sylius_cms_admin_block permission: true vars: all: - header: bitbag_sylius_cms_plugin.ui.blocks_header - subheader: bitbag_sylius_cms_plugin.ui.blocks_subheader + header: sylius_cms.ui.blocks_header + subheader: sylius_cms.ui.blocks_subheader templates: - form: "@BitBagSyliusCmsPlugin/Block/Crud/_form.html.twig" + form: "@SyliusCmsPlugin/Block/Crud/_form.html.twig" index: icon: block layout route: @@ -20,10 +20,37 @@ bitbag_sylius_cms_plugin_admin_block: code: $type type: sylius.resource -bitbag_sylius_cms_plugin_admin_block_preview: +sylius_cms_admin_block_preview: path: /block/preview methods: [GET, POST, PUT] defaults: - _controller: bitbag_sylius_cms_plugin.controller.block::previewAction + _controller: sylius_cms.controller.block::previewAction _sylius: - template: "@BitBagSyliusCmsPlugin/Block/preview.html.twig" + template: "@SyliusCmsPlugin/Block/preview.html.twig" + +sylius_cms_admin_ajax_block_by_name_phrase: + path: /ajax/blocks/search + methods: [GET] + defaults: + _format: json + _controller: sylius_cms.controller.block::indexAction + _sylius: + serialization_groups: [Autocomplete] + permission: true + repository: + method: findByNamePart + arguments: + phrase: $phrase + +sylius_cms_admin_ajax_block_by_code: + path: /ajax/blocks/code + methods: [GET] + defaults: + _format: json + _controller: sylius_cms.controller.block::indexAction + _sylius: + serialization_groups: [Autocomplete] + permission: true + repository: + method: findBy + arguments: [code: $code] diff --git a/src/Resources/config/routing/admin/collection.yml b/src/Resources/config/routing/admin/collection.yml new file mode 100755 index 000000000..cca2c9984 --- /dev/null +++ b/src/Resources/config/routing/admin/collection.yml @@ -0,0 +1,60 @@ +sylius_cms_admin_collection: + resource: | + alias: sylius_cms.collection + section: admin + templates: '@SyliusCmsPlugin/CrudUi' + redirect: update + grid: sylius_cms_admin_collection + except: ['show'] + permission: true + vars: + all: + header: sylius_cms.ui.collections_header + subheader: sylius_cms.ui.collections_subheader + templates: + form: "@SyliusCmsPlugin/Collection/Crud/_form.html.twig" + index: + icon: grid layout + type: sylius.resource + +sylius_cms_admin_ajax_collection_by_name_phrase: + path: /ajax/collections/search + methods: [GET] + defaults: + _format: json + _controller: sylius_cms.controller.collection::indexAction + _sylius: + serialization_groups: [Autocomplete] + permission: true + repository: + method: findByNamePart + arguments: + phrase: $phrase + +sylius_cms_admin_ajax_page_collection_by_name_phrase: + path: /ajax/collections/page/search + methods: [GET] + defaults: + _format: json + _controller: sylius_cms.controller.collection::indexAction + _sylius: + serialization_groups: [Autocomplete] + permission: true + repository: + method: findByNamePartAndType + arguments: + phrase: $phrase + type: page + +sylius_cms_admin_ajax_collection_by_code: + path: /ajax/collections/code + methods: [GET] + defaults: + _format: json + _controller: sylius_cms.controller.collection::indexAction + _sylius: + serialization_groups: [Autocomplete] + permission: true + repository: + method: findBy + arguments: [code: $code] diff --git a/src/Resources/config/routing/admin/frequently_asked_question.yml b/src/Resources/config/routing/admin/frequently_asked_question.yml deleted file mode 100755 index 4d8112282..000000000 --- a/src/Resources/config/routing/admin/frequently_asked_question.yml +++ /dev/null @@ -1,18 +0,0 @@ -bitbag_sylius_cms_plugin_admin_frequently_asked_question: - resource: | - alias: bitbag_sylius_cms_plugin.frequently_asked_question - section: admin - templates: '@BitBagSyliusCmsPlugin/CrudUi' - redirect: update - grid: bitbag_sylius_cms_plugin_admin_frequently_asked_question - except: ['show'] - permission: true - vars: - all: - header: bitbag_sylius_cms_plugin.ui.faq_header - subheader: bitbag_sylius_cms_plugin.ui.faq_subheader - templates: - form: "@BitBagSyliusCmsPlugin/FrequentlyAskedQuestion/Crud/_form.html.twig" - index: - icon: help - type: sylius.resource diff --git a/src/Resources/config/routing/admin/locale.yml b/src/Resources/config/routing/admin/locale.yml index 9b398a5de..3a4e3fa6c 100644 --- a/src/Resources/config/routing/admin/locale.yml +++ b/src/Resources/config/routing/admin/locale.yml @@ -1,4 +1,4 @@ -bitbag_sylius_cms_plugin_admin_partial_locale_index: +sylius_cms_admin_partial_locale_index: path: /_partial/locales methods: [GET] defaults: diff --git a/src/Resources/config/routing/admin/media.yml b/src/Resources/config/routing/admin/media.yml index 33360ee08..2a799aec3 100644 --- a/src/Resources/config/routing/admin/media.yml +++ b/src/Resources/config/routing/admin/media.yml @@ -1,48 +1,43 @@ -bitbag_sylius_cms_plugin_admin_media: +sylius_cms_admin_media: resource: | - alias: bitbag_sylius_cms_plugin.media + alias: sylius_cms.media section: admin - templates: '@BitBagSyliusCmsPlugin/CrudUi' + templates: '@SyliusCmsPlugin/CrudUi' redirect: update - grid: bitbag_sylius_cms_plugin_admin_media + grid: sylius_cms_admin_media except: ['show'] permission: true vars: all: - header: bitbag_sylius_cms_plugin.ui.media_header - subheader: bitbag_sylius_cms_plugin.ui.media_subheader + header: sylius_cms.ui.media_header + subheader: sylius_cms.ui.media_subheader templates: - form: "@BitBagSyliusCmsPlugin/Media/Crud/_form.html.twig" + form: "@SyliusCmsPlugin/Media/Crud/_form.html.twig" index: icon: file type: sylius.resource -bitbag_sylius_cms_plugin_admin_media_preview: - path: /media/preview/{id} - methods: [GET, POST, PUT] - defaults: - _controller: bitbag_sylius_cms_plugin.controller.media.overriden::previewAction - _sylius: - template: "@BitBagSyliusCmsPlugin/Media/preview.html.twig" - id: null - -bitbag_sylius_cms_plugin_admin_ajax_media_by_name_phrase: +sylius_cms_admin_ajax_media_by_name_phrase: path: /ajax/media/search methods: [GET] defaults: _format: json - _controller: bitbag_sylius_cms_plugin.controller.media.overriden::indexAction + _controller: sylius_cms.controller.media.overriden::indexAction _sylius: - serialization_groups: [Default, Autocomplete] + serialization_groups: [Autocomplete] permission: true - grid: bitbag_sylius_cms_plugin_admin_media + repository: + method: findByNamePart + arguments: + phrase: $phrase + mediaType: $mediaType -bitbag_sylius_cms_plugin_admin_ajax_media_by_code: +sylius_cms_admin_ajax_media_by_code: path: /ajax/media/code methods: [GET] defaults: _format: json - _controller: bitbag_sylius_cms_plugin.controller.media.overriden::indexAction + _controller: sylius_cms.controller.media.overriden::indexAction _sylius: serialization_groups: [Autocomplete] permission: true diff --git a/src/Resources/config/routing/admin/page.yml b/src/Resources/config/routing/admin/page.yml index d1ed40f68..8f9200f98 100755 --- a/src/Resources/config/routing/admin/page.yml +++ b/src/Resources/config/routing/admin/page.yml @@ -1,27 +1,54 @@ -bitbag_sylius_cms_plugin_admin_page: +sylius_cms_admin_page: resource: | - alias: bitbag_sylius_cms_plugin.page + alias: sylius_cms.page section: admin - templates: '@BitBagSyliusCmsPlugin/CrudUi' + templates: '@SyliusCmsPlugin/CrudUi' redirect: update - grid: bitbag_sylius_cms_plugin_admin_page + grid: sylius_cms_admin_page except: ['show'] permission: true vars: all: - header: bitbag_sylius_cms_plugin.ui.pages_header - subheader: bitbag_sylius_cms_plugin.ui.pages_subheader + header: sylius_cms.ui.pages_header + subheader: sylius_cms.ui.pages_subheader templates: - form: "@BitBagSyliusCmsPlugin/Page/Crud/_form.html.twig" + form: "@SyliusCmsPlugin/Page/Crud/_form.html.twig" index: icon: sticky note type: sylius.resource -bitbag_sylius_cms_plugin_admin_page_preview: +sylius_cms_admin_page_preview: path: /page/preview/{id} methods: [GET, POST, PUT] defaults: - _controller: bitbag_sylius_cms_plugin.controller.page.overriden::previewAction + _controller: sylius_cms.controller.page.overriden::previewAction _sylius: - template: "@BitBagSyliusCmsPlugin/Page/preview.html.twig" + template: "@SyliusCmsPlugin/Page/preview.html.twig" id: null + +sylius_cms_admin_ajax_page_by_name_phrase: + path: /ajax/pages/search + methods: [GET] + defaults: + _format: json + _controller: sylius_cms.controller.page::indexAction + _sylius: + serialization_groups: [Autocomplete] + permission: true + repository: + method: findByNamePart + arguments: + phrase: $phrase + +sylius_cms_admin_ajax_page_by_code: + path: /ajax/pages/code + methods: [GET] + defaults: + _format: json + _controller: sylius_cms.controller.page::indexAction + _sylius: + serialization_groups: [Autocomplete] + permission: true + repository: + method: findBy + arguments: [code: $code] diff --git a/src/Resources/config/routing/admin/product.yml b/src/Resources/config/routing/admin/product.yml index ef296f342..0e0168796 100644 --- a/src/Resources/config/routing/admin/product.yml +++ b/src/Resources/config/routing/admin/product.yml @@ -1,6 +1,6 @@ -bitbag_sylius_cms_plugin_admin_ajax_product_by_name_phrase: +sylius_cms_admin_ajax_product_by_name_phrase: path: /ajax/products/search-by-name methods: [GET] defaults: _format: json - _controller: bitbag_sylius_cms_plugin.controller.action.admin.product_search + _controller: sylius_cms.controller.action.admin.product_search diff --git a/src/Resources/config/routing/admin/section.yml b/src/Resources/config/routing/admin/section.yml deleted file mode 100755 index 18af15ec5..000000000 --- a/src/Resources/config/routing/admin/section.yml +++ /dev/null @@ -1,46 +0,0 @@ -bitbag_sylius_cms_plugin_admin_section: - resource: | - alias: bitbag_sylius_cms_plugin.section - section: admin - templates: '@BitBagSyliusCmsPlugin/CrudUi' - redirect: update - grid: bitbag_sylius_cms_plugin_admin_section - except: ['show'] - permission: true - vars: - all: - header: bitbag_sylius_cms_plugin.ui.sections_header - subheader: bitbag_sylius_cms_plugin.ui.sections_subheader - templates: - form: "@BitBagSyliusCmsPlugin/Section/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 - methods: [GET] - defaults: - _format: json - _controller: bitbag_sylius_cms_plugin.controller.section::indexAction - _sylius: - serialization_groups: [Autocomplete] - permission: true - repository: - method: findByNamePart - arguments: - phrase: $phrase - locale: null - -bitbag_sylius_cms_plugin_admin_ajax_section_by_code: - path: /ajax/sections/code - methods: [GET] - defaults: - _format: json - _controller: bitbag_sylius_cms_plugin.controller.section::indexAction - _sylius: - serialization_groups: [Autocomplete] - permission: true - repository: - method: findBy - arguments: [code: $code] diff --git a/src/Resources/config/routing/admin/taxon.yml b/src/Resources/config/routing/admin/taxon.yml index 9a26281ee..fa191797b 100644 --- a/src/Resources/config/routing/admin/taxon.yml +++ b/src/Resources/config/routing/admin/taxon.yml @@ -1,6 +1,6 @@ -bitbag_sylius_cms_plugin_admin_ajax_taxon_by_name_phrase: +sylius_cms_admin_ajax_taxon_by_name_phrase: path: /ajax/taxon/search-by-name methods: [GET] defaults: _format: json - _controller: bitbag_sylius_cms_plugin.controller.action.admin.taxon_search + _controller: sylius_cms.controller.action.admin.taxon_search diff --git a/src/Resources/config/routing/admin/template.yml b/src/Resources/config/routing/admin/template.yml new file mode 100755 index 000000000..9ce48ee6b --- /dev/null +++ b/src/Resources/config/routing/admin/template.yml @@ -0,0 +1,68 @@ +sylius_cms_admin_template: + resource: | + alias: sylius_cms.template + section: admin + templates: '@SyliusCmsPlugin/CrudUi' + except: ['show'] + redirect: update + grid: sylius_cms_admin_template + permission: true + vars: + all: + templates: + form: "@SyliusCmsPlugin/ContentTemplate/Crud/_form.html.twig" + index: + icon: block layout + type: sylius.resource + +sylius_cms_admin_ajax_template_page_by_name_phrase: + path: /ajax/templates/page/search + methods: [GET] + defaults: + _format: json + _controller: sylius_cms.controller.template::indexAction + _sylius: + serialization_groups: [Autocomplete] + permission: true + repository: + method: findTemplatesByNamePart + arguments: + phrase: $phrase + type: page + +sylius_cms_admin_ajax_template_block_by_name_phrase: + path: /ajax/templates/block/search + methods: [GET] + defaults: + _format: json + _controller: sylius_cms.controller.template::indexAction + _sylius: + serialization_groups: [Autocomplete] + permission: true + repository: + method: findTemplatesByNamePart + arguments: + phrase: $phrase + type: block + +sylius_cms_admin_ajax_template_by_id: + path: /ajax/templates/id + methods: [GET] + defaults: + _format: json + _controller: sylius_cms.controller.template::indexAction + _sylius: + serialization_groups: [Autocomplete] + permission: true + repository: + method: find + arguments: [id: $id] + +sylius_cms_admin_ajax_template_content_by_id: + path: /ajax/templates/content/{id} + methods: [GET] + defaults: + _format: json + _controller: sylius_cms.controller.action.admin.template_content_elements::getContentElementsAction + _sylius: + permission: true diff --git a/src/Resources/config/routing/shop.yml b/src/Resources/config/routing/shop.yml index 596f3276e..bd3c5283f 100755 --- a/src/Resources/config/routing/shop.yml +++ b/src/Resources/config/routing/shop.yml @@ -1,14 +1,11 @@ -bitbag_sylius_cms_plugin_shop_block: - resource: "@BitBagSyliusCmsPlugin/Resources/config/routing/shop/block.yml" +sylius_cms_shop_block: + resource: "@SyliusCmsPlugin/Resources/config/routing/shop/block.yml" -bitbag_sylius_cms_plugin_shop_page: - resource: "@BitBagSyliusCmsPlugin/Resources/config/routing/shop/page.yml" +sylius_cms_shop_page: + resource: "@SyliusCmsPlugin/Resources/config/routing/shop/page.yml" -bitbag_sylius_cms_plugin_shop_frequently_asked_question: - resource: "@BitBagSyliusCmsPlugin/Resources/config/routing/shop/frequently_asked_question.yml" +sylius_cms_shop_collection: + resource: "@SyliusCmsPlugin/Resources/config/routing/shop/collection.yml" -bitbag_sylius_cms_plugin_shop_section: - resource: "@BitBagSyliusCmsPlugin/Resources/config/routing/shop/section.yml" - -bitbag_sylius_cms_plugin_shop_media: - resource: "@BitBagSyliusCmsPlugin/Resources/config/routing/shop/media.yml" +sylius_cms_shop_media: + resource: "@SyliusCmsPlugin/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..e639af5fe 100755 --- a/src/Resources/config/routing/shop/block.yml +++ b/src/Resources/config/routing/shop/block.yml @@ -1,38 +1,23 @@ -bitbag_sylius_cms_plugin_shop_block_render: +sylius_cms_shop_block_render: path: /block/{code} methods: [GET] defaults: - _controller: bitbag_sylius_cms_plugin.controller.block::renderBlockAction + _controller: sylius_cms.controller.block::renderBlockAction _sylius: repository: method: findOneByCode arguments: - $code -bitbag_sylius_cms_plugin_shop_block_index_by_section_code: - path: /blocks/section/{sectionCode} +sylius_cms_shop_block_index_by_collection_code: + path: /blocks/collection/{collectionCode} methods: [GET] defaults: - _controller: bitbag_sylius_cms_plugin.controller.block::indexAction + _controller: sylius_cms.controller.block::indexAction _sylius: template: $template repository: - method: findBySectionCode + method: findByCollectionCode arguments: - - $sectionCode - - "expr:service('sylius.context.locale').getLocaleCode()" - - "expr:service('sylius.context.channel').getChannel().getCode()" - -bitbag_sylius_cms_plugin_shop_block_index_by_product_code: - path: /blocks/product/{productCode} - methods: [GET] - defaults: - _controller: bitbag_sylius_cms_plugin.controller.block::indexAction - _sylius: - template: $template - repository: - method: findByProductCode - arguments: - - $productCode - - "expr:service('sylius.context.locale').getLocaleCode()" + - $collectionCode - "expr:service('sylius.context.channel').getChannel().getCode()" diff --git a/src/Resources/config/routing/shop/collection.yml b/src/Resources/config/routing/shop/collection.yml new file mode 100755 index 000000000..0c045b479 --- /dev/null +++ b/src/Resources/config/routing/shop/collection.yml @@ -0,0 +1,23 @@ +sylius_cms_shop_collection_show: + path: /collection/{code} + methods: [GET] + defaults: + _controller: sylius_cms.controller.collection::showAction + _sylius: + template: $template + repository: + method: findOneByCode + arguments: + - $code + +sylius_cms_shop_collection_show_codes: + path: /collections/{codes} + methods: [GET] + defaults: + _controller: sylius_cms.controller.collection::indexAction + _sylius: + template: $template + repository: + method: findByCodes + arguments: + - $codes diff --git a/src/Resources/config/routing/shop/frequently_asked_question.yml b/src/Resources/config/routing/shop/frequently_asked_question.yml deleted file mode 100755 index a9927601a..000000000 --- a/src/Resources/config/routing/shop/frequently_asked_question.yml +++ /dev/null @@ -1,11 +0,0 @@ -bitbag_sylius_cms_plugin_shop_frequently_asked_question_index: - path: /faq - defaults: - _controller: bitbag_sylius_cms_plugin.controller.frequently_asked_question::indexAction - _sylius: - template: "@BitBagSyliusCmsPlugin/Shop/FrequentlyAskedQuestion/index.html.twig" - repository: - method: findEnabledOrderedByPosition - arguments: - - "expr:service('sylius.context.locale').getLocaleCode()" - - "expr:service('sylius.context.channel').getChannel().getCode()" diff --git a/src/Resources/config/routing/shop/media.yml b/src/Resources/config/routing/shop/media.yml index b40e4d5c6..6f1791f32 100755 --- a/src/Resources/config/routing/shop/media.yml +++ b/src/Resources/config/routing/shop/media.yml @@ -1,61 +1,19 @@ -bitbag_sylius_cms_plugin_shop_media_render: +sylius_cms_shop_media_render: path: /media/{code} methods: [GET] defaults: - _controller: bitbag_sylius_cms_plugin.controller.media.overriden::renderMediaAction + _controller: sylius_cms_plugin.controller.media.overriden::renderMediaAction -bitbag_sylius_cms_plugin_shop_media_render_template: - path: /media-template/{code} - methods: [GET] - defaults: - _controller: bitbag_sylius_cms_plugin.controller.media.overriden::showAction - _sylius: - template: $template - repository: - method: findOneEnabledByCode - arguments: - - $code - - "expr:service('sylius.context.locale').getLocaleCode()" - - "expr:service('sylius.context.channel').getChannel().getCode()" - -bitbag_sylius_cms_plugin_shop_media_download: +sylius_cms_shop_media_download: path: /media/download/{code} methods: [GET] defaults: - _controller: bitbag_sylius_cms_plugin.controller.media.overriden::downloadMediaAction + _controller: sylius_cms_plugin.controller.media.overriden::downloadMediaAction disposition: !php/const Symfony\Component\HttpFoundation\ResponseHeaderBag::DISPOSITION_ATTACHMENT -bitbag_sylius_cms_plugin_shop_media_inline: +sylius_cms_shop_media_inline: path: /media/inline/{code} methods: [GET] defaults: - _controller: bitbag_sylius_cms_plugin.controller.media.overriden::downloadMediaAction + _controller: 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} - methods: [GET] - defaults: - _controller: bitbag_sylius_cms_plugin.controller.media.overriden::indexAction - _sylius: - template: $template - repository: - method: findBySectionCode - arguments: - - $sectionCode - - "expr:service('sylius.context.locale').getLocaleCode()" - - "expr:service('sylius.context.channel').getChannel().getCode()" - -bitbag_sylius_cms_plugin_shop_media_index_by_product_code: - path: /media/product/{productCode} - methods: [GET] - defaults: - _controller: bitbag_sylius_cms_plugin.controller.media.overriden::indexAction - _sylius: - template: $template - repository: - method: findByProductCode - arguments: - - $productCode - - "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..d015cf27c 100755 --- a/src/Resources/config/routing/shop/page.yml +++ b/src/Resources/config/routing/shop/page.yml @@ -1,67 +1,55 @@ -bitbag_sylius_cms_plugin_shop_page_show: +sylius_cms_shop_page_show: path: /page/{slug} methods: [GET] defaults: - _controller: bitbag_sylius_cms_plugin.controller.page.overriden::showAction - _sylius: - template: "@BitBagSyliusCmsPlugin/Shop/Page/show.html.twig" - repository: - method: findOneEnabledBySlugAndChannelCode - arguments: - - $slug - - "expr:service('sylius.context.locale').getLocaleCode()" - - "expr:service('sylius.context.channel').getChannel().getCode()" + _controller: sylius_cms.controller.page.overriden::showAction -bitbag_sylius_cms_plugin_shop_page_show_link_by_code: +sylius_cms_shop_page_show_link_by_code: path: /page/link/{code} methods: [GET] defaults: - _controller: bitbag_sylius_cms_plugin.controller.page.overriden::renderLinkAction + _controller: sylius_cms.controller.page.overriden::renderLinkAction _sylius: template: $template repository: method: findOneEnabledByCode arguments: - $code - - "expr:service('sylius.context.locale').getLocaleCode()" -bitbag_sylius_cms_plugin_shop_page_index_by_section_code: - path: /pages/{sectionCode} +sylius_cms_shop_page_index_by_collection_code: + path: /page/{collectionCode} methods: [GET] defaults: - _controller: bitbag_sylius_cms_plugin.controller.page.overriden::indexAction + _controller: sylius_cms.controller.page.overriden::indexAction _sylius: - template: "@BitBagSyliusCmsPlugin/Shop/Page/index.html.twig" - grid: bitbag_sylius_cms_plugin_shop_page + template: "@SyliusCmsPlugin/Shop/Page/index.html.twig" + grid: sylius_cms_shop_page repository: - method: findBySectionCode + method: findByCollectionCode arguments: - - $sectionCode - - "expr:service('sylius.context.locale').getLocaleCode()" + - $collectionCode -bitbag_sylius_cms_plugin_shop_page_index_by_section_code_no_grid: - path: /pages/{sectionCode}/no-grid +sylius_cms_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 + _controller: sylius_cms.controller.page.overriden::indexAction _sylius: - template: "@BitBagSyliusCmsPlugin/Shop/Page/index.html.twig" + template: "@SyliusCmsPlugin/Shop/Page/index.html.twig" repository: - method: findBySectionCode + method: findByCollectionCode arguments: - - $sectionCode - - "expr:service('sylius.context.locale').getLocaleCode()" + - $collectionCode -bitbag_sylius_cms_plugin_shop_page_index_by_section_code_template: - path: /pages-template/{sectionCode} +sylius_cms_shop_page_index_by_collection_code_template: + path: /pages-template/{collectionCode} methods: [GET] defaults: - _controller: bitbag_sylius_cms_plugin.controller.page.overriden::indexAction + _controller: sylius_cms.controller.page.overriden::indexAction _sylius: template: $template - grid: bitbag_sylius_cms_plugin_shop_page + grid: sylius_cms_shop_page repository: - method: findBySectionCode + method: findByCollectionCode arguments: - - $sectionCode - - "expr:service('sylius.context.locale').getLocaleCode()" + - $collectionCode diff --git a/src/Resources/config/routing/shop/section.yml b/src/Resources/config/routing/shop/section.yml deleted file mode 100755 index 9c40f6185..000000000 --- a/src/Resources/config/routing/shop/section.yml +++ /dev/null @@ -1,26 +0,0 @@ -bitbag_sylius_cms_plugin_shop_section_show: - path: /section/{code} - methods: [GET] - defaults: - _controller: bitbag_sylius_cms_plugin.controller.section::showAction - _sylius: - template: $template - repository: - method: findOneByCode - arguments: - - $code - - "expr:service('sylius.context.locale').getLocaleCode()" - -bitbag_sylius_cms_plugin_shop_section_show_codes: - path: /sections/{codes} - methods: [GET] - defaults: - _controller: bitbag_sylius_cms_plugin.controller.section::indexAction - _sylius: - template: $template - repository: - method: findByCodesAndLocale - arguments: - - $codes - - "expr:service('sylius.context.locale').getLocaleCode()" - diff --git a/src/Resources/config/serialization/Block.xml b/src/Resources/config/serialization/Block.xml index 0faacbba8..c0648ecd9 100644 --- a/src/Resources/config/serialization/Block.xml +++ b/src/Resources/config/serialization/Block.xml @@ -3,30 +3,40 @@ 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 + sylius_cms:block:read:index + sylius_cms:block:read:show - shop:cms:read + sylius_cms:block:read:index + sylius_cms:block:read:show + + + sylius_cms:block:read:index + sylius_cms:block:read:show - shop:cms:read + sylius_cms:block:read:index + sylius_cms:block:read:show - - shop:cms:read + + sylius_cms:block:read:show - - shop:cms:read + + sylius_cms:block:read:show - - shop:cms:read + + sylius_cms:block:read:show - shop:cms:read + sylius_cms:block:read:show + + + sylius_cms:block:read:show - - shop:cms:read + + sylius_cms:block:read:show diff --git a/src/Resources/config/serialization/BlockTranslation.xml b/src/Resources/config/serialization/BlockTranslation.xml deleted file mode 100644 index b56254f8c..000000000 --- a/src/Resources/config/serialization/BlockTranslation.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - shop:cms:read - - - shop:cms:read - - - shop:cms:read - - - diff --git a/src/Resources/config/serialization/Collection.xml b/src/Resources/config/serialization/Collection.xml new file mode 100644 index 000000000..90182810b --- /dev/null +++ b/src/Resources/config/serialization/Collection.xml @@ -0,0 +1,29 @@ + + + + + sylius_cms:collection:read:index + sylius_cms:collection:read:show + + + sylius_cms:collection:read:index + sylius_cms:collection:read:show + + + sylius_cms:collection:read:index + sylius_cms:collection:read:show + + + sylius_cms:collection:read:show + + + sylius_cms:collection:read:show + + + sylius_cms:collection:read:show + + + diff --git a/src/Resources/config/serialization/ContentConfiguration.xml b/src/Resources/config/serialization/ContentConfiguration.xml new file mode 100644 index 000000000..a288347f0 --- /dev/null +++ b/src/Resources/config/serialization/ContentConfiguration.xml @@ -0,0 +1,28 @@ + + + + + sylius_cms:page:read:index + sylius_cms:page:read:show + + + sylius_cms:page:read:index + sylius_cms:page:read:show + + + sylius_cms:page:read:show + + + sylius_cms:page:read:show + + + sylius_cms:page:read:show + + + sylius_cms:page:read:show + + + diff --git a/src/Resources/config/serialization/Faq.xml b/src/Resources/config/serialization/Faq.xml deleted file mode 100644 index 89e1154db..000000000 --- a/src/Resources/config/serialization/Faq.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - shop:cms:read - - - shop:cms:read - - - shop:cms:read - - - shop:cms:read - - - shop:cms:read - - - shop:cms:read - - - diff --git a/src/Resources/config/serialization/FaqTranslation.xml b/src/Resources/config/serialization/FaqTranslation.xml deleted file mode 100644 index 235bfcfe1..000000000 --- a/src/Resources/config/serialization/FaqTranslation.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - shop:cms:read - - - shop:cms:read - - - diff --git a/src/Resources/config/serialization/Media.xml b/src/Resources/config/serialization/Media.xml index 61dcde6ab..24f4c722b 100644 --- a/src/Resources/config/serialization/Media.xml +++ b/src/Resources/config/serialization/Media.xml @@ -3,45 +3,50 @@ 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 + sylius_cms:media:read:index + sylius_cms:media:read:show - shop:cms:read + sylius_cms:media:read:index + sylius_cms:media:read:show + + + sylius_cms:media:read:index + sylius_cms:media:read:show - shop:cms:read + sylius_cms:media:read:index + sylius_cms:media:read:show + + + sylius_cms:media:read:index + sylius_cms:media:read:show - shop:cms:read + sylius_cms:media:read:show - shop:cms:read - - - shop:cms:read + sylius_cms:media:read:show - shop:cms:read + sylius_cms:media:read:show - shop:cms:read + sylius_cms:media:read:show - shop:cms:read - - - shop:cms:read + sylius_cms:media:read:show - - shop:cms:read + + sylius_cms:media:read:show - shop:cms:read + sylius_cms:media:read:show - shop:cms:read + sylius_cms:media:read:show diff --git a/src/Resources/config/serialization/MediaTranslation.xml b/src/Resources/config/serialization/MediaTranslation.xml index 7a99d1fed..1a773bbb0 100644 --- a/src/Resources/config/serialization/MediaTranslation.xml +++ b/src/Resources/config/serialization/MediaTranslation.xml @@ -3,18 +3,15 @@ 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 - + - shop:cms:read + sylius_cms:media:read:show - shop:cms:read + sylius_cms:media:read:show - shop:cms:read + sylius_cms:media:read:show diff --git a/src/Resources/config/serialization/Page.xml b/src/Resources/config/serialization/Page.xml index 177296ea6..50a05b5d2 100644 --- a/src/Resources/config/serialization/Page.xml +++ b/src/Resources/config/serialization/Page.xml @@ -3,18 +3,27 @@ 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 + sylius_cms:page:read:index + sylius_cms:page:read:show - shop:cms:read + sylius_cms:page:read:index + sylius_cms:page:read:show + + + sylius_cms:page:read:index + sylius_cms:page:read:show - shop:cms:read + sylius_cms:page:read:show + + + sylius_cms:page:read:show - shop:cms:read + sylius_cms:page:read:show diff --git a/src/Resources/config/serialization/PageTranslation.xml b/src/Resources/config/serialization/PageTranslation.xml index 2ee008f6c..00b3e8f56 100644 --- a/src/Resources/config/serialization/PageTranslation.xml +++ b/src/Resources/config/serialization/PageTranslation.xml @@ -3,39 +3,27 @@ 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 - + - shop:cms:read - - - shop:cms:read - - - shop:cms:read - - - shop:cms:read + sylius_cms:page:read:show - shop:cms:read + sylius_cms:page:read:show - shop:cms:read + sylius_cms:page:read:show - - shop:cms:read + + sylius_cms:page:read:show - - shop:cms:read + + sylius_cms:page:read:show - - shop:cms:read + + sylius_cms:page:read:show - - shop:cms:read + + sylius_cms:page:read:show diff --git a/src/Resources/config/serialization/Section.xml b/src/Resources/config/serialization/Section.xml deleted file mode 100644 index bced61249..000000000 --- a/src/Resources/config/serialization/Section.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - shop:cms:read - - - shop:cms:read - - - diff --git a/src/Resources/config/serialization/SectionTranslation.xml b/src/Resources/config/serialization/SectionTranslation.xml deleted file mode 100644 index 505f7c914..000000000 --- a/src/Resources/config/serialization/SectionTranslation.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - shop:cms:read - - - diff --git a/src/Resources/config/serialization/Template.xml b/src/Resources/config/serialization/Template.xml new file mode 100644 index 000000000..666114643 --- /dev/null +++ b/src/Resources/config/serialization/Template.xml @@ -0,0 +1,23 @@ + + + + + sylius_cms:template:read:index + sylius_cms:template:read:show + + + sylius_cms:template:read:index + sylius_cms:template:read:show + + + sylius_cms:template:read:index + sylius_cms:template:read:show + + + sylius_cms:template:read:show + + + diff --git a/src/Resources/config/serializer/Entity.Block.yml b/src/Resources/config/serializer/Entity.Block.yml new file mode 100644 index 000000000..80781986c --- /dev/null +++ b/src/Resources/config/serializer/Entity.Block.yml @@ -0,0 +1,17 @@ +Sylius\CmsPlugin\Entity\Block: + exclusion_policy: ALL + xml_root_name: block + properties: + id: + expose: true + type: integer + xml_attribute: true + groups: [Autocomplete] + code: + expose: true + type: string + groups: [Autocomplete] + virtual_properties: + getName: + serialized_name: name + groups: [Autocomplete] diff --git a/src/Resources/config/serializer/Entity.Section.yml b/src/Resources/config/serializer/Entity.Collection.yml similarity index 85% rename from src/Resources/config/serializer/Entity.Section.yml rename to src/Resources/config/serializer/Entity.Collection.yml index 96a51ea3d..ff18f5d99 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: +Sylius\CmsPlugin\Entity\Collection: exclusion_policy: ALL - xml_root_name: section + xml_root_name: collection properties: id: expose: true diff --git a/src/Resources/config/serializer/Entity.Media.yml b/src/Resources/config/serializer/Entity.Media.yml index 8cf3defd2..d6c46c77f 100644 --- a/src/Resources/config/serializer/Entity.Media.yml +++ b/src/Resources/config/serializer/Entity.Media.yml @@ -1,4 +1,4 @@ -BitBag\SyliusCmsPlugin\Entity\Media: +Sylius\CmsPlugin\Entity\Media: exclusion_policy: ALL xml_root_name: media properties: @@ -19,7 +19,7 @@ BitBag\SyliusCmsPlugin\Entity\Media: - rel: self href: - route: bitbag_sylius_cms_plugin_shop_media_inline + route: sylius_cms_shop_media_inline parameters: _locale: expr(object.getTranslation().getLocale()) code: expr(object.getCode()) diff --git a/src/Resources/config/serializer/Entity.Page.yml b/src/Resources/config/serializer/Entity.Page.yml new file mode 100644 index 000000000..75367e63a --- /dev/null +++ b/src/Resources/config/serializer/Entity.Page.yml @@ -0,0 +1,17 @@ +Sylius\CmsPlugin\Entity\Page: + exclusion_policy: ALL + xml_root_name: page + properties: + id: + expose: true + type: integer + xml_attribute: true + groups: [Autocomplete] + code: + expose: true + type: string + groups: [Autocomplete] + virtual_properties: + getName: + serialized_name: name + groups: [Autocomplete] diff --git a/src/Resources/config/serializer/Entity.Template.yml b/src/Resources/config/serializer/Entity.Template.yml new file mode 100644 index 000000000..7e19eefb3 --- /dev/null +++ b/src/Resources/config/serializer/Entity.Template.yml @@ -0,0 +1,13 @@ +Sylius\CmsPlugin\Entity\Template: + exclusion_policy: ALL + xml_root_name: template + properties: + id: + expose: true + type: integer + xml_attribute: true + groups: [Autocomplete] + virtual_properties: + getName: + serialized_name: name + groups: [Autocomplete] diff --git a/src/Resources/config/services.xml b/src/Resources/config/services.xml index a2879038d..90fe0ae3a 100644 --- a/src/Resources/config/services.xml +++ b/src/Resources/config/services.xml @@ -6,42 +6,38 @@ - BitBag\SyliusCmsPlugin\MediaProvider\ProviderInterface + Sylius\CmsPlugin\MediaProvider\ProviderInterface - + - - - + + + - - + + - - - - - - %bitbag_sylius_cms_plugin.media_provider.interface% + + %sylius_cms.media_provider.interface% Media provider - - + + - + - %bitbag_sylius_cms_plugin.uploader.filesystem% + %sylius_cms.uploader.filesystem% - + diff --git a/src/Resources/config/services/assigner.xml b/src/Resources/config/services/assigner.xml index ae5fe46c4..585268f25 100644 --- a/src/Resources/config/services/assigner.xml +++ b/src/Resources/config/services/assigner.xml @@ -4,20 +4,28 @@ - + - + - + - - + + + + + + + + + + diff --git a/src/Resources/config/services/controller.xml b/src/Resources/config/services/controller.xml index 9f40680ed..bbd1d4003 100644 --- a/src/Resources/config/services/controller.xml +++ b/src/Resources/config/services/controller.xml @@ -4,51 +4,55 @@ - + - + - + - - + + - + - - - - + + + + - + + + + + - + - + - + - + @@ -58,12 +62,12 @@ - + - + - + @@ -73,6 +77,6 @@ - + diff --git a/src/Resources/config/services/event_listener.xml b/src/Resources/config/services/event_listener.xml index fc6c51187..5df6289b1 100644 --- a/src/Resources/config/services/event_listener.xml +++ b/src/Resources/config/services/event_listener.xml @@ -4,17 +4,18 @@ - + + - - - - + + + + - + diff --git a/src/Resources/config/services/fixture.xml b/src/Resources/config/services/fixture.xml index 1b862c9ca..6258eceb5 100644 --- a/src/Resources/config/services/fixture.xml +++ b/src/Resources/config/services/fixture.xml @@ -4,78 +4,68 @@ - - + + - - + + - - + + - - + + - - + + - - - - - - - - - - - + + + + + + + + - - - - - - - - - - - + + + + + + + - - - - - + + + + - - - - + + + + + + + - - - - - - - - + + + diff --git a/src/Resources/config/services/form.xml b/src/Resources/config/services/form.xml index 70601a9ae..a9d3016f8 100644 --- a/src/Resources/config/services/form.xml +++ b/src/Resources/config/services/form.xml @@ -1,84 +1,125 @@ + + Sylius\CmsPlugin\Form\Type\ContentElements\SingleMediaContentElementType::TYPE + Sylius\CmsPlugin\Form\Type\ContentElements\MultipleMediaContentElementType::TYPE + Sylius\CmsPlugin\Form\Type\ContentElements\ProductsCarouselByTaxonContentElementType::TYPE + Sylius\CmsPlugin\Form\Type\ContentElements\ProductsGridByTaxonContentElementType::TYPE + Sylius\CmsPlugin\Form\Type\ContentElements\PagesCollectionContentElementType::TYPE + + - - %bitbag_sylius_cms_plugin.model.block.class% - %bitbag_sylius_cms_plugin.form.type.block.validation_groups% + + + + %sylius_cms.model.block.class% + %sylius_cms.form.type.block.validation_groups% - - %bitbag_sylius_cms_plugin.model.block_translation.class% - %bitbag_sylius_cms_plugin.form.type.translation.block.validation_groups% + + Sylius\CmsPlugin\Entity\ContentConfiguration + %sylius_cms.form.type.content_configuration.validation_groups% + + - - BitBag\SyliusCmsPlugin\Entity\BlockImage - %bitbag_sylius_cms_plugin.form.type.block_image.validation_groups% + + + + %sylius_cms.model.page.class% + %sylius_cms.form.type.page.validation_groups% - - %bitbag_sylius_cms_plugin.model.page.class% - %bitbag_sylius_cms_plugin.form.type.page.validation_groups% + + %sylius_cms.model.page_translation.class% + %sylius_cms.form.type.translation.page.validation_groups% - - %bitbag_sylius_cms_plugin.model.page_translation.class% - %bitbag_sylius_cms_plugin.form.type.translation.page.validation_groups% + + %sylius_cms.model.collection.class% + %sylius_cms.form.type.collection.validation_groups% - - %bitbag_sylius_cms_plugin.model.frequently_asked_question.class% - %bitbag_sylius_cms_plugin.form.type.frequently_asked_question.validation_groups% + - - %bitbag_sylius_cms_plugin.model.frequently_asked_question_translation.class% - %bitbag_sylius_cms_plugin.form.type.translation.frequently_asked_question.validation_groups% + + %sylius_cms.model.media_translation.class% + %sylius_cms.form.type.translation.media.validation_groups% - - %bitbag_sylius_cms_plugin.model.section.class% - %bitbag_sylius_cms_plugin.form.type.section.validation_groups% + + %sylius_cms.model.media.class% + %sylius_cms.form.type.media.validation_groups% + %sylius_cms.media_providers% - - %bitbag_sylius_cms_plugin.model.section_translation.class% - %bitbag_sylius_cms_plugin.form.type.translation.section.validation_groups% + + - + + %sylius_cms.model.template.class% + %sylius_cms.form.type.template.validation_groups% - - %bitbag_sylius_cms_plugin.model.media_translation.class% - %bitbag_sylius_cms_plugin.form.type.translation.media.validation_groups% + + - - %bitbag_sylius_cms_plugin.model.media.class% - %bitbag_sylius_cms_plugin.form.type.media.validation_groups% - %bitbag_sylius_cms_plugin.media_providers% + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Resources/config/services/importer.xml b/src/Resources/config/services/importer.xml index 636f252e4..1ed179826 100644 --- a/src/Resources/config/services/importer.xml +++ b/src/Resources/config/services/importer.xml @@ -4,41 +4,58 @@ - + - - + + - - - - - - + + - + - - + + + + + + + + + + + + + + - - - + - - + + - - + + - - + + + + + + + + + + + + + + - - + diff --git a/src/Resources/config/services/media_provider.xml b/src/Resources/config/services/media_provider.xml index 52f284517..989c30996 100644 --- a/src/Resources/config/services/media_provider.xml +++ b/src/Resources/config/services/media_provider.xml @@ -4,28 +4,28 @@ - - + + - @BitBagSyliusCmsPlugin/Shop/Media/Show/image.html.twig + @SyliusCmsPlugin/Shop/Media/Show/image.html.twig media/image - + - - + + - @BitBagSyliusCmsPlugin/Shop/Media/Show/video.html.twig + @SyliusCmsPlugin/Shop/Media/Show/video.html.twig media/video - + - - + + - @BitBagSyliusCmsPlugin/Shop/Media/Show/file.html.twig + @SyliusCmsPlugin/Shop/Media/Show/file.html.twig media/file - + diff --git a/src/Resources/config/services/menu.xml b/src/Resources/config/services/menu.xml new file mode 100644 index 000000000..0f78688e5 --- /dev/null +++ b/src/Resources/config/services/menu.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/src/Resources/config/services/orm.xml b/src/Resources/config/services/orm.xml new file mode 100644 index 000000000..4c59b14ec --- /dev/null +++ b/src/Resources/config/services/orm.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/src/Resources/config/services/provider.xml b/src/Resources/config/services/provider.xml new file mode 100644 index 000000000..eac63dbde --- /dev/null +++ b/src/Resources/config/services/provider.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/src/Resources/config/services/renderer.xml b/src/Resources/config/services/renderer.xml new file mode 100644 index 000000000..7c17f5e6f --- /dev/null +++ b/src/Resources/config/services/renderer.xml @@ -0,0 +1,132 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Resources/config/services/resolver.xml b/src/Resources/config/services/resolver.xml index 6fce6c8a0..2aaf7d5b7 100644 --- a/src/Resources/config/services/resolver.xml +++ b/src/Resources/config/services/resolver.xml @@ -4,63 +4,78 @@ - - - + + + code - - - + + + code - - - + + + code - - - + + + code - - + + - - - + + - - - + + + + + + + - - + + + + + + + + + + + + + + - - + + - - + + - - + + diff --git a/src/Resources/config/services/twig.xml b/src/Resources/config/services/twig.xml index 7ab15a413..ff0c2e71a 100644 --- a/src/Resources/config/services/twig.xml +++ b/src/Resources/config/services/twig.xml @@ -2,74 +2,91 @@ - - bitbag_cms_render_block - bitbag_cms_render_media + + sylius_cms_render_block + sylius_cms_render_media - @BitBagSyliusCmsPlugin/Page/link.html.twig + @SyliusCmsPlugin/Page/link.html.twig - - + + - - + + + - - + + - - - + + + + - - + + - - - - - + + + + + + + + + + + + - + - - + + - + - %bitbag_cms.twig.admin_functions% + %sylius_cms.twig.admin_functions% - + - - - + + - %bitbag_cms.twig.link_template% + %sylius_cms.twig.link_template% + + + + + + + + + diff --git a/src/Resources/config/validation/Block.xml b/src/Resources/config/validation/Block.xml index 26e369571..f142162c3 100644 --- a/src/Resources/config/validation/Block.xml +++ b/src/Resources/config/validation/Block.xml @@ -3,44 +3,57 @@ xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping http://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd"> - + - + - + - - + + - + - - + + + + + + + + + + + diff --git a/src/Resources/config/validation/BlockTranslation.xml b/src/Resources/config/validation/BlockTranslation.xml deleted file mode 100644 index bd3e547f1..000000000 --- a/src/Resources/config/validation/BlockTranslation.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Resources/config/validation/Collection.xml b/src/Resources/config/validation/Collection.xml new file mode 100644 index 000000000..4bdd82aff --- /dev/null +++ b/src/Resources/config/validation/Collection.xml @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Resources/config/validation/FrequentlyAskedQuestion.xml b/src/Resources/config/validation/FrequentlyAskedQuestion.xml deleted file mode 100644 index ead67ad2c..000000000 --- a/src/Resources/config/validation/FrequentlyAskedQuestion.xml +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Resources/config/validation/FrequentlyAskedQuestionTranslation.xml b/src/Resources/config/validation/FrequentlyAskedQuestionTranslation.xml deleted file mode 100644 index 8bc83fdcf..000000000 --- a/src/Resources/config/validation/FrequentlyAskedQuestionTranslation.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Resources/config/validation/Media.xml b/src/Resources/config/validation/Media.xml index e7c2f4e1e..eb8ee1eba 100644 --- a/src/Resources/config/validation/Media.xml +++ b/src/Resources/config/validation/Media.xml @@ -3,46 +3,63 @@ xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping http://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd"> - + - + - + - - + + - + - - + + - + + + + + + + + + + + + + + @@ -50,9 +67,9 @@ - + @@ -60,7 +77,7 @@ diff --git a/src/Resources/config/validation/MediaTranslation.xml b/src/Resources/config/validation/MediaTranslation.xml index 1e3495124..4897fd36e 100644 --- a/src/Resources/config/validation/MediaTranslation.xml +++ b/src/Resources/config/validation/MediaTranslation.xml @@ -3,27 +3,15 @@ xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping http://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd"> - - - - - - - - - - - + - - + + @@ -32,10 +20,10 @@ - - + + @@ -43,10 +31,10 @@ - - + + diff --git a/src/Resources/config/validation/Page.xml b/src/Resources/config/validation/Page.xml index 5cf0e3316..a663aecae 100644 --- a/src/Resources/config/validation/Page.xml +++ b/src/Resources/config/validation/Page.xml @@ -3,38 +3,56 @@ xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping http://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd"> - + - + - + - - + + - + + + + + + + + + + + + + + + diff --git a/src/Resources/config/validation/PageTranslation.xml b/src/Resources/config/validation/PageTranslation.xml index cd4f86842..b211defa5 100644 --- a/src/Resources/config/validation/PageTranslation.xml +++ b/src/Resources/config/validation/PageTranslation.xml @@ -3,7 +3,7 @@ xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping http://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd"> - + - + - - - - - - - - - - - - - - - - - - - - + + @@ -56,10 +32,10 @@ - - + + @@ -68,26 +44,10 @@ - - - - - - - - - - - - - - + + diff --git a/src/Resources/config/validation/Section.xml b/src/Resources/config/validation/Section.xml deleted file mode 100644 index a9034efda..000000000 --- a/src/Resources/config/validation/Section.xml +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Resources/config/validation/SectionTranslation.xml b/src/Resources/config/validation/Template.xml similarity index 50% rename from src/Resources/config/validation/SectionTranslation.xml rename to src/Resources/config/validation/Template.xml index 4c1bd58cc..ff0fccfb2 100644 --- a/src/Resources/config/validation/SectionTranslation.xml +++ b/src/Resources/config/validation/Template.xml @@ -3,21 +3,31 @@ xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping http://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd"> - + + + + + + + - + - - + + diff --git a/src/Resources/public/build/bitbag-cms-admin.css b/src/Resources/public/build/bitbag-cms-admin.css deleted file mode 100644 index 83c50b5d9..000000000 --- a/src/Resources/public/build/bitbag-cms-admin.css +++ /dev/null @@ -1 +0,0 @@ -#bitbag-cms-resource-preview-modal{height:100%}#bitbag-cms-resource-preview-modal iframe{height:100vh;width:100%}#bitbag-cms-resource-preview-modal .ui.header{padding-bottom:0}.bitbag-cms-import .ui.action.input input[type=file]{display:none}.bitbag-cms-import .ui.action.input input[type=text]{width:auto}.media-list{grid-gap:20px;display:grid;grid-template-columns:repeat(6,150px);margin:0 auto}.media-list__item{align-items:flex-start;display:flex;flex-direction:column;justify-content:space-between;max-width:150px;position:relative!important}.media-list__item__label,.media-list__item__label>strong{word-wrap:break-word!important;white-space:-moz-pre-wrap!important;white-space:-webkit-pre-wrap!important;white-space:-pre-wrap!important;white-space:-o-pre-wrap!important;white-space:pre-wrap!important;white-space:normal!important;word-break:break-all!important}.media-list__item__label>strong{display:block!important}.media-list__item__input{bottom:10px;position:absolute!important;right:10px;z-index:99}.media-list__item__input:hover{cursor:pointer}.media-list__item__img{height:150px!important;width:150px!important}.btn{display:inline-block!important;font-size:1.4em!important}.btn:hover{cursor:pointer}.page-number{font-size:1.4em!important}.btn-delete{color:#db2828;cursor:pointer;font-weight:700;height:20px;position:absolute;right:30px;width:20px;z-index:5}.btn-delete.is-hidden{opacity:.2;pointer-events:none}.bitbag-media-autocomplete .dropdown.icon{pointer-events:none}.bitbag-media-autocomplete .search{cursor:pointer!important} \ No newline at end of file diff --git a/src/Resources/public/build/bitbag-cms-admin.js b/src/Resources/public/build/bitbag-cms-admin.js deleted file mode 100644 index ed9eb90dc..000000000 --- a/src/Resources/public/build/bitbag-cms-admin.js +++ /dev/null @@ -1,2 +0,0 @@ -/*! For license information please see bitbag-cms-admin.js.LICENSE.txt */ -(()=>{"use strict";function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}function e(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t,e){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:{textField:"data-bb-cms-text",fileField:"data-bb-cms-file"};e(this,n),this.config=t,this.textField=document.querySelector("[".concat(t.textField,"]")),this.fileField=document.querySelector("[".concat(t.fileField,"]"))}var o,i,a;return o=n,(i=[{key:"init",value:function(){if("object"!==t(this.config))throw new Error("Bitbag CMS Plugin - HandleCsvUpload class config is not a valid object");this._handleFields()}},{key:"_handleFields",value:function(){this._handleTextField(),this._handleFileField()}},{key:"_handleTextField",value:function(){var t=this;this.textField.addEventListener("click",(function(){t.fileField.click()}))}},{key:"_handleFileField",value:function(){var t=this;this.fileField.addEventListener("change",(function(e){t.textField.value=e.target.files[0].name}))}}])&&r(o.prototype,i),a&&r(o,a),Object.defineProperty(o,"prototype",{writable:!1}),n}();const o=function(t,e,r){var n=new CustomEvent("".concat("bb",".").concat(e),{detail:r});return t.dispatchEvent(n),t};function i(){i=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",a=n.asyncIterator||"@@asyncIterator",c=n.toStringTag||"@@toStringTag";function l(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{l({},"")}catch(t){l=function(t,e,r){return t[e]=r}}function s(t,e,r,n){var o=e&&e.prototype instanceof d?e:d,i=Object.create(o.prototype),a=new x(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return O()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=_(a,r);if(c){if(c===h)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=f(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===h)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(t,r,a),i}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=s;var h={};function d(){}function p(){}function v(){}var y={};l(y,o,(function(){return this}));var m=Object.getPrototypeOf,g=m&&m(m(k([])));g&&g!==e&&r.call(g,o)&&(y=g);var b=v.prototype=d.prototype=Object.create(y);function w(t){["next","throw","return"].forEach((function(e){l(t,e,(function(t){return this._invoke(e,t)}))}))}function S(t,e){function n(o,i,a,c){var l=f(t[o],t,i);if("throw"!==l.type){var s=l.arg,h=s.value;return h&&"object"==u(h)&&r.call(h,"__await")?e.resolve(h.__await).then((function(t){n("next",t,a,c)}),(function(t){n("throw",t,a,c)})):e.resolve(h).then((function(t){s.value=t,a(s)}),(function(t){return n("throw",t,a,c)}))}c(l.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function _(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,_(t,e),"throw"===e.method))return h;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return h}var n=f(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,h;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,h):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,h)}function L(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function E(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function x(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(L,this),this.reset(!0)}function k(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),E(r),h}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;E(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:k(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),h}},t}function a(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function c(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function c(t){a(i,n,o,c,u,"next",t)}function u(t){a(i,n,o,c,u,"throw",t)}c(void 0)}))}}function u(t){return u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(t)}function l(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function s(t,e){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:{wrappersIndicator:"data-bb-cms-wrapper",lockFieldIndicator:"data-bb-cms-toggle-slug",bbTarget:"bitbag_sylius_cms_plugin_page"};l(this,t),this.wrappers=document.querySelectorAll("[".concat(e.wrappersIndicator,"]")),this.lockFieldIndicator="[".concat(e.lockFieldIndicator,"]"),this.bbTarget=e.bbTarget,this.config=e}var e,r,n,a,f;return e=t,r=[{key:"init",value:function(){if("object"!==u(this.config))throw new Error("Bitbag CMS Plugin - HandleSlugUpdate class config is not a valid object");if("string"!=typeof this.lockFieldIndicator||"string"!=typeof this.bbTarget)throw new Error("Bitbag CMS Plugin - HandleSlugUpdate class config key values are not valid strings");this._handleFields()}},{key:"_handleFields",value:function(){var t=this;this.wrappers.forEach((function(e){var r,n=e.dataset.locale,o=e.querySelector("#".concat(t.bbTarget,"_translations_").concat(n,"_name")),i=e.querySelector("#".concat(t.bbTarget,"_translations_").concat(n,"_slug")),a=e.querySelector(t.lockFieldIndicator);o&&i&&n&&(o.addEventListener("input",(function(e){e.preventDefault(),i.readOnly||(clearTimeout(r),r=setTimeout((function(){t._updateSlug(i,o.value)}),1e3))})),a&&a.addEventListener("click",(function(e){e.preventDefault(),t._toggleSlugModification(i,a)})))}))}},{key:"_updateSlug",value:(f=c(i().mark((function t(e,r){return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o(e,"cms.slug.update.start"),e.parentNode.classList.add("loading"),t.next=4,this._getValidSlug(e.dataset.url,r);case 4:e.value=t.sent,e.parentNode.classList.remove("loading"),o(e,"cms.slug.update.end");case 7:case"end":return t.stop()}}),t,this)}))),function(t,e){return f.apply(this,arguments)})},{key:"_getValidSlug",value:(a=c(i().mark((function t(e,r){var n,o;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,fetch("".concat(e,"?name=").concat(r));case 3:return n=t.sent,t.next=6,n.json();case 6:return o=t.sent,t.abrupt("return",o.slug);case 10:t.prev=10,t.t0=t.catch(0),console.error("BitBag CMS Plugin - HandleSlugUpdate class error : ".concat(t.t0));case 13:case"end":return t.stop()}}),t,null,[[0,10]])}))),function(t,e){return a.apply(this,arguments)})},{key:"_toggleSlugModification",value:function(t,e){t.readOnly=!t.readOnly;var r=e.querySelector("i");r.classList.toggle("lock"),r.classList.toggle("unlock")}}],r&&s(e.prototype,r),n&&s(e,n),Object.defineProperty(e,"prototype",{writable:!1}),t}();function h(){h=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var o=e&&e.prototype instanceof f?e:f,i=Object.create(o.prototype),a=new x(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return O()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=_(a,r);if(c){if(c===s)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=l(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===s)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(t,r,a),i}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var s={};function f(){}function d(){}function p(){}var v={};c(v,o,(function(){return this}));var m=Object.getPrototypeOf,g=m&&m(m(k([])));g&&g!==e&&r.call(g,o)&&(v=g);var b=p.prototype=f.prototype=Object.create(v);function w(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function S(t,e){function n(o,i,a,c){var u=l(t[o],t,i);if("throw"!==u.type){var s=u.arg,f=s.value;return f&&"object"==y(f)&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,a,c)}),(function(t){n("throw",t,a,c)})):e.resolve(f).then((function(t){s.value=t,a(s)}),(function(t){return n("throw",t,a,c)}))}c(u.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function _(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,_(t,e),"throw"===e.method))return s;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return s}var n=l(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,s;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,s):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,s)}function L(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function E(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function x(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(L,this),this.reset(!0)}function k(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),E(r),s}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;E(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:k(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),s}},t}function d(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function p(t){return function(t){if(Array.isArray(t))return v(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return v(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return v(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r0&&void 0!==arguments[0]?arguments[0]:{previewButton:"data-bb-cms-preview-btn",previewModal:"data-bb-cms-preview-modal",channelSwitch:"data-bb-cms-channel",localeSwitch:"data-bb-cms-locale"};m(this,t),this.config=e,this.button=document.querySelector("[".concat(e.previewButton,"]")),this.modal=document.querySelector("[".concat(e.previewModal,"]")),this.modalSelector=e.previewModal,this.channelSelector=e.channelSwitch,this.localeSelector=e.localeSwitch}var e,r,n,i,a;return e=t,r=[{key:"init",value:function(){if("object"!==y(this.config))throw new Error("Bitbag CMS Plugin - HandlePreview class config is not a valid object");if("string"!=typeof this.localeSelector||"string"!=typeof this.channelSelector||"string"!=typeof this.modalSelector)throw new Error("Bitbag CMS Plugin - HandlePreview class config key values are not valid strings");this._resourcePreview()}},{key:"_$_CKEDITOR_MODAL_SHOW",value:function(){return $("[".concat(this.modalSelector,"]")).modal("show")}},{key:"_$_CKEDITOR_UPDATE_INSTANCES",value:function(){p(CKEDITOR.instances).forEach((function(t){return t.updateElement()}))}},{key:"_resourcePreview",value:function(){var t=this;this.button.addEventListener("click",(function(e){e.preventDefault(),t._$_CKEDITOR_UPDATE_INSTANCES,t._createPreview(),t._$_CKEDITOR_MODAL_SHOW()})),document.querySelector("[".concat(this.channelSelector,"]")).addEventListener("change",(function(e){e.preventDefault(),t._$_CKEDITOR_UPDATE_INSTANCES,t._createPreview(),t._$_CKEDITOR_MODAL_SHOW()})),document.querySelector("[".concat(this.localeSelector,"]")).addEventListener("change",(function(e){e.preventDefault(),t._$_CKEDITOR_UPDATE_INSTANCES,t._createPreview(),t._$_CKEDITOR_MODAL_SHOW()}))}},{key:"_createPreview",value:(i=h().mark((function t(){var e,r,n,i,a,c,u,l,s;return h().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.modal.querySelector(".ui.loadable").classList.add("loading"),this.modal.disabled=!0,e=document.querySelector("[".concat(this.channelSelector,"]")).value,r=document.querySelector("[".concat(this.localeSelector,"]")).value,n=this.button.dataset.url,i=this.button.closest("form"),a={method:"POST",body:new FormData(i)},t.prev=7,o(this.modal,"cms.create.preview.start"),t.next=11,fetch("".concat(n,"?_channel_code=").concat(e,"&_locale=").concat(r),a);case 11:return c=t.sent,t.next=14,c.text();case 14:u=t.sent,l=new Blob([u],{type:"text/html",charset:"utf-8"}),s=window.URL.createObjectURL(l),this.modal.querySelector("iframe").src=s,o(this.modal,"cms.create.preview.completed",u),t.next=25;break;case 21:t.prev=21,t.t0=t.catch(7),console.error("BitBag CMS Plugin - HandlePreview class error : ".concat(t.t0)),o(this.modal,"cms.create.preview.error",t.t0);case 25:return t.prev=25,this.modal.querySelector(".ui.loadable").classList.remove("loading"),this.modal.disabled=!1,o(this.modal,"cms.create.preview.end"),t.finish(25);case 30:case"end":return t.stop()}}),t,this,[[7,21,25,30]])})),a=function(){var t=this,e=arguments;return new Promise((function(r,n){var o=i.apply(t,e);function a(t){d(o,r,n,a,c,"next",t)}function c(t){d(o,r,n,a,c,"throw",t)}a(void 0)}))},function(){return a.apply(this,arguments)})}],r&&g(e.prototype,r),n&&g(e,n),Object.defineProperty(e,"prototype",{writable:!1}),t}();function w(){w=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var o=e&&e.prototype instanceof f?e:f,i=Object.create(o.prototype),a=new x(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return O()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=S(a,r);if(c){if(c===s)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=l(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===s)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(t,r,a),i}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var s={};function f(){}function h(){}function d(){}var p={};c(p,o,(function(){return this}));var v=Object.getPrototypeOf,y=v&&v(v(k([])));y&&y!==e&&r.call(y,o)&&(p=y);var m=d.prototype=f.prototype=Object.create(p);function g(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function b(t,e){function n(o,i,a,c){var u=l(t[o],t,i);if("throw"!==u.type){var s=u.arg,f=s.value;return f&&"object"==L(f)&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,a,c)}),(function(t){n("throw",t,a,c)})):e.resolve(f).then((function(t){s.value=t,a(s)}),(function(t){return n("throw",t,a,c)}))}c(u.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function S(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,S(t,e),"throw"===e.method))return s;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return s}var n=l(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,s;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,s):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,s)}function _(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function E(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function x(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(_,this),this.reset(!0)}function k(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),E(r),s}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;E(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:k(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),s}},t}function S(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function _(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){S(i,n,o,a,c,"next",t)}function c(t){S(i,n,o,a,c,"throw",t)}a(void 0)}))}}function L(t){return L="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},L(t)}function E(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function x(t,e){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:{bbMediaContainer:"data-bb-cms-autocomplete",choiceName:"data-bb-cms-choice-name",choiceValue:"data-bb-cms-choice-value",criteriaType:"data-bb-cms-criteria-type",criteriaName:"data-bb-cms-criteria-name",editUrl:"data-bb-cms-load-edit-url",nameMessage:"data-bb-cms-name-message",deleteButton:"data-bb-cms-delete-selected",choosenPreview:"data-bb-cms-selected-image",selectMenu:"data-bb-cms-selection-menu",selectInput:"data-bb-cms-image-select",placeholder:"data-bb-cms-placeholder",limit:30};E(this,t),this.config=e,this.mediaContainers=document.querySelectorAll("[".concat(e.bbMediaContainer,"]")),this.deleteButton="[".concat(e.deleteButton,"]"),this.selectMenu="[".concat(e.selectMenu,"]"),this.selectInput="[".concat(e.selectInput,"]"),this.placeholder="[".concat(e.placeholder,"]")}var e,r,n,i,a;return e=t,r=[{key:"init",value:function(){var t=this;if("object"!==L(this.config))throw new Error("Bitbag CMS Plugin - HandleAutoComplete class config is not a valid object");this.mediaContainers.forEach((function(e){t._handleSavedValue(e),t._handleImageChoice(e),t._handleResetBtn(e)}))}},{key:"_handleResetBtn",value:function(t){var e=this,r=t.querySelector(this.deleteButton);""!==t.querySelector("input[type=hidden]").value?(r.classList.remove("is-hidden"),r.addEventListener("click",(function(){e._resetValues(t)}))):r.classList.add("is-hidden")}},{key:"_handleImageChoice",value:function(t){var e,r=this;t.querySelector(this.selectInput).addEventListener("click",(function(e){e.preventDefault(),r._getMediaImages(t)})),t.querySelector(this.selectInput).addEventListener("input",(function(n){n.preventDefault(),clearTimeout(e),e=setTimeout((function(){r._getMediaImages(t,n.target.value)}),500)})),t.querySelector("input[type=hidden]").addEventListener("change",(function(e){e.preventDefault(),r._handleResetBtn(t)}))}},{key:"_handleSavedValue",value:(a=_(w().mark((function t(e){var r,n,i,a,c;return w().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(""!==e.querySelector("input[type=hidden]").value){t.next=2;break}return t.abrupt("return");case 2:return r="".concat(e.dataset.bbCmsLoadEditUrl,"?code=").concat(e.querySelector("input[type=hidden]").value),t.prev=3,o(e,"cms.media.saved.reload.start"),e.classList.add("loading"),t.next=8,fetch(r);case 8:return a=t.sent,t.next=11,a.json();case 11:c=t.sent,this._addToSelectMenu(c,e),null===(n=e.querySelector(this.selectMenu))||void 0===n||null===(i=n.firstChild)||void 0===i||i.click(),o(e,"cms.media.saved.reload.completed",c),t.next=21;break;case 17:t.prev=17,t.t0=t.catch(3),console.error("BitBag CMS Plugin - HandleAutoComplete class error : ".concat(t.t0)),o(e,"cms.media.saved.reload.error",t.t0);case 21:return t.prev=21,e.classList.remove("loading"),o(e,"cms.media.saved.reload.end"),t.finish(21);case 25:case"end":return t.stop()}}),t,this,[[3,17,21,25]])}))),function(t){return a.apply(this,arguments)})},{key:"_getMediaImages",value:(i=_(w().mark((function t(e){var r,n,i,a,c,u,l,s,f=arguments;return w().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=f.length>1&&void 0!==f[1]&&f[1],n=e.dataset.bbCmsUrl,i=e.dataset.bbCmsCriteriaType,a=r?"&criteria[search][value]=".concat(r):"",c="".concat(n,"&limit=").concat(this.config.limit,"&criteria[search][type]=").concat(i,"&criteria[search][value]=").concat(a),t.prev=5,o(e,"cms.media.display.start"),e.classList.add("loading"),t.next=10,fetch(c);case 10:return u=t.sent,t.next=13,u.json();case 13:l=t.sent,s=l._embedded.items,this._addToSelectMenu(s,e),o(e,"cms.media.display.completed",l),t.next=23;break;case 19:t.prev=19,t.t0=t.catch(5),console.error("BitBag CMS Plugin - HandleAutoComplete class error : ".concat(t.t0)),o(e,"cms.media.display.error",t.t0);case 23:return t.prev=23,e.classList.remove("loading"),o(e,"cms.media.display.end"),t.finish(23);case 27:case"end":return t.stop()}}),t,this,[[5,19,23,27]])}))),function(t){return i.apply(this,arguments)})},{key:"_resetValues",value:function(t){o(t,"cms.media.reset.start"),t.querySelector("input[type=hidden]").value="",t.querySelector(this.selectMenu).innerHTML="",t.querySelector(this.placeholder).innerHTML="",o(t,"cms.media.reset.end")}},{key:"_addToSelectMenu",value:function(t,e){var r=this;o(e,"cms.media.display.update.start");var n=e.querySelector(this.selectMenu);n.innerHTML="",null==t||t.forEach((function(t){n.insertAdjacentHTML("beforeend",r._itemTemplate(t.path,t.code.trim()))})),o(e,"cms.media.display.update.end")}},{key:"_itemTemplate",value:function(t,e){return'
').concat(e,"
")}}],r&&x(e.prototype,r),n&&x(e,n),Object.defineProperty(e,"prototype",{writable:!1}),t}();var O;document.querySelector('[data-bb-target="cms-import"]')&&(new n).init(),(null===(O=document.querySelectorAll('[data-bb-target="cms-slug-update"]'))||void 0===O?void 0:O.length)>0&&(new f).init(),document.querySelectorAll("[data-bb-cms-preview-btn]").length>0&&(new b).init(),document.querySelector('[data-bb-target="cms-handle-autocomplete"]')&&(new k).init()})(); \ No newline at end of file diff --git a/src/Resources/public/build/bitbag-cms-shop.css b/src/Resources/public/build/bitbag-cms-shop.css deleted file mode 100644 index 70da80069..000000000 --- a/src/Resources/public/build/bitbag-cms-shop.css +++ /dev/null @@ -1 +0,0 @@ -.bitbag-block img{max-width:100%} \ No newline at end of file diff --git a/src/Resources/public/build/entrypoints.json b/src/Resources/public/build/entrypoints.json index 00da06b81..38903804c 100644 --- a/src/Resources/public/build/entrypoints.json +++ b/src/Resources/public/build/entrypoints.json @@ -1,19 +1,19 @@ { "entrypoints": { - "bitbag-cms-shop": { + "sylius-cms-shop": { "css": [ - "/public/build/bitbag-cms-shop.css" + "/public/build/sylius-cms-shop.css" ], "js": [ - "/public/build/bitbag-cms-shop.js" + "/public/build/sylius-cms-shop.js" ] }, - "bitbag-cms-admin": { + "sylius-cms-admin": { "css": [ - "/public/build/bitbag-cms-admin.css" + "/public/build/sylius-cms-admin.css" ], "js": [ - "/public/build/bitbag-cms-admin.js" + "/public/build/sylius-cms-admin.js" ] } } diff --git a/src/Resources/public/build/manifest.json b/src/Resources/public/build/manifest.json index fe4d82bd6..328e454c0 100644 --- a/src/Resources/public/build/manifest.json +++ b/src/Resources/public/build/manifest.json @@ -1,6 +1,6 @@ { - "public/build/bitbag-cms-shop.css": "/public/build/bitbag-cms-shop.css", - "public/build/bitbag-cms-shop.js": "/public/build/bitbag-cms-shop.js", - "public/build/bitbag-cms-admin.css": "/public/build/bitbag-cms-admin.css", - "public/build/bitbag-cms-admin.js": "/public/build/bitbag-cms-admin.js" + "public/build/sylius-cms-shop.css": "/public/build/sylius-cms-shop.css", + "public/build/sylius-cms-shop.js": "/public/build/sylius-cms-shop.js", + "public/build/sylius-cms-admin.css": "/public/build/sylius-cms-admin.css", + "public/build/sylius-cms-admin.js": "/public/build/sylius-cms-admin.js" } \ No newline at end of file diff --git a/src/Resources/public/build/sylius-cms-admin.css b/src/Resources/public/build/sylius-cms-admin.css new file mode 100644 index 000000000..49fef1082 --- /dev/null +++ b/src/Resources/public/build/sylius-cms-admin.css @@ -0,0 +1 @@ +#cms-resource-preview-modal{height:100%}#cms-resource-preview-modal iframe{height:100vh;width:100%}#cms-resource-preview-modal .ui.header{padding-bottom:0}.cms-import .ui.action.input input[type=file]{display:none}.cms-import .ui.action.input input[type=text]{width:auto}.media-list{grid-gap:20px;display:grid;grid-template-columns:repeat(6,150px);margin:0 auto}.media-list__item{align-items:flex-start;display:flex;flex-direction:column;justify-content:space-between;max-width:150px;position:relative!important}.media-list__item__label,.media-list__item__label>strong{word-wrap:break-word!important;white-space:-moz-pre-wrap!important;white-space:-webkit-pre-wrap!important;white-space:-pre-wrap!important;white-space:-o-pre-wrap!important;white-space:pre-wrap!important;white-space:normal!important;word-break:break-all!important}.media-list__item__label>strong{display:block!important}.media-list__item__input{bottom:10px;position:absolute!important;right:10px;z-index:99}.media-list__item__input:hover{cursor:pointer}.media-list__item__img{height:150px!important;width:150px!important}.btn{display:inline-block!important;font-size:1.4em!important}.btn:hover{cursor:pointer}.page-number{font-size:1.4em!important}.btn-delete{color:#db2828;cursor:pointer;font-weight:700;height:20px;position:absolute;right:30px;width:20px;z-index:5}.btn-delete.is-hidden{opacity:.2;pointer-events:none}.cms-media-autocomplete .dropdown.icon{pointer-events:none}.cms-media-autocomplete .search{cursor:pointer!important}.bb-collection-item{margin-bottom:1em}.bb-collection-item-delete{margin-top:5px!important}.cke_notifications_area{display:none}.help-text{font-size:12px;margin-top:-10px;opacity:.5} \ No newline at end of file diff --git a/src/Resources/public/build/sylius-cms-admin.js b/src/Resources/public/build/sylius-cms-admin.js new file mode 100644 index 000000000..e1bee5273 --- /dev/null +++ b/src/Resources/public/build/sylius-cms-admin.js @@ -0,0 +1,2 @@ +/*! For license information please see sylius-cms-admin.js.LICENSE.txt */ +(()=>{var t={461:()=>{$(document).ready((function(){$(".bitbag-media-autocomplete, .sylius-autocomplete").each((function(t,e){$(e).autoComplete()}));var t="#sylius_cms_page_contentElements",e=$(t).length?t:"#sylius_cms_block_contentElements";$(e).length&&($(document).on("collection-form-add",(function(){$(".bitbag-media-autocomplete, .sylius-autocomplete").each((function(t,e){void 0===$._data($(e).get(0),"events")&&$(e).autoComplete()})),$("".concat(e,' [data-form-collection="item"]')).each((function(t,e){$(document).loadContentConfiguration(e)}))})),$.fn.extend({loadContentConfiguration:function(t){t.querySelector("".concat(e,' select[name*="type"]')).onchange=function(){var t=this.parentElement,e=document.createElement("div"),r=this.selectedOptions[0];e.innerHTML=r.getAttribute("data-configuration");var n=t.nextElementSibling;t.parentElement.replaceChild(e,n);var o=n.querySelector("input");o||(o=n.querySelector("textarea"));var i=o.getAttribute("name"),a=e.querySelectorAll("input");a.length||(a=e.querySelectorAll("textarea")),a.forEach((function(t){var r=t.getAttribute("name");r&&(r=i.replace(i.substring(i.indexOf("[configuration]")+15),r.substring(r.indexOf("configuration")+13)),$(t).attr("name",r),$(e).find(".bitbag-media-autocomplete").autoComplete(),$(e).find(".sylius-autocomplete").autoComplete())}))}}}),$("".concat(e,' [data-form-collection="item"]')).each((function(t,e){$(document).loadContentConfiguration(e)})),$(document).loadContentConfiguration(document.querySelector("".concat(e,' [data-form-collection="item"]'))))}))}},e={};function r(n){var o=e[n];if(void 0!==o)return o.exports;var i=e[n]={exports:{}};return t[n](i,i.exports,r),i.exports}(()=>{"use strict";r(461);function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}function e(t,e){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:{textField:"data-bb-cms-text",fileField:"data-bb-cms-file"};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.config=e,this.textField=document.querySelector("[".concat(e.textField,"]")),this.fileField=document.querySelector("[".concat(e.fileField,"]"))},n=[{key:"init",value:function(){if("object"!==t(this.config))throw new Error("Bitbag CMS Plugin - HandleCsvUpload class config is not a valid object");this._handleFields()}},{key:"_handleFields",value:function(){this._handleTextField(),this._handleFileField()}},{key:"_handleTextField",value:function(){var t=this;this.textField.addEventListener("click",(function(){t.fileField.click()}))}},{key:"_handleFileField",value:function(){var t=this;this.fileField.addEventListener("change",(function(e){t.textField.value=e.target.files[0].name}))}}],n&&e(r.prototype,n),o&&e(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}();const i=function(t,e,r){var n=new CustomEvent("".concat("bb",".").concat(e),{detail:r});return t.dispatchEvent(n),t};function a(){a=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},i="function"==typeof Symbol?Symbol:{},c=i.iterator||"@@iterator",u=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function f(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{f({},"")}catch(t){f=function(t,e,r){return t[e]=r}}function h(t,e,r,n){var i=e&&e.prototype instanceof b?e:b,a=Object.create(i.prototype),c=new I(n||[]);return o(a,"_invoke",{value:O(t,r,c)}),a}function d(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=h;var p="suspendedStart",y="suspendedYield",v="executing",m="completed",g={};function b(){}function w(){}function S(){}var _={};f(_,c,(function(){return this}));var E=Object.getPrototypeOf,L=E&&E(E(F([])));L&&L!==r&&n.call(L,c)&&(_=L);var x=S.prototype=b.prototype=Object.create(_);function k(t){["next","throw","return"].forEach((function(e){f(t,e,(function(t){return this._invoke(e,t)}))}))}function j(t,e){function r(o,i,a,c){var u=d(t[o],t,i);if("throw"!==u.type){var s=u.arg,f=s.value;return f&&"object"==l(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,c)}),(function(t){r("throw",t,a,c)})):e.resolve(f).then((function(t){s.value=t,a(s)}),(function(t){return r("throw",t,a,c)}))}c(u.arg)}var i;o(this,"_invoke",{value:function(t,n){function o(){return new e((function(e,o){r(t,n,e,o)}))}return i=i?i.then(o,o):o()}})}function O(e,r,n){var o=p;return function(i,a){if(o===v)throw Error("Generator is already running");if(o===m){if("throw"===i)throw a;return{value:t,done:!0}}for(n.method=i,n.arg=a;;){var c=n.delegate;if(c){var u=P(c,n);if(u){if(u===g)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===p)throw o=m,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=v;var l=d(e,r,n);if("normal"===l.type){if(o=n.done?m:y,l.arg===g)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(o=m,n.method="throw",n.arg=l.arg)}}}function P(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,P(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var i=d(o,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,g;var a=i.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,g):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,g)}function T(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function C(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(T,this),this.reset(!0)}function F(e){if(e||""===e){var r=e[c];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,i=function r(){for(;++o=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),l=n.call(a,"finallyLoc");if(u&&l){if(this.prev=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),C(r),g}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;C(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:F(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),g}},e}function c(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function u(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){c(i,n,o,a,u,"next",t)}function u(t){c(i,n,o,a,u,"throw",t)}a(void 0)}))}}function l(t){return l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},l(t)}function s(t,e){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:{wrappersIndicator:"data-bb-cms-wrapper",lockFieldIndicator:"data-bb-cms-toggle-slug",bbTarget:"sylius_cms_page",nameField:"sylius_cms_page_name"};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.wrappers=document.querySelectorAll("[".concat(e.wrappersIndicator,"]")),this.lockFieldIndicator="[".concat(e.lockFieldIndicator,"]"),this.bbTarget=e.bbTarget,this.config=e,this.nameField=document.getElementById("".concat(e.nameField))},e=[{key:"init",value:function(){if("object"!==l(this.config))throw new Error("Bitbag CMS Plugin - HandleSlugUpdate class config is not a valid object");if("string"!=typeof this.lockFieldIndicator||"string"!=typeof this.bbTarget)throw new Error("Bitbag CMS Plugin - HandleSlugUpdate class config key values are not valid strings");if(!this.nameField)throw new Error("Bitbag CMS Plugin - HandleSlugUpdate name field not found");this._handleFields()}},{key:"_handleFields",value:function(){var t=this;this.wrappers.forEach((function(e){var r=e.dataset.locale,n=e.querySelector("#".concat(t.bbTarget,"_translations_").concat(r,"_slug"));if(n||(n=e.querySelector("#".concat(t.bbTarget,"_slug"))),n){var o;t.nameField.addEventListener("input",(function(e){e.preventDefault(),n.readOnly||(clearTimeout(o),o=setTimeout((function(){t._updateSlug(n,t.nameField.value)}),1e3))}));var i=e.querySelector(t.lockFieldIndicator);i&&i.addEventListener("click",(function(e){e.preventDefault(),t._toggleSlugModification(n,i)}))}}))}},{key:"_updateSlug",value:(o=u(a().mark((function t(e,r){return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i(e,"cms.slug.update.start"),e.parentNode.classList.add("loading"),t.next=4,this._getValidSlug(e.dataset.url,r);case 4:e.value=t.sent,e.parentNode.classList.remove("loading"),i(e,"cms.slug.update.end");case 7:case"end":return t.stop()}}),t,this)}))),function(t,e){return o.apply(this,arguments)})},{key:"_getValidSlug",value:(n=u(a().mark((function t(e,r){var n,o;return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,fetch("".concat(e,"?name=").concat(encodeURIComponent(r)));case 3:return n=t.sent,t.next=6,n.json();case 6:return o=t.sent,t.abrupt("return",o.slug);case 10:t.prev=10,t.t0=t.catch(0),console.error("BitBag CMS Plugin - HandleSlugUpdate class error : ".concat(t.t0));case 13:case"end":return t.stop()}}),t,null,[[0,10]])}))),function(t,e){return n.apply(this,arguments)})},{key:"_toggleSlugModification",value:function(t,e){t.readOnly=!t.readOnly;var r=e.querySelector("i");r.classList.toggle("lock"),r.classList.toggle("unlock")}}],e&&s(t.prototype,e),r&&s(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r,n,o}();function d(){d=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function l(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{l({},"")}catch(t){l=function(t,e,r){return t[e]=r}}function s(t,e,r,n){var i=e&&e.prototype instanceof b?e:b,a=Object.create(i.prototype),c=new I(n||[]);return o(a,"_invoke",{value:O(t,r,c)}),a}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=s;var h="suspendedStart",p="suspendedYield",y="executing",v="completed",g={};function b(){}function w(){}function S(){}var _={};l(_,a,(function(){return this}));var E=Object.getPrototypeOf,L=E&&E(E(F([])));L&&L!==r&&n.call(L,a)&&(_=L);var x=S.prototype=b.prototype=Object.create(_);function k(t){["next","throw","return"].forEach((function(e){l(t,e,(function(t){return this._invoke(e,t)}))}))}function j(t,e){function r(o,i,a,c){var u=f(t[o],t,i);if("throw"!==u.type){var l=u.arg,s=l.value;return s&&"object"==m(s)&&n.call(s,"__await")?e.resolve(s.__await).then((function(t){r("next",t,a,c)}),(function(t){r("throw",t,a,c)})):e.resolve(s).then((function(t){l.value=t,a(l)}),(function(t){return r("throw",t,a,c)}))}c(u.arg)}var i;o(this,"_invoke",{value:function(t,n){function o(){return new e((function(e,o){r(t,n,e,o)}))}return i=i?i.then(o,o):o()}})}function O(e,r,n){var o=h;return function(i,a){if(o===y)throw Error("Generator is already running");if(o===v){if("throw"===i)throw a;return{value:t,done:!0}}for(n.method=i,n.arg=a;;){var c=n.delegate;if(c){var u=P(c,n);if(u){if(u===g)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===h)throw o=v,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=y;var l=f(e,r,n);if("normal"===l.type){if(o=n.done?v:p,l.arg===g)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(o=v,n.method="throw",n.arg=l.arg)}}}function P(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,P(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var i=f(o,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,g;var a=i.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,g):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,g)}function T(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function C(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(T,this),this.reset(!0)}function F(e){if(e||""===e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,i=function r(){for(;++o=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),l=n.call(a,"finallyLoc");if(u&&l){if(this.prev=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),C(r),g}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;C(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:F(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),g}},e}function p(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function y(t){return function(t){if(Array.isArray(t))return v(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return v(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?v(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r0&&void 0!==arguments[0]?arguments[0]:{previewButton:"data-bb-cms-preview-btn",previewModal:"data-bb-cms-preview-modal",channelSwitch:"data-bb-cms-channel",localeSwitch:"data-bb-cms-locale"};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.config=e,this.button=document.querySelector("[".concat(e.previewButton,"]")),this.modal=document.querySelector("[".concat(e.previewModal,"]")),this.modalSelector=e.previewModal,this.channelSelector=e.channelSwitch,this.localeSelector=e.localeSwitch},e=[{key:"init",value:function(){if("object"!==m(this.config))throw new Error("Bitbag CMS Plugin - HandlePreview class config is not a valid object");if("string"!=typeof this.localeSelector||"string"!=typeof this.channelSelector||"string"!=typeof this.modalSelector)throw new Error("Bitbag CMS Plugin - HandlePreview class config key values are not valid strings");this._resourcePreview()}},{key:"_$_CKEDITOR_MODAL_SHOW",value:function(){return $("[".concat(this.modalSelector,"]")).modal("show")}},{key:"_$_CKEDITOR_UPDATE_INSTANCES",value:function(){y(CKEDITOR.instances).forEach((function(t){return t.updateElement()}))}},{key:"_resourcePreview",value:function(){var t=this;this.button.addEventListener("click",(function(e){e.preventDefault(),t._$_CKEDITOR_UPDATE_INSTANCES,t._createPreview(),t._$_CKEDITOR_MODAL_SHOW()})),document.querySelector("[".concat(this.channelSelector,"]")).addEventListener("change",(function(e){e.preventDefault(),t._$_CKEDITOR_UPDATE_INSTANCES,t._createPreview(),t._$_CKEDITOR_MODAL_SHOW()})),document.querySelector("[".concat(this.localeSelector,"]")).addEventListener("change",(function(e){e.preventDefault(),t._$_CKEDITOR_UPDATE_INSTANCES,t._createPreview(),t._$_CKEDITOR_MODAL_SHOW()}))}},{key:"_createPreview",value:(n=d().mark((function t(){var e,r,n,o,a,c,u,l,s;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.modal.querySelector(".ui.loadable").classList.add("loading"),this.modal.disabled=!0,e=document.querySelector("[".concat(this.channelSelector,"]")).value,r=document.querySelector("[".concat(this.localeSelector,"]")).value,n=this.button.dataset.url,o=this.button.closest("form"),a={method:"POST",body:new FormData(o)},t.prev=7,i(this.modal,"cms.create.preview.start"),t.next=11,fetch("".concat(n,"?_channel_code=").concat(e,"&_locale=").concat(r),a);case 11:return c=t.sent,t.next=14,c.text();case 14:u=t.sent,l=new Blob([u],{type:"text/html",charset:"utf-8"}),s=window.URL.createObjectURL(l),this.modal.querySelector("iframe").src=s,i(this.modal,"cms.create.preview.completed",u),t.next=25;break;case 21:t.prev=21,t.t0=t.catch(7),console.error("BitBag CMS Plugin - HandlePreview class error : ".concat(t.t0)),i(this.modal,"cms.create.preview.error",t.t0);case 25:return t.prev=25,this.modal.querySelector(".ui.loadable").classList.remove("loading"),this.modal.disabled=!1,i(this.modal,"cms.create.preview.end"),t.finish(25);case 30:case"end":return t.stop()}}),t,this,[[7,21,25,30]])})),o=function(){var t=this,e=arguments;return new Promise((function(r,o){var i=n.apply(t,e);function a(t){p(i,r,o,a,c,"next",t)}function c(t){p(i,r,o,a,c,"throw",t)}a(void 0)}))},function(){return o.apply(this,arguments)})}],e&&g(t.prototype,e),r&&g(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r,n,o}();function S(){S=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function l(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{l({},"")}catch(t){l=function(t,e,r){return t[e]=r}}function s(t,e,r,n){var i=e&&e.prototype instanceof m?e:m,a=Object.create(i.prototype),c=new I(n||[]);return o(a,"_invoke",{value:O(t,r,c)}),a}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=s;var h="suspendedStart",d="suspendedYield",p="executing",y="completed",v={};function m(){}function g(){}function b(){}var w={};l(w,a,(function(){return this}));var _=Object.getPrototypeOf,E=_&&_(_(F([])));E&&E!==r&&n.call(E,a)&&(w=E);var L=b.prototype=m.prototype=Object.create(w);function x(t){["next","throw","return"].forEach((function(e){l(t,e,(function(t){return this._invoke(e,t)}))}))}function j(t,e){function r(o,i,a,c){var u=f(t[o],t,i);if("throw"!==u.type){var l=u.arg,s=l.value;return s&&"object"==k(s)&&n.call(s,"__await")?e.resolve(s.__await).then((function(t){r("next",t,a,c)}),(function(t){r("throw",t,a,c)})):e.resolve(s).then((function(t){l.value=t,a(l)}),(function(t){return r("throw",t,a,c)}))}c(u.arg)}var i;o(this,"_invoke",{value:function(t,n){function o(){return new e((function(e,o){r(t,n,e,o)}))}return i=i?i.then(o,o):o()}})}function O(e,r,n){var o=h;return function(i,a){if(o===p)throw Error("Generator is already running");if(o===y){if("throw"===i)throw a;return{value:t,done:!0}}for(n.method=i,n.arg=a;;){var c=n.delegate;if(c){var u=P(c,n);if(u){if(u===v)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===h)throw o=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=p;var l=f(e,r,n);if("normal"===l.type){if(o=n.done?y:d,l.arg===v)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(o=y,n.method="throw",n.arg=l.arg)}}}function P(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,P(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),v;var i=f(o,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,v;var a=i.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function T(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function C(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(T,this),this.reset(!0)}function F(e){if(e||""===e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,i=function r(){for(;++o=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),l=n.call(a,"finallyLoc");if(u&&l){if(this.prev=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),C(r),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;C(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:F(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),v}},e}function _(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return E(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?E(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}function E(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r0&&void 0!==arguments[0]?arguments[0]:{bbMediaContainer:"data-bb-cms-autocomplete",choiceName:"data-bb-cms-choice-name",choiceValue:"data-bb-cms-choice-value",criteriaType:"data-bb-cms-criteria-type",criteriaName:"data-bb-cms-criteria-name",editUrl:"data-bb-cms-load-edit-url",nameMessage:"data-bb-cms-name-message",deleteButton:"data-bb-cms-delete-selected",choosenPreview:"data-bb-cms-selected-image",selectMenu:"data-bb-cms-selection-menu",selectInput:"data-bb-cms-image-select",placeholder:"data-bb-cms-placeholder",limit:30};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.config=e,this.mediaContainers=document.querySelectorAll("[".concat(e.bbMediaContainer,"]")),this.deleteButton="[".concat(e.deleteButton,"]"),this.selectMenu="[".concat(e.selectMenu,"]"),this.selectInput="[".concat(e.selectInput,"]"),this.placeholder="[".concat(e.placeholder,"]")},e=[{key:"init",value:function(){var t=this;if("object"!==k(this.config))throw new Error("Bitbag CMS Plugin - HandleAutoComplete class config is not a valid object");this.mediaContainers.forEach((function(e){t._handleSavedValue(e),t._handleImageChoice(e),t._handleResetBtn(e)}))}},{key:"_handleResetBtn",value:function(t){var e=this,r=t.querySelector(this.deleteButton);""!==t.querySelector("input[type=hidden]").value?(r.classList.remove("is-hidden"),r.addEventListener("click",(function(){e._resetValues(t)}))):r.classList.add("is-hidden")}},{key:"_handleImageChoice",value:function(t){var e,r=this;t.querySelector(this.selectInput).addEventListener("click",(function(e){e.preventDefault(),r._getMediaImages(t)})),t.querySelector(this.selectInput).addEventListener("input",(function(n){n.preventDefault(),clearTimeout(e),e=setTimeout((function(){r._getMediaImages(t,n.target.value)}),500)})),t.querySelector("input[type=hidden]").addEventListener("change",(function(e){e.preventDefault(),r._handleResetBtn(t)}))}},{key:"_handleSavedValue",value:(o=x(S().mark((function t(e){var r,n,o,a,c,u,l;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(""!==e.querySelector("input[type=hidden]").value){t.next=2;break}return t.abrupt("return");case 2:return r="".concat(e.dataset.bbCmsLoadEditUrl,"?").concat(e.querySelector("input[type=hidden]").value.split(",").filter(String).map((function(t){return"code[]=".concat(t)})).join("&")),t.prev=3,i(e,"cms.media.saved.reload.start"),e.classList.add("loading"),t.next=8,fetch(r);case 8:return n=t.sent,t.next=11,n.json();case 11:o=t.sent,this._addToSelectMenu(o,e),a=[],null!==(c=e.querySelector(this.selectMenu))&&(a=c.children),u=_(a);try{for(u.s();!(l=u.n()).done;)l.value.click()}catch(t){u.e(t)}finally{u.f()}i(e,"cms.media.saved.reload.completed",o),t.next=25;break;case 21:t.prev=21,t.t0=t.catch(3),console.error("BitBag CMS Plugin - HandleAutoComplete class error : ".concat(t.t0)),i(e,"cms.media.saved.reload.error",t.t0);case 25:return t.prev=25,e.classList.remove("loading"),i(e,"cms.media.saved.reload.end"),t.finish(25);case 29:case"end":return t.stop()}}),t,this,[[3,21,25,29]])}))),function(t){return o.apply(this,arguments)})},{key:"_getMediaImages",value:(n=x(S().mark((function t(e){var r,n,o,a,c,u,l,s,f=arguments;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=f.length>1&&void 0!==f[1]&&f[1],n=e.dataset.bbCmsUrl,o=e.dataset.bbCmsCriteriaType,a=r?"&criteria[search][value]=".concat(r):"",c="".concat(n,"&limit=").concat(this.config.limit,"&criteria[search][type]=").concat(o,"&criteria[search][value]=").concat(a),t.prev=5,i(e,"cms.media.display.start"),e.classList.add("loading"),t.next=10,fetch(c);case 10:return u=t.sent,t.next=13,u.json();case 13:l=t.sent,s=l._embedded.items,this._addToSelectMenu(s,e),i(e,"cms.media.display.completed",l),t.next=23;break;case 19:t.prev=19,t.t0=t.catch(5),console.error("BitBag CMS Plugin - HandleAutoComplete class error : ".concat(t.t0)),i(e,"cms.media.display.error",t.t0);case 23:return t.prev=23,e.classList.remove("loading"),i(e,"cms.media.display.end"),t.finish(23);case 27:case"end":return t.stop()}}),t,this,[[5,19,23,27]])}))),function(t){return n.apply(this,arguments)})},{key:"_resetValues",value:function(t){i(t,"cms.media.reset.start"),t.querySelector("input[type=hidden]").value="",t.querySelector(this.selectMenu).innerHTML="",t.querySelector(this.placeholder).innerHTML="",i(t,"cms.media.reset.end")}},{key:"_addToSelectMenu",value:function(t,e){var r=this;i(e,"cms.media.display.update.start");var n=e.querySelector(this.selectMenu);n.innerHTML="",null!==t&&t.forEach((function(t){n.insertAdjacentHTML("beforeend",r._itemTemplate(t.path,t.code.trim()))})),i(e,"cms.media.display.update.end")}},{key:"_itemTemplate",value:function(t,e){return'
').concat(e,"
")}}],e&&j(t.prototype,e),r&&j(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r,n,o}();function T(t){return T="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},T(t)}function C(t,e){for(var r=0;r0&&(new h).init(),document.querySelectorAll("[data-bb-cms-preview-btn]").length>0&&(new w).init(),document.querySelector('[data-bb-target="cms-handle-autocomplete"]')&&(new P).init(),document.querySelector(".collection-type-items")&&(new F).init(),document.querySelector("[data-bb-cms-load-template]")&&(new N).init()})()})(); \ No newline at end of file diff --git a/src/Resources/public/build/sylius-cms-admin.js.LICENSE.txt b/src/Resources/public/build/sylius-cms-admin.js.LICENSE.txt new file mode 100644 index 000000000..ae386fb79 --- /dev/null +++ b/src/Resources/public/build/sylius-cms-admin.js.LICENSE.txt @@ -0,0 +1 @@ +/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ diff --git a/src/Resources/public/build/sylius-cms-shop.css b/src/Resources/public/build/sylius-cms-shop.css new file mode 100644 index 000000000..fa24c6ec9 --- /dev/null +++ b/src/Resources/public/build/sylius-cms-shop.css @@ -0,0 +1 @@ +.cms-block{margin-bottom:20px}.cms-block img{max-width:100%}.carousel-wrapper{position:relative}.carousel-wrapper .carousel{margin:0 -1em}.carousel-wrapper .carousel-nav .carousel-left{left:30px}.carousel-wrapper .carousel-nav .carousel-right{right:30px}.carousel-wrapper .carousel-nav .carousel-left,.carousel-wrapper .carousel-nav .carousel-right{position:absolute;top:50%;transform:translateY(-50%)}.carousel-wrapper .carousel-item{padding:5px 1em}.teaser__content{margin-top:10px}.teaser__description{margin-top:5px}.teaser__read-more{display:block;margin-top:20px}[class^=cms_content_element__]:not(:last-child){margin-bottom:1rem} \ No newline at end of file diff --git a/src/Resources/public/build/sylius-cms-shop.js b/src/Resources/public/build/sylius-cms-shop.js new file mode 100644 index 000000000..e69de29bb diff --git a/src/Resources/public/js/ckeditor-plugins/dialogs/index.js b/src/Resources/public/js/ckeditor-plugins/dialogs/index.js index f5cbafb3f..130e7450f 100644 --- a/src/Resources/public/js/ckeditor-plugins/dialogs/index.js +++ b/src/Resources/public/js/ckeditor-plugins/dialogs/index.js @@ -1,9 +1,3 @@ -/* - 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 -*/ - let oldValue = null; let phrase = ''; let currentPage = 1; diff --git a/src/Resources/public/js/ckeditor-plugins/image/plugin.js b/src/Resources/public/js/ckeditor-plugins/image/plugin.js index d992f2be3..2dd595991 100644 --- a/src/Resources/public/js/ckeditor-plugins/image/plugin.js +++ b/src/Resources/public/js/ckeditor-plugins/image/plugin.js @@ -1,9 +1,3 @@ -/* - 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 -*/ - CKEDITOR.plugins.add('mediaImage', { icons: 'mediaimage', init(editor) { diff --git a/src/Resources/public/js/ckeditor-plugins/video/plugin.js b/src/Resources/public/js/ckeditor-plugins/video/plugin.js index 3ffce1eea..ab61e9eeb 100644 --- a/src/Resources/public/js/ckeditor-plugins/video/plugin.js +++ b/src/Resources/public/js/ckeditor-plugins/video/plugin.js @@ -1,9 +1,3 @@ -/* - 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 -*/ - CKEDITOR.plugins.add('mediaVideo', { icons: 'mediavideo', init(editor) { diff --git a/src/Resources/translations/messages.cs.yml b/src/Resources/translations/messages.cs.yml index 75b576807..490ff466b 100755 --- a/src/Resources/translations/messages.cs.yml +++ b/src/Resources/translations/messages.cs.yml @@ -1,8 +1,53 @@ -bitbag_sylius_cms_plugin: +sylius_cms: ui: + collections: Kolekce blocks: Bloky + block: Blok pages: Stránky + page: Stránka title: Titul + content_elements: + title: Obsah + type: + textarea: Textarea + single_media: Jediné médium + multiple_media: Více médií + heading: Nadpis + products_carousel: Produkty v karuselu + products_carousel_by_taxon: Produkty v karuselu podle taxonu + taxons_list: Seznam taxonů + products_grid: Produkty v mřížce + products_grid_by_taxon: Produkty v mřížce podle taxonu + pages_collection: Kolekce stránek + spacer: Oddělovač + spacer_height: Výška oddělovače v pixelech + heading_type: Typ nadpisu + template: Šablona prvků obsahu + taxon: Taxon + display_for_products: + label: Zobrazit pro produkty + help: Vyberte produkty, ve kterých se bude tento blok zobrazovat + display_for_products_in_taxons: + label: Zobrazit pro produkty v taxonech + help: Tento blok bude zobrazen pro produkty ve vybraných taxonech. Pouze "Hlavní taxon" je brán v úvahu. + display_for_taxons: + label: Zobrazit pro taxony + help: Vyberte taxony, ve kterých se bude tento blok zobrazovat + manage_block_display: Správa zobrazení bloku + templates: Šablony + template: Šablona + content_templates: Obsahové šablony + new_template: Nová šablona + edit_template: Upravit šablonu + use_page_template: Použít šablonu stránky + use_this_template: Použít tuto šablonu + load_template_confirmation_modal_text: Tato operace vymaže aktuální konfiguraci prvků obsahu. Opravdu si přejete pokračovat? + teaser: + header: Ukázka + title: Název ukázky + content: Obsah ukázky + image: Obrázek ukázky + help: Jedná se o malý náhled stránky. Používá se při vykreslování kolekce stránek. cms: content_management: Obsahový management cms: Obsahový management @@ -19,6 +64,7 @@ bitbag_sylius_cms_plugin: products: Produkty name: Název slug: Slug + meta_title: Meta titul meta_keywords: Meta klíčová slova meta_description: Meta popis content: Obsah diff --git a/src/Resources/translations/messages.cs_CZ.yml b/src/Resources/translations/messages.cs_CZ.yml index 75b576807..490ff466b 100755 --- a/src/Resources/translations/messages.cs_CZ.yml +++ b/src/Resources/translations/messages.cs_CZ.yml @@ -1,8 +1,53 @@ -bitbag_sylius_cms_plugin: +sylius_cms: ui: + collections: Kolekce blocks: Bloky + block: Blok pages: Stránky + page: Stránka title: Titul + content_elements: + title: Obsah + type: + textarea: Textarea + single_media: Jediné médium + multiple_media: Více médií + heading: Nadpis + products_carousel: Produkty v karuselu + products_carousel_by_taxon: Produkty v karuselu podle taxonu + taxons_list: Seznam taxonů + products_grid: Produkty v mřížce + products_grid_by_taxon: Produkty v mřížce podle taxonu + pages_collection: Kolekce stránek + spacer: Oddělovač + spacer_height: Výška oddělovače v pixelech + heading_type: Typ nadpisu + template: Šablona prvků obsahu + taxon: Taxon + display_for_products: + label: Zobrazit pro produkty + help: Vyberte produkty, ve kterých se bude tento blok zobrazovat + display_for_products_in_taxons: + label: Zobrazit pro produkty v taxonech + help: Tento blok bude zobrazen pro produkty ve vybraných taxonech. Pouze "Hlavní taxon" je brán v úvahu. + display_for_taxons: + label: Zobrazit pro taxony + help: Vyberte taxony, ve kterých se bude tento blok zobrazovat + manage_block_display: Správa zobrazení bloku + templates: Šablony + template: Šablona + content_templates: Obsahové šablony + new_template: Nová šablona + edit_template: Upravit šablonu + use_page_template: Použít šablonu stránky + use_this_template: Použít tuto šablonu + load_template_confirmation_modal_text: Tato operace vymaže aktuální konfiguraci prvků obsahu. Opravdu si přejete pokračovat? + teaser: + header: Ukázka + title: Název ukázky + content: Obsah ukázky + image: Obrázek ukázky + help: Jedná se o malý náhled stránky. Používá se při vykreslování kolekce stránek. cms: content_management: Obsahový management cms: Obsahový management @@ -19,6 +64,7 @@ bitbag_sylius_cms_plugin: products: Produkty name: Název slug: Slug + meta_title: Meta titul meta_keywords: Meta klíčová slova meta_description: Meta popis content: Obsah diff --git a/src/Resources/translations/messages.de.yml b/src/Resources/translations/messages.de.yml index 56a44c9f0..d1769c177 100755 --- a/src/Resources/translations/messages.de.yml +++ b/src/Resources/translations/messages.de.yml @@ -1,7 +1,9 @@ -bitbag_sylius_cms_plugin: +sylius_cms: ui: blocks: Blöcke + block: Block pages: Seiten + page: Seite content_management: Inhaltsverwaltung cms: Inhaltsverwaltung enabled: Aktiviert @@ -20,6 +22,7 @@ bitbag_sylius_cms_plugin: empty_name: Leerer Name publish_at: Veröffentlichen am page_will_be_publish_at: Diese Seite wird veröffentlicht am + meta_title: Meta Titel meta_keywords: Meta Stichwörter meta_description: Meta Beschreibung content: Inhalt @@ -28,13 +31,12 @@ bitbag_sylius_cms_plugin: images: Bilder image: Bild link: Link + link_content: Link-Inhalt title: Titel csv_file: CSV-Datei - sections: Sektionen - sections_header: Sektionen - sections_subheader: Verwalte deine Sektionen - faq_subheader: Verwalte häufig gestellte Fragen - frequently_asked_questions: Häufig gestellte Fragen + collections: Sammlungen + collections_header: Sammlungen + collections_subheader: Verwalten Sie Ihre Sammlungen question: Frage answer: Antwort channels: Ausgabekanäle @@ -54,3 +56,45 @@ bitbag_sylius_cms_plugin: import: Importieren successfully_imported: Die Daten wurden importiert. form_was_submitted_with_errors: "Das Formular wurde mit folgenden Fehlern übermittelt:" + content_elements: + title: Inhalt + type: + textarea: Textarea + single_media: Einzelmedium + multiple_media: Mehrere Medien + heading: Überschrift + products_carousel: Produkte im Karussell + products_carousel_by_taxon: Produkte im Karussell nach Taxon + taxons_list: Taxon-Liste + products_grid: Produkte im Raster + products_grid_by_taxon: Produkte im Raster nach Taxon + pages_collection: Seitenkollektion + spacer: Abstandshalter + spacer_height: Höhe des Abstandshalters in Pixeln + heading_type: Überschrift-Typ + template: Inhaltselementvorlage + taxon: Taxon + display_for_products: + label: Display für Produkte + help: Wählen Sie Produkte aus, in denen dieser Block angezeigt wird + display_for_products_in_taxons: + label: Display für Produkte in Taxons + help: Dieser Block wird für Produkte in ausgewählten Taxonen angezeigt. Nur „Haupttaxon“ ist belegt. + display_for_taxons: + label: Display für Taxons + help: Wählen Sie Taxonen aus, in denen dieser Block angezeigt wird + manage_block_display: Blockanzeige verwalten + templates: Vorlagen + template: Vorlage + content_templates: Inhaltsvorlagen + new_template: Neue Vorlage + edit_template: Vorlage bearbeiten + use_page_template: Seitenschablone verwenden + use_this_template: Diese Vorlage verwenden + load_template_confirmation_modal_text: Dieser Vorgang wird die aktuelle Konfiguration der Inhaltselemente löschen. Sind Sie sicher, dass Sie fortfahren möchten? + teaser: + header: Vorschau + title: Vorschau-Titel + content: Vorschau-Inhalt + image: Vorschau-Bild + help: Es ist eine kleine Vorschau der Seite. Sie wird beim Rendern einer Sammlung von Seiten verwendet. diff --git a/src/Resources/translations/messages.en.yml b/src/Resources/translations/messages.en.yml index 55eb6b00e..bd4c1b0c8 100755 --- a/src/Resources/translations/messages.en.yml +++ b/src/Resources/translations/messages.en.yml @@ -1,7 +1,9 @@ -bitbag_sylius_cms_plugin: +sylius_cms: ui: blocks: Blocks + block: Block pages: Pages + page: Page content_management: Content management cms: Content management enabled: Enabled @@ -15,23 +17,21 @@ bitbag_sylius_cms_plugin: name: Name path: Path slug: Slug + meta_title: Meta title meta_keywords: Meta keywords meta_description: Meta description content: Content - faq: FAQ code: Code contents: Contents images: Images image: Image link: Link - faq_header: FAQ - faq_subheader: Manage frequently asked questions - frequently_asked_questions: Frequently asked questions + link_content: Link content 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 @@ -60,3 +60,46 @@ bitbag_sylius_cms_plugin: publish_at: Publish at page_will_be_publish_at: This page will be publish at save_with_original_name: Save with original name + content_elements: + title: Content + type: + textarea: Textarea + single_media: Single media + multiple_media: Multiple media + heading: Heading + products_carousel: Products carousel + products_carousel_by_taxon: Products carousel by Taxon + taxons_list: Taxons list + products_grid: Products grid + products_grid_by_taxon: Products grid by Taxon + pages_collection: Pages collection + spacer: Spacer + spacer_height: Spacer height in pixels + heading_type: Heading type + template: Content elements template + taxon: Taxon + seo: SEO + display_for_products: + label: Display for products + help: Select products in which this block will be displayed + display_for_products_in_taxons: + label: Display for products in taxons + help: This block will be displayed for products in selected taxons. Only "Main Taxon" is taken. + display_for_taxons: + label: Display for taxons + help: Select taxons in which this block will be displayed + manage_block_display: Manage block display + templates: Templates + template: Template + content_templates: Content Templates + new_template: New template + edit_template: Edit template + use_page_template: Use page template + use_this_template: Use this template + load_template_confirmation_modal_text: This operation will erase current content elements configuration. Are you sure you want to proceed? + teaser: + header: Teaser + title: Teaser Title + content: Teaser Content + image: Teaser Image + help: It's a small preview of the page. It is used during rendering a collection of pages. diff --git a/src/Resources/translations/messages.es.yml b/src/Resources/translations/messages.es.yml index 158a2025f..ab7c32b15 100755 --- a/src/Resources/translations/messages.es.yml +++ b/src/Resources/translations/messages.es.yml @@ -1,7 +1,9 @@ -bitbag_sylius_cms_plugin: +sylius_cms: ui: blocks: Bloques + block: Bloque pages: Páginas + page: Página content_management: Gestión de contenido cms: Gestión de contenido enabled: Activo @@ -16,22 +18,62 @@ bitbag_sylius_cms_plugin: page_related_products: Productos relacionados name: Nombre slug: Slug + meta_title: Meta título meta_keywords: Meta keywords meta_description: Meta descripción content: Contenido - faq: Preguntas frecuentes code: Código contents: Contenido images: Imágenes image: Imagen link: Enlace - faq_header: Preguntas frecuentes - faq_subheader: Gestiona tus preguntas frecuentes - frequently_asked_questions: Preguntas frecuentes + link_content: Contenido del enlace 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 + content_elements: + title: Contenido + type: + textarea: Textarea + single_media: Medio único + multiple_media: Múltiples medios + heading: Encabezado + products_carousel: Productos en carrusel + products_carousel_by_taxon: Productos en carrusel por taxón + taxons_list: Lista de taxones + products_grid: Productos en cuadrícula + products_grid_by_taxon: Productos en cuadrícula por taxón + pages_collection: Colección de páginas + spacer: Separador + spacer_height: Altura del separador en píxeles + heading_type: Tipo de encabezado + template: Plantilla de elementos de contenido + taxon: Taxón + display_for_products: + label: Mostrar para productos + help: Seleccione productos en los que se mostrará este bloque + display_for_products_in_taxons: + label: Mostrar para productos en taxones + help: Este bloque se mostrará para productos en los taxones seleccionados. Solo se considera el "Taxón principal". + display_for_taxons: + label: Mostrar para taxones + help: Seleccione taxones en los que se mostrará este bloque + manage_block_display: Administrar visualización de bloques + templates: Plantillas + template: Plantilla + content_templates: Plantillas de contenido + new_template: Nueva plantilla + edit_template: Editar plantilla + use_page_template: Usar plantilla de página + use_this_template: Usar esta plantilla + load_template_confirmation_modal_text: Esta operación borrará la configuración actual de los elementos de contenido. ¿Está seguro de que desea continuar? + teaser: + header: Avance + title: Título del avance + content: Contenido del avance + image: Imagen del avance + help: Es una pequeña vista previa de la página. Se utiliza al renderizar una colección de páginas. diff --git a/src/Resources/translations/messages.fr.yml b/src/Resources/translations/messages.fr.yml index d0a2eeb9d..70d30e9c4 100755 --- a/src/Resources/translations/messages.fr.yml +++ b/src/Resources/translations/messages.fr.yml @@ -1,7 +1,9 @@ -bitbag_sylius_cms_plugin: +sylius_cms: ui: blocks: Blocs + block: Bloc pages: Pages + page: Page content_management: Gestion de contenu cms: Gestion de contenu enabled: Activée @@ -13,23 +15,21 @@ bitbag_sylius_cms_plugin: page_related_products: Produits liés à la page name: Nom slug: Slug + meta_title: Meta Titre meta_keywords: Meta Mots-clés meta_description: Meta Description content: Contenu - faq: FAQ code: Code contents: Contenu images: Images image: Image link: Link - faq_header: FAQ - faq_subheader: Gérer votre FAQ - frequently_asked_questions: Questions fréquentes (FAQ) + link_content: Contenu du lien 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 @@ -53,3 +53,45 @@ bitbag_sylius_cms_plugin: successfully_imported: Les données ont été importées. form_was_submitted_with_errors: "Le formulaire a les erreurs suivantes :" title: Titre + content_elements: + title: Contenu + type: + textarea: Textarea + single_media: Média unique + multiple_media: Médias multiples + heading: En-tête + products_carousel: Produits en carrousel + products_carousel_by_taxon: Produits en carrousel par taxon + taxons_list: Liste de taxons + products_grid: Produits en grille + products_grid_by_taxon: Produits en grille par taxon + pages_collection: Collection de pages + spacer: Espacement + spacer_height: Hauteur de l'espacement en pixels + heading_type: Type d'en-tête + template: Modèle d'éléments de contenu + taxon: Taxon + display_for_products: + label: Afficher pour les produits + help: Ce bloc sera affiché pour les produits sélectionnés + display_for_products_in_taxons: + label: Afficher pour les produits dans les taxons + help: Ce bloc sera affiché pour les produits des taxons sélectionnés. Seul le « taxon principal » est pris en compte. + display_for_taxons: + label: Afficher pour les taxons + help: Ce bloc sera affiché pour les taxons sélectionnés + manage_block_display: Gérer l'affichage du bloc + templates: Modèles + template: Modèle + content_templates: Modèles de contenu + new_template: Nouveau modèle + edit_template: Modifier le modèle + use_page_template: Utiliser le modèle de page + use_this_template: Utiliser ce modèle + load_template_confirmation_modal_text: Cette opération effacera la configuration actuelle des éléments de contenu. Êtes-vous sûr de vouloir continuer ? + teaser: + header: Aperçu + title: Titre de l'aperçu + content: Contenu de l'aperçu + image: Image de l'aperçu + help: Il s'agit d'un petit aperçu de la page. Il est utilisé lors du rendu d'une collection de pages. diff --git a/src/Resources/translations/messages.hr.yml b/src/Resources/translations/messages.hr.yml index c062cb7d0..f3d99745d 100755 --- a/src/Resources/translations/messages.hr.yml +++ b/src/Resources/translations/messages.hr.yml @@ -1,7 +1,9 @@ -bitbag_sylius_cms_plugin: +sylius_cms: ui: blocks: Blokovi + block: Blok pages: Stranice + page: Stranica content_management: Uređivanje sadržaja cms: Uređivanje sadržaja enabled: Omogućeno @@ -16,22 +18,62 @@ bitbag_sylius_cms_plugin: page_related_products: Vezani proizvodi name: Naslov slug: Slug + meta_title: Meta naslov meta_keywords: Meta ključne riječi meta_description: Meta opis content: Sadržaj - faq: FAQ code: Kod contents: Sadržaj images: Slike image: Slika link: Poveznica (link) - faq_header: FAQ - faq_subheader: Uredi često postavljena pitanja - frequently_asked_questions: Često postavljena pitanja + link_content: Sadržaj poveznice (linka) 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 + content_elements: + title: Sadržaj + type: + textarea: Textarea + single_media: Jedan medij + multiple_media: Više medija + heading: Naslov + products_carousel: Proizvodi u karijeslu + products_carousel_by_taxon: Proizvodi u karijeslu po taksonu + taxons_list: Lista taksona + products_grid: Proizvodi u mreži + products_grid_by_taxon: Proizvodi u mreži po taksonu + pages_collection: Kolekcija stranica + spacer: Razmak + spacer_height: Visina razmaka u pikselima + heading_type: Tip naslova + template: Predložak elemenata sadržaja + taxon: Takson + display_for_products: + label: Prikaz za proizvode + help: Ovaj blok će biti prikazan za odabrane proizvode + display_for_products_in_taxons: + label: Prikaz za proizvode u taksonima + help: Ovaj će blok biti prikazan za proizvode u odabranim taksonima. Uzima se samo "Glavni takson". + display_for_taxons: + label: Prikaz za takson + help: Odaberite taksone u kojima će se ovaj blok prikazati + manage_block_display: Upravljanje prikazom bloka + templates: Predlošci + template: Predložak + content_templates: Predloške sadržaja + new_template: Novi predložak + edit_template: Uredi predložak + use_page_template: Koristi predložak stranice + use_this_template: Koristi ovaj predložak + load_template_confirmation_modal_text: Ova operacija će izbrisati trenutnu konfiguraciju elemenata sadržaja. Jeste li sigurni da želite nastaviti? + teaser: + header: Pregled + title: Naslov pregleda + content: Sadržaj pregleda + image: Slika pregleda + help: Ovo je mali pregled stranice. Koristi se prilikom prikazivanja zbirke stranica. diff --git a/src/Resources/translations/messages.lt.yml b/src/Resources/translations/messages.lt.yml index b25ebe8f5..b807a1eb1 100644 --- a/src/Resources/translations/messages.lt.yml +++ b/src/Resources/translations/messages.lt.yml @@ -1,7 +1,9 @@ -bitbag_sylius_cms_plugin: +sylius_cms: ui: blocks: Blokai + block: Blokas pages: Puslapiai + page: Puslapis content_management: Turinio valdymas cms: Turinio valdymas enabled: Įjungta @@ -13,23 +15,21 @@ bitbag_sylius_cms_plugin: page_related_products: Su puslapiu susiję produktai name: Pavadinimas slug: Šliužas (nuorodos dalis) + meta_title: Meta pavadinimas meta_keywords: Meta raktiniai žodžiai meta_description: Meta aprašymas content: Turinys - faq: DUK code: Kodas contents: Turinys images: Paveikslai image: Paveikslas link: Nuoroda - faq_header: DUK - faq_subheader: Dažniausiai užduodamų klausimų tvarkymas - frequently_asked_questions: Dažniausiai užduodami klausimai + link_content: Nuorodos turinys 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 @@ -52,4 +52,45 @@ bitbag_sylius_cms_plugin: csv_file: CSV failas successfully_imported: Duomenys sėkmingai importuoti. form_was_submitted_with_errors: "Forma pateikta su klaidomis:" - + content_elements: + title: Turinys + type: + textarea: Textarea + single_media: Vienas medijos elementas + multiple_media: Kelios medijos elementai + heading: Antraštė + products_carousel: Produktų karuselė + products_carousel_by_taxon: Produktų karuselė pagal taksoną + taxons_list: Taksonų sąrašas + products_grid: Produktų tinklelis + products_grid_by_taxon: Produktų tinklelis pagal taksoną + pages_collection: Puslapių kolekcija + spacer: Tarpo elementas + spacer_height: Tarpo aukštis pikseliais + heading_type: Antraštės tipas + template: Turinio elementų šablonas + taxon: Taksonas + display_for_products: + label: Rodyti produktams + help: Pasirinkite produktus, kuriuose šis blokas bus rodomas + display_for_products_in_taxons: + label: Rodyti produktams + help: Šis blokas bus rodomas produktams pasirinktuose taksonuose. Paimamas tik „Pagrindinis taksonas“. + display_for_taxons: + label: Rodyti taksonams + help: Pasirinkite taksonus, kuriuose šis blokas bus rodomas + manage_block_display: Bloko rodymo valdymas + templates: Šablonai + template: Šablonas + content_templates: Turinys šablonai + new_template: Naujas šablonas + edit_template: Redaguoti šabloną + use_page_template: Naudoti puslapio šabloną + use_this_template: Naudoti šį šabloną + load_template_confirmation_modal_text: Ši operacija ištrins dabartinę turinio elementų konfigūraciją. Ar tikrai norite tęsti? + teaser: + header: Anonsas + title: Anonso pavadinimas + content: Anonso turinys + image: Anonso nuotrauka + help: Tai mažas puslapio peržiūra. Ji naudojama kuriant puslapių kolekciją. diff --git a/src/Resources/translations/messages.nl.yml b/src/Resources/translations/messages.nl.yml index ddb8f49a9..d107e9f92 100755 --- a/src/Resources/translations/messages.nl.yml +++ b/src/Resources/translations/messages.nl.yml @@ -1,7 +1,9 @@ -bitbag_sylius_cms_plugin: +sylius_cms: ui: blocks: Blokken + block: Blok pages: Pagina's + page: Pagina content_management: Beheer inhoud cms: Beheer inhoud enabled: Ingeschakeld @@ -16,21 +18,61 @@ bitbag_sylius_cms_plugin: page_related_products: Pagina gerelateerde producten name: Naam slug: Slug + meta_title: Meta titel meta_keywords: Meta sleutelwoorden meta_description: Meta omschrijving content: Inhoud - faq: Veelgestelde vragen code: Code contents: Inhoud images: Afbeeldingen link: Link - faq_header: Veelgestelde vragen - faq_subheader: Beheer veelgestelde vragen - frequently_asked_questions: Veelgestelde vragen + link_content: Link inhoud 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 + content_elements: + title: Inhoud + type: + textarea: Textarea + single_media: Enkel medium + multiple_media: Meerdere media + heading: Kop + products_carousel: Producten in carrousel + products_carousel_by_taxon: Producten in carrousel per taxon + taxons_list: Taxon lijst + products_grid: Producten grid + products_grid_by_taxon: Producten grid per taxon + pages_collection: Pagina collectie + spacer: Afstandhouder + spacer_height: Hoogte van de afstandhouder in pixels + heading_type: Kop type + template: Sjabloon voor inhoudselementen + taxon: Taxon + display_for_products: + label: Display voor producten + help: Selecteer producten waarin dit blok wordt weergegeven + display_for_products_in_taxons: + label: Display voor producten in taxons + help: Dit blok wordt weergegeven voor producten in geselecteerde taxonen. Alleen "Hoofdtaxon" wordt gebruikt. + display_for_taxons: + label: Display voor taxons + help: Selecteer taxonen waarin dit blok wordt weergegeven + manage_block_display: Beheer blok weergave + templates: Sjablonen + template: Sjabloon + content_templates: Inhoudsjablonen + new_template: Nieuwe sjabloon + edit_template: Sjabloon bewerken + use_page_template: Sjabloon voor pagina gebruiken + use_this_template: Deze sjabloon gebruiken + load_template_confirmation_modal_text: Deze actie zal de huidige configuratie van inhoudselementen wissen. Weet je zeker dat je verder wilt gaan? + teaser: + header: Voorbeeld + title: Voorbeeldtitel + content: Voorbeeldinhoud + image: Voorbeeldafbeelding + help: Dit is een kleine preview van de pagina. Het wordt gebruikt bij het renderen van een verzameling pagina's. diff --git a/src/Resources/translations/messages.pl.yml b/src/Resources/translations/messages.pl.yml index 9c3f34761..95fd26351 100755 --- a/src/Resources/translations/messages.pl.yml +++ b/src/Resources/translations/messages.pl.yml @@ -1,7 +1,9 @@ -bitbag_sylius_cms_plugin: +sylius_cms: ui: blocks: Bloki + block: Blok pages: Strony + page: Strona content_management: Zarządzanie treścią cms: Zarządzanie treścią enabled: Włączony @@ -16,26 +18,66 @@ bitbag_sylius_cms_plugin: page_related_products: Produkty powiązane ze stroną name: Nazwa slug: Link + meta_title: Tytuł meta meta_keywords: Słowa kluczowe meta_description: Opis sekcji meta content: Treść - faq: FAQ code: Kod contents: Treść images: Zdjęcia image: Zdjęcie link: Link - faq_header: FAQ - faq_subheader: Zarządzaj najczęściej zadawanymi pytaniami - frequently_asked_questions: Najczęściej zadawane pytania + link_content: Treść linka 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 publish_at: Opublikuj page_will_be_publish_at: Strona zostanie opublikowana save_with_original_name: Zapisz z oryginalną nazwą + content_elements: + title: Treść + type: + textarea: Textarea + single_media: Pojedyncze media + multiple_media: Wiele mediów + heading: Nagłówek + products_carousel: Karuzela produktów + products_carousel_by_taxon: Karuzela produktów według taksonomii + taxons_list: Lista taksonomii + products_grid: Siatka produktów + products_grid_by_taxon: Siatka produktów według taksonomii + pages_collection: Kolekcja stron + spacer: Odstęp + spacer_height: Wysokość odstępu w pikselach + heading_type: Typ nagłówka + template: Szablon elementów treści + taxon: Taksonomia + display_for_products: + label: Wyświetlaj dla produktów + help: Wybierz produkty, dla których ten blok będzie wyświetlany + display_for_products_in_taxons: + label: Wyświetlaj dla produktów w taksonomiach + help: Ten blok będzie wyświetlany dla produktów w wybranych taksonomiach. Tylko "Główna taksonomia" jest brana pod uwagę. + display_for_taxons: + label: Wyświetlaj dla taksonomii + help: Wybież taksonomie, dla których ten blok będzie wyświetlany + manage_block_display: Zarządzaj wyświetlaniem bloku + templates: Szablony + template: Szablon + content_templates: Szablony treści + new_template: Nowy szablon + edit_template: Edytuj szablon + use_page_template: Użyj szablonu strony + use_this_template: Użyj tego szablonu + load_template_confirmation_modal_text: Ta operacja spowoduje usunięcie bieżącej konfiguracji elementów zawartości. Czy na pewno chcesz kontynuować? + teaser: + header: Zapowiedź + title: Tytuł zapowiedzi + content: Treść zapowiedzi + image: Obrazek zapowiedzi + help: To mały podgląd strony. Używa się go podczas renderowania kolekcji stron. diff --git a/src/Resources/translations/messages.ru.yml b/src/Resources/translations/messages.ru.yml index 3459c5620..db928bf82 100755 --- a/src/Resources/translations/messages.ru.yml +++ b/src/Resources/translations/messages.ru.yml @@ -1,7 +1,9 @@ -bitbag_sylius_cms_plugin: +sylius_cms: ui: blocks: Блоки + block: Блок pages: Страницы + page: Страница content_management: Наполнение cms: Управление наполнением enabled: Вкл @@ -13,23 +15,21 @@ bitbag_sylius_cms_plugin: page_related_products: Cопутствующие товары name: Имя slug: Путь + meta_title: Заголовок (мета) meta_keywords: Ключевые слова (мета) meta_description: Описание (мета) content: Содержимое - faq: FAQ code: Код contents: Содержит images: Изображения image: Изображение link: Ссылка - faq_header: FAQ - faq_subheader: Управление часто задаваемыми вопросами - frequently_asked_questions: Часто задаваемые вопросы + link_content: Содержимое ссылки question: Вопрос answer: Ответ - sections: Разделы - sections_header: Разделы - sections_subheader: Управление разделами + collections: Коллекции + collections_header: Коллекции + collections_subheader: Управляйте своими коллекциями position: Позиция channels: Каналы preview: Предпросмотр @@ -52,3 +52,45 @@ bitbag_sylius_cms_plugin: csv_file: CSV файл successfully_imported: Данные успешно импортированы title: заглавие + content_elements: + title: Содержание + type: + textarea: Textarea + single_media: Одиночный медиа + multiple_media: Несколько медиа + heading: Заголовок + products_carousel: Продукты в карусели + products_carousel_by_taxon: Продукты в карусели по таксону + taxons_list: Список таксонов + products_grid: Продукты в сетке + products_grid_by_taxon: Продукты в сетке по таксону + pages_collection: Коллекция страниц + spacer: Пробел + spacer_height: Высота пробела в пикселях + heading_type: Тип заголовка + template: Шаблон элементов контента + taxon: Таксон + display_for_products: + label: Отображать для товаров + help: Выберите товары, для которых этот блок будет отображаться + display_for_products_in_taxons: + label: Отображать для товаров в таксономиях + help: Этот блок будет отображаться для товаров в выбранных таксонах. Берется только «Основной таксон». + display_for_taxons: + label: Отображать для таксонов + help: Выберите таксоны, в которых будет отображаться этот блок + manage_block_display: Управление отображением блоков + templates: Шаблоны + template: Шаблон + content_templates: Шаблоны контента + new_template: Новый шаблон + edit_template: Редактировать шаблон + use_page_template: Использовать шаблон страницы + use_this_template: Использовать этот шаблон + load_template_confirmation_modal_text: Эта операция удалит текущую конфигурацию элементов контента. Вы уверены, что хотите продолжить? + teaser: + header: Анонс + title: Заголовок анонса + content: Содержание анонса + image: Изображение анонса + help: Это небольшой предварительный просмотр страницы. Он используется при отображении коллекции страниц. diff --git a/src/Resources/translations/messages.sk.yml b/src/Resources/translations/messages.sk.yml index 3d6de1ee8..57902b86c 100644 --- a/src/Resources/translations/messages.sk.yml +++ b/src/Resources/translations/messages.sk.yml @@ -1,7 +1,9 @@ -bitbag_sylius_cms_plugin: +sylius_cms: ui: blocks: Bloky + block: Blok pages: Stránky + page: Stránka content_management: Správa obsahu cms: Správa obsahu enabled: Aktívny @@ -13,23 +15,21 @@ bitbag_sylius_cms_plugin: page_related_products: Produkty relevantné ku stránke name: Meno slug: Slug + meta_title: Meta titulok meta_keywords: Meta keywords meta_description: Meta description content: Obsah - faq: FAQ code: Kód contents: Obsah images: Obrázky image: Obrázok link: Odkaz - faq_header: FAQ - faq_subheader: Spravujte vaše časté otázky - frequently_asked_questions: Časté otázky + link_content: Obsah odkazu 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 @@ -53,3 +53,45 @@ bitbag_sylius_cms_plugin: successfully_imported: Dáta boli naimportované form_was_submitted_with_errors: "Formulár obsahuje nasledovné chyby:" title: Titulok + content_elements: + title: Obsah + type: + textarea: Textarea + single_media: Jedno médium + multiple_media: Viacero médií + heading: Nadpis + products_carousel: Produkty v karuseli + products_carousel_by_taxon: Produkty v karuseli podľa taxónu + taxons_list: Zoznam taxónov + products_grid: Produkty v mriežke + products_grid_by_taxon: Produkty v mriežke podľa taxónu + pages_collection: Kolekcia strán + spacer: Medzera + spacer_height: Výška medzery v pixeloch + heading_type: Typ nadpisu + template: Šablóna prvkov obsahu + taxon: Taxón + display_for_products: + label: Zobraziť pre produkty + help: Tento blok bude zobrazený pre vybrané produkty + display_for_products_in_taxons: + label: Zobraziť pre produkty v taxónoch + help: Tento blok sa zobrazí pri produktoch vo vybraných taxónoch. Zaberie sa iba „hlavný taxón“. + display_for_taxons: + label: Zobrazenie pre taxóny + help: Vyberte taxóny, v ktorých sa tento blok zobrazí + manage_block_display: Spravovať zobrazenie bloku + templates: Šablóny + template: Šablóna + content_templates: Šablóny obsahu + new_template: Nová šablóna + edit_template: Upraviť šablónu + use_page_template: Použiť šablónu stránky + use_this_template: Použiť túto šablónu + load_template_confirmation_modal_text: Táto operácia vymaže aktuálnu konfiguráciu prvkov obsahu. Ste si istí, že chcete pokračovať? + teaser: + header: Ukážka + title: Názov ukážky + content: Obsah ukážky + image: Obrázok ukážky + help: Toto je malý náhľad stránky. Používa sa pri vykresľovaní zbierky stránok. diff --git a/src/Resources/translations/messages.uk.yml b/src/Resources/translations/messages.uk.yml index 89fb0c878..3d3391794 100755 --- a/src/Resources/translations/messages.uk.yml +++ b/src/Resources/translations/messages.uk.yml @@ -1,7 +1,9 @@ -bitbag_sylius_cms_plugin: +sylius_cms: ui: blocks: Блоки + block: Блок pages: Сторінки + page: Сторінка content_management: Наповнення cms: Управління Наповненням enabled: Вкл @@ -13,23 +15,21 @@ bitbag_sylius_cms_plugin: page_related_products: Супутні товари name: Назва slug: Шлях + meta_title: Заголовок (мета) meta_keywords: Ключові слова (мета) meta_description: Опис (мета) content: Вміст - faq: FAQ code: Код contents: Містить images: Зображення image: Зображення link: Посилання - faq_header: FAQ - faq_subheader: Управління FAQ - frequently_asked_questions: FAQ + link_content: Вміст посилання question: Питання answer: Відповідь - sections: Розділи - sections_header: Розділи - sections_subheader: Управління розділами + collections: Колекції + collections_header: Колекції + collections_subheader: Керуйте своїми колекціями position: Позиція channels: Канали preview: Попередній перегляд @@ -52,3 +52,45 @@ bitbag_sylius_cms_plugin: csv_file: CSV файл successfully_imported: Дані успішно імпортовані title: заголовок + content_elements: + title: Зміст + type: + textarea: Textarea + single_media: Одиночне медіа + multiple_media: Кілька медіа + heading: Заголовок + products_carousel: Продукти в каруселі + products_carousel_by_taxon: Продукти в каруселі за таксоном + taxons_list: Список таксонів + products_grid: Продукти в сітці + products_grid_by_taxon: Продукти в сітці за таксоном + pages_collection: Колекція сторінок + spacer: Роздільник + spacer_height: Висота роздільника в пікселях + heading_type: Тип заголовка + template: Шаблон елементів контенту + taxon: Таксон + display_for_products: + label: Дисплей для продуктів + help: Цей блок буде відображатися для вибраних продуктів + display_for_products_in_taxons: + label: Дисплей для таксонів + help: Цей блок відображатиметься для продуктів у вибраних таксонах. Береться лише «Основний таксон». + display_for_taxons: + label: Дисплей для таксонів + help: Виберіть таксони, в яких буде відображатися цей блок + manage_block_display: Керування відображенням блоку + templates: Шаблони + template: Шаблон + content_templates: Шаблони контенту + new_template: Новий шаблон + edit_template: Редагувати шаблон + use_page_template: Використовувати шаблон сторінки + use_this_template: Використовувати цей шаблон + load_template_confirmation_modal_text: Ця операція видалить поточну конфігурацію елементів контенту. Ви впевнені, що хочете продовжити? + teaser: + header: Анонс + title: Заголовок анонсу + content: Контент анонсу + image: Зображення анонсу + help: Це невеликий попередній перегляд сторінки. Використовується при рендерингу колекції сторінок. diff --git a/src/Resources/translations/validators.cs.yml b/src/Resources/translations/validators.cs.yml index 97165ce72..874a9aa40 100644 --- a/src/Resources/translations/validators.cs.yml +++ b/src/Resources/translations/validators.cs.yml @@ -1,4 +1,4 @@ -bitbag_sylius_cms_plugin: +sylius_cms: block: image: mime_types: Pouze PNG, SVG a JPEG soubory jsou povoleny. @@ -43,25 +43,9 @@ bitbag_sylius_cms_plugin: content: not_blank: Obsah nemůže být prázdný. min_length: Obsah musí mít alespoň {{ limit }} znaků. - frequently_asked_question: + collection: code: - unique: S tímto kódem již existují často kladené dotazy. - 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ů. - regex: Kód se může skládat pouze z písmen, číslic, pomlček a podtržítek. - position: - unique: Na této pozici již existují často kladené dotazy. - not_blank: Pozice nemůže být prázdná. - question: - not_blank: Otázka nemůže být prázdná. - min_length: Otázka musí mít alespoň {{ limit }} znaků. - answer: - not_blank: Odpověď nemůže být prázdná. - min_length: Odpověď musí obsahovat alespoň {{ limit }} znaků. - section: - 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ů. @@ -96,3 +80,9 @@ bitbag_sylius_cms_plugin: import: not_blank: Importovaný soubor nemůže být prázdný. invalid_format: Nahrajte platný CSV soubor pro import. + template: + name: + unique: Šablona s tímto názvem již existuje. + not_blank: Název nesmí být prázdný. + min_length: Název musí mít alespoň {{ limit }} znaků. + max_length: Název nesmí být delší než {{ limit }} znaků. diff --git a/src/Resources/translations/validators.de.yml b/src/Resources/translations/validators.de.yml index 967c98501..1174bffb7 100755 --- a/src/Resources/translations/validators.de.yml +++ b/src/Resources/translations/validators.de.yml @@ -1,4 +1,4 @@ -bitbag_sylius_cms_plugin: +sylius_cms: block: image: mime_types: Nur PNG, SVG und JPEG Dateien sind erlaubt. @@ -35,3 +35,9 @@ bitbag_sylius_cms_plugin: content: not_blank: Inhalt darf nicht leer sein. min_length: Inhalt muss mindestens {{ limit }} Zeichen lang sein. + template: + name: + unique: Es gibt bereits eine Vorlage mit diesem Namen. + not_blank: Der Name darf nicht leer sein. + min_length: Der Name muss mindestens {{ limit }} Zeichen lang sein. + max_length: Der Name darf nicht länger als {{ limit }} Zeichen sein. diff --git a/src/Resources/translations/validators.en.yml b/src/Resources/translations/validators.en.yml index a182eada3..34b174ba3 100755 --- a/src/Resources/translations/validators.en.yml +++ b/src/Resources/translations/validators.en.yml @@ -1,4 +1,4 @@ -bitbag_sylius_cms_plugin: +sylius_cms: block: image: mime_types: Only PNG, SVG and JPEG files are allowed. @@ -43,29 +43,13 @@ bitbag_sylius_cms_plugin: content: not_blank: Content cannot be blank. min_length: Content must be at least {{ limit }} characters long. - frequently_asked_question: + collection: code: - unique: There is an existing FAQ 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: Code can only be comprised of letters, numbers, dashes and underscores. - position: - unique: There is an existing FAQ with this position. - not_blank: Position cannot be blank. - question: - not_blank: Question cannot be blank. - min_length: Question must be at least {{ limit }} characters long. - answer: - not_blank: Answer cannot be blank. - min_length: Answer must be at least {{ limit }} characters long. - section: - code: - unique: There is an existing section 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. @@ -96,3 +80,9 @@ bitbag_sylius_cms_plugin: import: not_blank: Import file cannot be blank. invalid_format: Upload a valid CSV import file. + template: + name: + unique: There is an existing template with this name. + not_blank: Name cannot be blank. + min_length: Name must be at least {{ limit }} characters long. + max_length: Name can not be longer than {{ limit }} characters. diff --git a/src/Resources/translations/validators.es.yml b/src/Resources/translations/validators.es.yml index 76f0ece39..99682d19a 100755 --- a/src/Resources/translations/validators.es.yml +++ b/src/Resources/translations/validators.es.yml @@ -1,4 +1,4 @@ -bitbag_sylius_cms_plugin: +sylius_cms: block: image: mime_types: Solo se permiten archivos PNG, SVG y JPEG. @@ -37,24 +37,9 @@ bitbag_sylius_cms_plugin: content: not_blank: El contenido no puede ir vacío. min_length: El contenido debe tener al menos {{ limit }} caracteres. - frequently_asked_question: + collection: code: - unique: Ya existe una pregunta 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. - position: - unique: Ya existe una pregunta con esta posición. - not_blank: La posición no puede ir vacía. - question: - not_blank: La pregunta no puede ir vacía. - min_length: La pregunta debe tener al menos {{ limit }} caracteres. - answer: - not_blank: La respuesta no puede ir vacía. - min_length: La respuesta debe tener al menos {{ limit }} caracteres. - section: - 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. @@ -62,3 +47,9 @@ bitbag_sylius_cms_plugin: not_blank: El nombre no puede ir vacío. min_length: El nombre debe tener al menos {{ limit }} caracteres. max_length: El nombre no puede tener más de {{ limit }} caracteres. + template: + name: + unique: Ya existe una plantilla con este nombre. + not_blank: El nombre no puede estar en blanco. + min_length: El nombre debe tener al menos {{ limit }} caracteres. + max_length: El nombre 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..d28c80914 100755 --- a/src/Resources/translations/validators.fr.yml +++ b/src/Resources/translations/validators.fr.yml @@ -1,4 +1,4 @@ -bitbag_sylius_cms_plugin: +sylius_cms: block: image: mime_types: Seuls les fichiers PNG, SVG et JPEG sont autorisés. @@ -41,24 +41,9 @@ bitbag_sylius_cms_plugin: content: not_blank: Le contenu ne peut pas être vide. min_length: Le contenu doit faire au moins {{ limit }} caractères. - frequently_asked_question: + collection: code: - unique: Il existe déjà une FAQ 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. - position: - unique: Il existe déjà une FAQ avec ce code. - not_blank: La position ne peut pas être vide. - question: - not_blank: La question ne peut pas être vide. - min_length: La question doit faire au moins {{ limit }} caractères. - answer: - not_blank: La réponse ne peut pas être vide. - min_length: La réponse doit faire au moins {{ limit }} caractères. - section: - 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. @@ -89,3 +74,9 @@ bitbag_sylius_cms_plugin: import: not_blank: Le fichier à importer ne peut pas être vide. invalid_format: Ceci n'est pas un fichier CSV valide. + template: + name: + unique: Il existe déjà un modèle avec ce nom. + not_blank: Le nom ne peut pas être vide. + min_length: Le nom doit comporter au moins {{ limit }} caractères. + max_length: Le nom 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..cab29c8da 100755 --- a/src/Resources/translations/validators.hr.yml +++ b/src/Resources/translations/validators.hr.yml @@ -1,4 +1,4 @@ -bitbag_sylius_cms_plugin: +sylius_cms: block: image: mime_types: Samo su PNG, SVG ili JPG formati dopušteni. @@ -37,24 +37,9 @@ bitbag_sylius_cms_plugin: content: not_blank: Sadržaj ne može biti prazan. min_length: Sadržaj mora sadržavati minimlano {{ limit }} znakova. - frequently_asked_question: + collection: code: - unique: Postoji FAQ 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. - position: - unique: Postoji FAQ sa istom pozicijom. - not_blank: Pozicija ne može biti prazna. - question: - not_blank: Pitanje ne može biti prazno. - min_length: Pitanje mora sadržavati minimalno {{ limit }} znaka. - answer: - not_blank: Odgovor ne može biti prazan. - min_length: Odgovor mora sadržavati minimalno {{ limit }} znaka. - section: - 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. @@ -62,3 +47,9 @@ bitbag_sylius_cms_plugin: not_blank: Naziv ne može biti prazan. min_length: Naziv mora sadržavati minimalno {{ limit }} znaka. max_length: Naziv mora biti duži od {{ limit }} znakova. + template: + name: + unique: Već postoji predložak s tim imenom. + not_blank: Ime ne može biti prazno. + min_length: Ime mora biti dugo najmanje {{ limit }} znakova. + max_length: Ime ne smije biti duže od {{ limit }} znakova. diff --git a/src/Resources/translations/validators.lt.yml b/src/Resources/translations/validators.lt.yml index af148ddfe..fb91f3259 100644 --- a/src/Resources/translations/validators.lt.yml +++ b/src/Resources/translations/validators.lt.yml @@ -1,4 +1,4 @@ -bitbag_sylius_cms_plugin: +sylius_cms: block: image: mime_types: Leidžiami tik PNG ir JPEG formatų failai. @@ -41,24 +41,9 @@ bitbag_sylius_cms_plugin: content: not_blank: Turinį įvesti privaloma. min_length: Turinio ilgis turi būti bent {{ limit }} simb. - frequently_asked_question: + collection: code: - unique: DUK įrašas su tokiu kodu jau egzistuoja. - 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. - position: - unique: DUK įrašas su tokia pozicija jau egzistuoja. - not_blank: Poziciją įvesti privaloma. - question: - not_blank: Klausimą įvesti privaloma. - min_length: Klausimo ilgis turi būti bent {{ limit }} simb. - answer: - not_blank: Atsakymą įvesti privaloma. - min_length: Atsakymo ilgis turi būti bent {{ limit }} simb. - section: - 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. @@ -89,4 +74,9 @@ bitbag_sylius_cms_plugin: import: not_blank: Importuojamą failą pasirinkti privaloma. invalid_format: Įkeltas netinkamas failas. Pasirinkite CSV formato failą. - + template: + name: + unique: Šablonas su šiuo pavadinimu jau egzistuoja. + not_blank: Pavadinimas negali būti tuščias. + min_length: Pavadinimas turi būti ne trumpesnis kaip {{ limit }} simboliai. + max_length: Pavadinimas negali būti ilgesnis nei {{ limit }} simboliai. diff --git a/src/Resources/translations/validators.nl.yml b/src/Resources/translations/validators.nl.yml index 43919988a..d12575455 100755 --- a/src/Resources/translations/validators.nl.yml +++ b/src/Resources/translations/validators.nl.yml @@ -1,4 +1,4 @@ -bitbag_sylius_cms_plugin: +sylius_cms: block: image: mime_types: Alleen PNG, SVG en JPEG bestanden zijn toegestaan. @@ -37,24 +37,9 @@ bitbag_sylius_cms_plugin: content: not_blank: Inhoud is verplicht en mag niet leeg zijn. min_length: Inhoud moet minstens {{ limit }} tekens lang zijn. - frequently_asked_question: + collection: code: - unique: Er bestaat al een veelgestelde vraag 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. - position: - unique: Er bestaat al een veelgestelde vraag met deze positie. - not_blank: Positie is verplicht en mag niet leeg zijn. - question: - not_blank: Vraag is verplicht en mag niet leeg zijn. - min_length: Vraag oet minstens {{ limit }} tekens lang zijn. - answer: - not_blank: Antwoord is verplicht en mag niet leeg zijn. - min_length: Antwoord moet minstens {{ limit }} tekens lang zijn. - section: - 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. @@ -62,3 +47,9 @@ bitbag_sylius_cms_plugin: not_blank: Naam is verplicht en mag niet leeg zijn. min_length: Naam moet minstens {{ limit }} tekens lang zijn. max_length: Naam mag niet langer zijn dan {{ limit }} tekens. + template: + name: + unique: Er bestaat al een sjabloon met deze naam. + not_blank: De naam mag niet leeg zijn. + min_length: De naam moet minimaal {{ limit }} tekens lang zijn. + max_length: De naam 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..e27a4c7b3 100755 --- a/src/Resources/translations/validators.pl.yml +++ b/src/Resources/translations/validators.pl.yml @@ -1,4 +1,4 @@ -bitbag_sylius_cms_plugin: +sylius_cms: block: image: mime_types: Only PNG, SVG and JPEG files are allowed. @@ -37,22 +37,7 @@ bitbag_sylius_cms_plugin: content: not_blank: Content cannot be blank. min_length: Content must be at least {{ limit }} characters long. - frequently_asked_question: - code: - unique: There is an existing FAQ 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. - position: - unique: There is an existing FAQ with this position. - not_blank: Position cannot be blank. - question: - not_blank: Question cannot be blank. - min_length: Question must be at least {{ limit }} characters long. - 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. @@ -66,3 +51,9 @@ bitbag_sylius_cms_plugin: file: type_image: Przesłanego pliku nie można oznaczyć jako obraz. type_video: Przesłanego pliku nie można oznaczyć jako wideo. + template: + name: + unique: Istnieje już szablon o tej nazwie. + not_blank: Nazwa nie może być pusta. + min_length: Nazwa musi mieć co najmniej {{ limit }} znaków. + max_length: Nazwa nie może mieć więcej niż {{ limit }} znaków. diff --git a/src/Resources/translations/validators.ru.yml b/src/Resources/translations/validators.ru.yml index 60a297340..8b71515b4 100755 --- a/src/Resources/translations/validators.ru.yml +++ b/src/Resources/translations/validators.ru.yml @@ -1,4 +1,4 @@ -bitbag_sylius_cms_plugin: +sylius_cms: block: image: mime_types: Только PNG, SVG или JPEG. @@ -37,24 +37,9 @@ bitbag_sylius_cms_plugin: content: not_blank: Содержимое не может быть пустым. min_length: Содержимое должно быть длиной хотя бы {{ limit }} знаков. - frequently_asked_question: + collection: code: - unique: FAQ с таким кодом уже существует. - not_blank: Код не может быть пустым. - min_length: Код должен быть длиной хотя бы {{ limit }} знаков. - max_length: Код не может быть длиннее {{ limit }} знаков. - position: - unique: FAQ с такой позицией уже существет. - not_blank: Позиция не может быть пустой. - question: - not_blank: Вопрос не может быть пустым. - min_length: Вопрос должен быть длиной хотя бы {{ limit }} знаков. - answer: - not_blank: Ответ не может быть пустым. - min_length: Ответ должен быть длиной хотя бы {{ limit }} знаков. - section: - code: - unique: Раздел с таким кодом уже существет. + unique: Существует существующая коллекция с этим кодом. not_blank: Код не может быть пустым. min_length: Код должен быть длиной хотя бы {{ limit }} знаков. max_length: Код не может быть длиннее {{ limit }} знаков. @@ -82,3 +67,9 @@ bitbag_sylius_cms_plugin: import: not_blank: Импортируемый файл не может быть пустым. invalid_format: Загрузите файл в формате CSV. + template: + name: + 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..1aff25712 100755 --- a/src/Resources/translations/validators.sk.yml +++ b/src/Resources/translations/validators.sk.yml @@ -1,4 +1,4 @@ -bitbag_sylius_cms_plugin: +sylius_cms: block: image: mime_types: Iba PNG, SVG a JPEG súbory sú povolené. @@ -41,24 +41,9 @@ bitbag_sylius_cms_plugin: content: not_blank: Obsah nesmie byť prázdny. min_length: Obsah musí mať najmenej {{ limit }} znakov. - frequently_asked_question: + collection: code: - unique: FAQ 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. - position: - unique: FAQ s touto pozíciou už existuje. - not_blank: Pozícia nesmie byť prázdna. - question: - not_blank: Otázka nesmie byť prázdna. - min_length: Otázka musí mať najmenej {{ limit }} znakov. - answer: - not_blank: Odpoveď nesmie byť prázdna. - min_length: Odpoveď musí mať najmenej {{ limit }} znakov. - section: - 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. @@ -89,3 +74,9 @@ bitbag_sylius_cms_plugin: import: not_blank: Importovaný súbor nesmie byť prázdny. invalid_format: Súbor nemá platný CSV formát. + template: + name: + unique: Už existuje šablóna s týmto názvom. + not_blank: Názov nemôže byť prázdny. + min_length: Názov musí mať aspoň {{ limit }} znakov. + max_length: Názov nesmie byť dlhší ako {{ limit }} znakov. diff --git a/src/Resources/translations/validators.uk.yml b/src/Resources/translations/validators.uk.yml index 7502d94e7..b106ad07a 100755 --- a/src/Resources/translations/validators.uk.yml +++ b/src/Resources/translations/validators.uk.yml @@ -1,4 +1,4 @@ -bitbag_sylius_cms_plugin: +sylius_cms: block: image: mime_types: Тільки PNG, SVG чи JPEG. @@ -37,24 +37,9 @@ bitbag_sylius_cms_plugin: content: not_blank: Вміст не може бути порожнім. min_length: Вміст має бути довжиною хоча б {{ limit }} знаків. - frequently_asked_question: + collection: code: - unique: FAQ з таким кодом уже існує. - not_blank: Код не може бути порожнім. - min_length: Код має бути довжиною хоча б {{ limit }} знаків. - max_length: Код не може бути довшим за {{ limit }} знаків. - position: - unique: FAQ з такою позицією уже існує. - not_blank: Позиція не може бути порожньою. - question: - not_blank: Питання не може бути порожнім. - min_length: Питання має бути довжиною хоча б {{ limit }} знаків. - answer: - not_blank: Відповідь не може бути порожньою. - min_length: Відповідь має бути довжиною хоча б {{ limit }} знаків. - section: - code: - unique: Розділ з таким кодом уже існує. + unique: Існує колекція з цим кодом. not_blank: Код не може бути порожнім. min_length: Код має бути довжиною хоча б {{ limit }} знаків. max_length: Код не може бути довшим за {{ limit }} знаків. @@ -82,3 +67,9 @@ bitbag_sylius_cms_plugin: import: not_blank: Файл що імпортуються не може бути порожнім. invalid_format: Завантажте файл у форматі CSV. + template: + name: + unique: Уже існує шаблон з цією назвою. + not_blank: Назва не може бути порожньою. + min_length: Назва повинна містити не менше {{ limit }} символів. + max_length: Назва не може бути довшою за {{ limit }} символів. diff --git a/src/Resources/views/Block/Crud/_form.html.twig b/src/Resources/views/Block/Crud/_form.html.twig index 0af0ed0f5..a056ec1bd 100755 --- a/src/Resources/views/Block/Crud/_form.html.twig +++ b/src/Resources/views/Block/Crud/_form.html.twig @@ -1,34 +1,48 @@ -{% from '@BitBagSyliusCmsPlugin/Macro/translationForm.html.twig' import translationForm %} -{% form_theme form '@BitBagSyliusCmsPlugin/Form/theme.html.twig' %} +{% from '@SyliusCmsPlugin/Macro/translationForm.html.twig' import translationForm %} +{% form_theme form '@SyliusCmsPlugin/Form/theme.html.twig' %} -{% include '@BitBagSyliusCmsPlugin/Modal/_resourcePreview.html.twig' %} +{% include '@SyliusCmsPlugin/Modal/_resourcePreview.html.twig' %} +{% include '@SyliusCmsPlugin/Modal/_loadTemplateConfirmation.html.twig' %} -
+
{{ form_errors(form) }} + {{ form_row(form.name) }} {{ form_row(form.code) }} {{ form_row(form.enabled) }} - {{ form_row(form.products) }} - {{ form_row(form.taxons) }} - {{ form_row(form.sections) }} {{ form_row(form.channels) }} - - - {{ 'bitbag_sylius_cms_plugin.ui.preview'|trans }} + {{ 'sylius_cms.ui.preview'|trans }}
+
+

{{ 'sylius_cms.ui.manage_block_display'|trans }}

+ {{ form_row(form.products) }} + {{ form_row(form.productsInTaxons) }} + {{ form_row(form.taxons) }} +
-
- -
-
- {{ translationForm(form.translations, resource) }} +
+
+

{{ 'sylius_cms.ui.content_elements.title'|trans }}

+
+ {% include '@SyliusCmsPlugin/Locale/form.html.twig' %} + {% include '@SyliusCmsPlugin/Template/form.html.twig' %} +
+ {% include '@SyliusCmsPlugin/ContentTemplate/form.html.twig' with {ajax_url: path('sylius_cms_admin_ajax_template_content_by_id', {'id': 'REPLACE_ID'}) } %} +
+
+ {{ form_row(form.contentElements) }} +
+
+
diff --git a/src/Resources/views/Block/preview.html.twig b/src/Resources/views/Block/preview.html.twig index 43b89951c..9f6f1c8de 100755 --- a/src/Resources/views/Block/preview.html.twig +++ b/src/Resources/views/Block/preview.html.twig @@ -1,13 +1,9 @@ {% extends '@SyliusShop/layout.html.twig' %} -{% block metatags %} - +{% block content %} + {% include template %} {% endblock %} -{% block content %} -
-
- {% include blockTemplate %} -
-
+{% block metatags %} + {% endblock %} diff --git a/src/Resources/views/Collection/Crud/_form.html.twig b/src/Resources/views/Collection/Crud/_form.html.twig new file mode 100755 index 000000000..afc93a9c2 --- /dev/null +++ b/src/Resources/views/Collection/Crud/_form.html.twig @@ -0,0 +1,25 @@ +{% from '@SyliusAdmin/Macro/translationForm.html.twig' import translationForm %} +{% form_theme form '@SyliusCmsPlugin/Form/theme.html.twig' %} + +{{ form_errors(form) }} + +
+
+
+ {{ form_row(form.code) }} + {{ form_row(form.name) }} + {{ form_row(form.type) }} +
+
+
+ {{ form_row(form.pages) }} +
+
+ {{ form_row(form.blocks) }} +
+
+ {{ form_row(form.media) }} +
+
+
+
diff --git a/src/Resources/views/ContentConfiguration/_action.html.twig b/src/Resources/views/ContentConfiguration/_action.html.twig new file mode 100644 index 000000000..fd98adfe9 --- /dev/null +++ b/src/Resources/views/ContentConfiguration/_action.html.twig @@ -0,0 +1,5 @@ +{% form_theme field '@SyliusCmsPlugin/Form/theme.html.twig' %} + +{{ form_row(field) }} + +
diff --git a/src/Resources/views/ContentTemplate/Crud/_form.html.twig b/src/Resources/views/ContentTemplate/Crud/_form.html.twig new file mode 100644 index 000000000..c5ae90933 --- /dev/null +++ b/src/Resources/views/ContentTemplate/Crud/_form.html.twig @@ -0,0 +1,21 @@ +{% form_theme form '@SyliusCmsPlugin/Form/theme.html.twig' %} + +
+
+
+ {{ form_errors(form) }} + {{ form_row(form.name) }} + {{ form_row(form.type) }} +
+
+
+
+

{{ 'sylius_cms.ui.content_elements.title'|trans }}

+
+
+ {{ form_row(form.contentElements) }} +
+
+
+
+
diff --git a/src/Resources/views/ContentTemplate/form.html.twig b/src/Resources/views/ContentTemplate/form.html.twig new file mode 100644 index 000000000..6c15d0126 --- /dev/null +++ b/src/Resources/views/ContentTemplate/form.html.twig @@ -0,0 +1,9 @@ +
+
{{ 'sylius_cms.ui.content_elements.template'|trans }}
+
+
+ {{ form_row(form.contentTemplate) }} + +
+
+
diff --git a/src/Resources/views/CrudUi/create.html.twig b/src/Resources/views/CrudUi/create.html.twig index 98ae01951..3b81f7165 100755 --- a/src/Resources/views/CrudUi/create.html.twig +++ b/src/Resources/views/CrudUi/create.html.twig @@ -1,4 +1,4 @@ -{% extends '@BitBagSyliusCmsPlugin/layout.html.twig' %} +{% extends '@SyliusCmsPlugin/layout.html.twig' %} {% import '@SyliusUi/Macro/headers.html.twig' as headers %} diff --git a/src/Resources/views/CrudUi/index.html.twig b/src/Resources/views/CrudUi/index.html.twig index 02ed75bde..f658effd1 100644 --- a/src/Resources/views/CrudUi/index.html.twig +++ b/src/Resources/views/CrudUi/index.html.twig @@ -1,4 +1,4 @@ -{% extends '@BitBagSyliusCmsPlugin/layout.html.twig' %} +{% extends '@SyliusCmsPlugin/layout.html.twig' %} {% import '@SyliusUi/Macro/headers.html.twig' as headers %} diff --git a/src/Resources/views/CrudUi/update.html.twig b/src/Resources/views/CrudUi/update.html.twig index bb2f65af1..40080fd98 100755 --- a/src/Resources/views/CrudUi/update.html.twig +++ b/src/Resources/views/CrudUi/update.html.twig @@ -1,4 +1,4 @@ -{% extends '@BitBagSyliusCmsPlugin/layout.html.twig' %} +{% extends '@SyliusCmsPlugin/layout.html.twig' %} {% import '@SyliusUi/Macro/headers.html.twig' as headers %} {% import '@SyliusUi/Macro/buttons.html.twig' as buttons %} diff --git a/src/Resources/views/Form/theme.html.twig b/src/Resources/views/Form/theme.html.twig index 1693acf61..290dc6dee 100755 --- a/src/Resources/views/Form/theme.html.twig +++ b/src/Resources/views/Form/theme.html.twig @@ -1,43 +1,140 @@ {% 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 sylius_collection_autocomplete_choice_row %} + {{ form_row(form, {'remote_url': path('sylius_cms_admin_ajax_collection_by_name_phrase'), 'load_edit_url': path('sylius_cms_admin_ajax_collection_by_code')}) }} {% endblock %} -{% block bitbag_media_autocomplete_choice_row %} -
{{- form_label(form) -}} {{- form_errors(form) -}}
{% endblock %} {% block sylius_product_autocomplete_choice_row %} - {{ form_row(form, {'remote_url': path('bitbag_sylius_cms_plugin_admin_ajax_product_by_name_phrase'), 'load_edit_url': path('sylius_admin_ajax_product_by_code')}) }} + {{ form_row(form, {'remote_url': path('sylius_cms_admin_ajax_product_by_name_phrase'), 'load_edit_url': path('sylius_admin_ajax_product_by_code')}) }} {% endblock %} {% block sylius_taxon_autocomplete_choice_row %} - {{ form_row(form, {'remote_url': path('bitbag_sylius_cms_plugin_admin_ajax_taxon_by_name_phrase'), 'load_edit_url': path('sylius_admin_ajax_taxon_by_code')}) }} + {{ form_row(form, {'remote_url': path('sylius_cms_admin_ajax_taxon_by_name_phrase'), 'load_edit_url': path('sylius_admin_ajax_taxon_by_code')}) }} +{% endblock %} + +{% block collection_widget -%} + {% from '@SyliusResource/Macros/notification.html.twig' import error %} + {% import _self as self %} + {% set attr = attr|merge({'class': attr.class|default ~ ' controls collection-widget'}) %} + + {% apply spaceless %} +
+ {{ error(form.vars.errors) }} + + {% if prototypes|default is iterable %} + {% for key, subPrototype in prototypes %} + + {% endfor %} + {% endif %} + +
+ {% for child in form %} + {{ self.collection_item(child, allow_delete, button_delete_label, loop.index0) }} + {% endfor %} +
+ + {% if prototype is defined and allow_add %} + + + {{ button_add_label|trans }} + + {% endif %} +
+ {% endapply %} +{%- endblock collection_widget %} + +{% macro collection_item(form, allow_delete, button_delete_label, index) %} + {% apply spaceless %} +
+
+ {{ form_widget(form) }} + {% if allow_delete %} + + + {{ button_delete_label|trans }} + + {% endif %} +
+
+ {% endapply %} +{% endmacro %} + +{% block sylius_resource_autocomplete_choice_row %} +
+ {{- form_label(form) -}} + {{- form_help(form) -}} + + {{- form_errors(form) -}} +
{% endblock %} diff --git a/src/Resources/views/FrequentlyAskedQuestion/Crud/_form.html.twig b/src/Resources/views/FrequentlyAskedQuestion/Crud/_form.html.twig deleted file mode 100755 index 08bf71abc..000000000 --- a/src/Resources/views/FrequentlyAskedQuestion/Crud/_form.html.twig +++ /dev/null @@ -1,15 +0,0 @@ -{% from '@SyliusAdmin/Macro/translationForm.html.twig' import translationForm %} -{% form_theme form '@BitBagSyliusCmsPlugin/Form/theme.html.twig' %} - -{{ form_errors(form) }} - -
-
- {{ form_row(form.code) }} - {{ form_row(form.position) }} -
- {{ form_row(form.enabled) }} - {{ form_row(form.channels) }} -
- -{{ translationForm(form.translations) }} diff --git a/src/Resources/views/Grid/Action/import.html.twig b/src/Resources/views/Grid/Action/import.html.twig index bb63c10e2..21fbf091d 100644 --- a/src/Resources/views/Grid/Action/import.html.twig +++ b/src/Resources/views/Grid/Action/import.html.twig @@ -1,4 +1,4 @@ {{ render(path( - 'bitbag_sylius_cms_plugin_admin_import_data', + 'sylius_cms_admin_import_data', {'resourceName': options.resourceCode} )) }} diff --git a/src/Resources/views/Grid/Field/channels.html.twig b/src/Resources/views/Grid/Field/channels.html.twig new file mode 100755 index 000000000..a91fcd1e9 --- /dev/null +++ b/src/Resources/views/Grid/Field/channels.html.twig @@ -0,0 +1,3 @@ +{% for channel in data.channels %} + {{ channel.code }} +{% endfor %} 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/name.html.twig b/src/Resources/views/Grid/Field/name.html.twig new file mode 100644 index 000000000..21a790683 --- /dev/null +++ b/src/Resources/views/Grid/Field/name.html.twig @@ -0,0 +1,4 @@ +{% set name = data.name %} +{% if name %} + {{ name|length > 60 ? name|slice(0, 60) ~ '...' : name }} +{% endif %} 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/Grid/Form/_importForm.html.twig b/src/Resources/views/Grid/Form/_importForm.html.twig index 2577a1097..fdbc12d30 100644 --- a/src/Resources/views/Grid/Form/_importForm.html.twig +++ b/src/Resources/views/Grid/Form/_importForm.html.twig @@ -1,15 +1,15 @@ -{% form_theme form '@BitBagSyliusCmsPlugin/Form/theme.html.twig' %} -
-
+{% form_theme form '@SyliusCmsPlugin/Form/theme.html.twig' %} +
+
- + {{ form_widget(form.file, { 'attr': {'data-bb-cms-file': 'file'} }) }}
diff --git a/src/Resources/views/Locale/form.html.twig b/src/Resources/views/Locale/form.html.twig new file mode 100644 index 000000000..d50ad8597 --- /dev/null +++ b/src/Resources/views/Locale/form.html.twig @@ -0,0 +1,6 @@ +
{{ form_label(form.locale) }}
+
+
+ {{ form_widget(form.locale) }} +
+
diff --git a/src/Resources/views/Macro/mediaWidget.html.twig b/src/Resources/views/Macro/mediaWidget.html.twig index 5816fdf0b..f7c21e27e 100755 --- a/src/Resources/views/Macro/mediaWidget.html.twig +++ b/src/Resources/views/Macro/mediaWidget.html.twig @@ -1,7 +1,7 @@ {% macro mediaWidget(form) %} {% endmacro %} diff --git a/src/Resources/views/Macro/translationForm.html.twig b/src/Resources/views/Macro/translationForm.html.twig index 625bdef64..18732361c 100755 --- a/src/Resources/views/Macro/translationForm.html.twig +++ b/src/Resources/views/Macro/translationForm.html.twig @@ -1,6 +1,6 @@ {% macro translationForm(translations, resource) %} - {% import '@BitBagSyliusCmsPlugin/Macro/imageWidget.html.twig' as image %} - {% import '@BitBagSyliusCmsPlugin/Macro/mediaWidget.html.twig' as media %} + {% import '@SyliusCmsPlugin/Macro/imageWidget.html.twig' as image %} + {% import '@SyliusCmsPlugin/Macro/mediaWidget.html.twig' as media %} {% import '@SyliusUi/Macro/flags.html.twig' as flags %}
@@ -13,7 +13,7 @@
{% for field in translationForm %} - {% if 'bitbag_media_autocomplete_choice' in field.vars.block_prefixes %} + {% if 'sylius_media_autocomplete_choice' in field.vars.block_prefixes %} {{ media.mediaWidget(field) }} {% elseif 'image' == field.vars.name %} {{ image.imageWidget(field) }} @@ -29,8 +29,8 @@ {% endmacro %} {% macro translationFormWithSlug(translations, slugFieldTemplate, resource) %} - {% import '@BitBagSyliusCmsPlugin/Macro/imageWidget.html.twig' as image %} - {% import '@BitBagSyliusCmsPlugin/Macro/mediaWidget.html.twig' as media %} + {% import '@SyliusCmsPlugin/Macro/imageWidget.html.twig' as image %} + {% import '@SyliusCmsPlugin/Macro/mediaWidget.html.twig' as media %} {% import '@SyliusUi/Macro/flags.html.twig' as flags %}
@@ -45,7 +45,7 @@ {% if field.vars.name == 'slug' %} {% include slugFieldTemplate with { 'slugField': translationForm.slug, 'resource': resource } %} - {% elseif 'bitbag_media_autocomplete_choice' in field.vars.block_prefixes %} + {% elseif 'sylius_media_autocomplete_choice' in field.vars.block_prefixes %} {{ media.mediaWidget(field) }} {% elseif 'image' == field.vars.name %} {{ image.imageWidget(field) }} diff --git a/src/Resources/views/Media/Crud/_form.html.twig b/src/Resources/views/Media/Crud/_form.html.twig index 2e072fdb9..b8b9b4f18 100755 --- a/src/Resources/views/Media/Crud/_form.html.twig +++ b/src/Resources/views/Media/Crud/_form.html.twig @@ -1,37 +1,37 @@ -{% from '@BitBagSyliusCmsPlugin/Macro/translationForm.html.twig' import translationForm %} -{% form_theme form '@BitBagSyliusCmsPlugin/Form/theme.html.twig' %} +{% from '@SyliusCmsPlugin/Macro/translationForm.html.twig' import translationForm %} +{% form_theme form '@SyliusCmsPlugin/Form/theme.html.twig' %} -{% include '@BitBagSyliusCmsPlugin/Modal/_resourcePreview.html.twig' %} +{% include '@SyliusCmsPlugin/Modal/_resourcePreview.html.twig' %} {{ form_errors(form) }}
+ {{ form_row(form.name) }} {{ form_row(form.code) }} + {{ form_row(form.enabled) }} + {{ form_row(form.channels) }} + {{ form_row(form.collections) }} {{ form_row(form.type) }} {{ form_row(form.file) }} - {{ form_row(form.enabled) }} {{ form_row(form.saveWithOriginalName) }} - {{ form_row(form.products) }} - {{ form_row(form.sections) }} - {{ form_row(form.channels) }} - - - - {{ 'bitbag_sylius_cms_plugin.ui.preview'|trans }} - + {{ translationForm(form.translations) }}
-
- -
- {{ translationForm(form.translations) }} +
+

{{ 'sylius_cms.ui.preview'|trans }}

+ {{ form_row(form.path) }} + + {% set type = form.type.vars.value %} + {% if 'image' == type %} + {% include '@SyliusCmsPlugin/Media/Preview/_image.html.twig' with {'path': form.path.vars.value} %} + {% elseif 'video' == type %} + {% include '@SyliusCmsPlugin/Media/Preview/_video.html.twig' with {'path': form.path.vars.value} %} + {% elseif 'file' == type %} + {% include '@SyliusCmsPlugin/Media/Preview/_file.html.twig' with {'code': form.code.vars.value} %} + {% endif %} +
diff --git a/src/Resources/views/Media/Preview/_file.html.twig b/src/Resources/views/Media/Preview/_file.html.twig new file mode 100644 index 000000000..14b8308bf --- /dev/null +++ b/src/Resources/views/Media/Preview/_file.html.twig @@ -0,0 +1,4 @@ + + + {{ 'sylius_cms.ui.download'|trans }} + diff --git a/src/Resources/views/Media/Preview/_image.html.twig b/src/Resources/views/Media/Preview/_image.html.twig new file mode 100644 index 000000000..9814b9df8 --- /dev/null +++ b/src/Resources/views/Media/Preview/_image.html.twig @@ -0,0 +1,5 @@ + diff --git a/src/Resources/views/Media/Preview/_video.html.twig b/src/Resources/views/Media/Preview/_video.html.twig new file mode 100644 index 000000000..81d4352e5 --- /dev/null +++ b/src/Resources/views/Media/Preview/_video.html.twig @@ -0,0 +1 @@ + diff --git a/src/Resources/views/Media/preview.html.twig b/src/Resources/views/Media/preview.html.twig deleted file mode 100644 index 6e18f258b..000000000 --- a/src/Resources/views/Media/preview.html.twig +++ /dev/null @@ -1,15 +0,0 @@ -{% extends '@SyliusShop/layout.html.twig' %} - -{% block metatags %} - -{% endblock %} - -{% block content %} -
-
- {% if mediaTemplate != null %} - {% include mediaTemplate %} - {% endif %} -
-
-{% endblock %} diff --git a/src/Resources/views/Modal/_channelSwitch.html.twig b/src/Resources/views/Modal/_channelSwitch.html.twig index 328bd5275..c822caf11 100644 --- a/src/Resources/views/Modal/_channelSwitch.html.twig +++ b/src/Resources/views/Modal/_channelSwitch.html.twig @@ -3,10 +3,10 @@ {% set code = app.request.query.get('channel', selected.code) %}
-