Skip to content

Commit

Permalink
Merge pull request #529 from BitBagCommerce/feature/OP-290
Browse files Browse the repository at this point in the history
OP-290: Refactor CMS plugin codebase to the Sylius style
  • Loading branch information
jkindly authored Sep 6, 2024
2 parents 9844dff + cdb16e7 commit e94dcdc
Show file tree
Hide file tree
Showing 660 changed files with 3,597 additions and 5,365 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# [![](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
# Sylius CMS Plugin

----

Expand Down
6 changes: 3 additions & 3 deletions UPGRADE-5.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ and [Templates](doc/templates.md) docs.
* Reordered forms/elements for functionality consistency.
* Updated import functionality to work with the new structure.
* Updated fixtures to work with the new structure
* Removed `bitbag_cms_render_product_pages` twig extension.
* Removed `sylius_cms_render_product_pages` twig extension.
* Removed support for rendering twig functions in WYSIWYG editor.
* Added twig extensions:
* `bitbag_cms_render_collection`
* `bitbag_cms_render_content_elements`
* `sylius_cms_render_collection`
* `sylius_cms_render_content_elements`

## Briefly about Content Elements

Expand Down
2 changes: 1 addition & 1 deletion UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion behat.yml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -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: ~

Expand Down
19 changes: 6 additions & 13 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -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",
Expand All @@ -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"]
},
Expand Down
22 changes: 11 additions & 11 deletions doc/01.1-webpack-config.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# BitBag SyliusCmsPlugin
# SyliusCmsPlugin

- [⬅️ Back](./installation.md)

Expand All @@ -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`
Expand All @@ -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`
Expand All @@ -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`
14 changes: 7 additions & 7 deletions doc/01.2-webpack-entry.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# BitBag SyliusCmsPlugin
# SyliusCmsPlugin

- [⬅️ Back](./installation.md)

Expand All @@ -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`
2 changes: 1 addition & 1 deletion doc/01.3-import-entry.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# BitBag SyliusCmsPlugin
# SyliusCmsPlugin

- [⬅️ Back](./installation.md)

Expand Down
2 changes: 1 addition & 1 deletion doc/01.4-custom-solution.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# BitBag SyliusCmsPlugin
# SyliusCmsPlugin

- [⬅️ Back](./installation.md)

Expand Down
10 changes: 5 additions & 5 deletions doc/01.5-non-webpack.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# BitBag SyliusCmsPlugin
# SyliusCmsPlugin

- [⬅️ Back](./installation.md)

Expand All @@ -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'
} %}
```
16 changes: 8 additions & 8 deletions doc/blocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Blocks can be placed on the homepage, product page, or any other page of your st

### Rendering the block

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.
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:

Expand All @@ -16,17 +16,17 @@ In your `app/Resources/views/SyliusShopBundle/Homepage/index.html.twig` file add
{% block content %}
{{ bitbag_cms_render_block('homepage_intro') }}
{{ sylius_cms_render_block('homepage_intro') }}
{% endblock %}
```

`{{ bitbag_cms_render_block([block_code]) }}` function can also take two additional parameters: `template` and `context`.
`{{ sylius_cms_render_block([block_code]) }}` function can also take two additional parameters: `template` and `context`.

`template` allows you to render a block with a custom template. For instance:

```twig
{{ bitbag_cms_render_block('homepage_intro', '@App/Some/Template/_path.html.twig') }}
{{ sylius_cms_render_block('homepage_intro', '@App/Some/Template/_path.html.twig') }}
```

`context` allows you to pass additional variables to the block template. It can be one of three types:
Expand All @@ -37,9 +37,9 @@ In your `app/Resources/views/SyliusShopBundle/Homepage/index.html.twig` file add
For instance:

```twig
{{ bitbag_cms_render_block('homepage_intro', null, {'some_variable': 'some_value'}) }}
{{ bitbag_cms_render_block('homepage_intro', null, product) }}
{{ bitbag_cms_render_block('homepage_intro', null, taxon) }}
{{ 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
Expand All @@ -52,5 +52,5 @@ in the admin panel.
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 block resource, you can change the global templates under `app/templates/bundles/BitBagSyliusCmsPlugin/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).
10 changes: 5 additions & 5 deletions doc/collections.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@ Or you might want to group all of your specific blocks together in a collection
### Rendering the collection

In the admin panel, you can create collection resources.
It could be rendered in your twig templates using `bitbag_cms_render_collection([collection_code])` helper extension.
It could be rendered in your twig templates using `sylius_cms_render_collection([collection_code])` helper extension.

`{{ bitbag_cms_render_collection([collection_code]) }}` function can also take two additional parameters: `countToRender` and `template`.
`{{ 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
{{ bitbag_cms_render_collection('homepage_blocks', 3) }}
{{ sylius_cms_render_collection('homepage_blocks', 3) }}
```

`template` allows you to render a collection with a custom template. For instance:

```twig
{{ bitbag_cms_render_collection('homepage_blocks', null, '@App/Some/Template/_path.html.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.
Expand All @@ -35,5 +35,5 @@ You can read more about it [here](https://symfony.com/doc/current/service_contai

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/BitBagSyliusCmsPlugin/Shop/Collection` location.
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).
Loading

0 comments on commit e94dcdc

Please sign in to comment.