Skip to content

Commit 2680eb4

Browse files
committed
PB-371: Documentation for Page Builder content upgrade process
Updated after review
1 parent 34dcee8 commit 2680eb4

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

docs/how-to/how-to-upgrade-content-types.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# How to make configuration changes backwards compatible
22

3-
Before version 1.3, changes to a content-type configuration could (and usually would) break the existing content that was saved with the previous configuration. Why? Because a content type's configuration maps data from its source (the master format) to its display templates. So when the configuration mapping changes, the display of existing content might also change. With significant configuration changes, data (such as styles, attributes, and html) is lost. This change causes existing content to appear incorrectly, or not at all.
3+
Before version 1.3, changes to a content-type configuration could (and usually would) break the existing content that was saved with the previous configuration. Why? Because a content type's configuration maps data from its source (the master format) to its display templates. So when the configuration mapping changes, the display of existing content might also change. With significant configuration changes, data (such as styles, attributes, and html) is lost. Such changes cause existing content to appear incorrectly, or not at all.
44

5-
The Page Builder content upgrade framework provides an API to convert existing content so it maps to new configurations and displays correctly.
5+
To fix this limitation for versions 1.3+, Page Builder uses Magento's native upgrade mechanism, coupled with our content upgrade helpers. These helpers convert existing content so that it maps to new configurations and displays correctly.
66

77
## Example usage for Row
88

9-
The Page Builder team recently had to change the configuration of the Row's full-width appearance to fix a layout issue. The fix was simple. We moved a style attribute from one element in the Row's full-width appearance to another element. But without the upgrade framework, our change to the Row's configuration would have broken all previously saved Page Builder content with Rows. And because all Page Builder content starts with a Row, all Page Builder content would be broken!
9+
The Page Builder team recently had to change the configuration of the Row's full-width appearance to fix a layout issue. The fix was simple. We moved a style attribute from one element in the Row's full-width appearance to another element. But without the upgrade helpers, our change to the Row's configuration would have broken all previously saved Page Builder content with Rows. And because all Page Builder content starts with a Row, all Page Builder content would be broken!
1010

11-
Our fix to this issue was to build a framework that requires two classes:
11+
To fix this issue, we used the Page Builder DOM helper classes (`Magento\PageBuilder\Model\Dom\*`) to create a converter and a data patcher for the native Row content type:
1212

1313
1. **Converter** (See `FixFullWidthRowPadding.php`)
1414
2. **Patcher** (See `UpgradeFullWidthPadding.php`)
@@ -17,9 +17,9 @@ Our fix to this issue was to build a framework that requires two classes:
1717

1818
### Converter class example
1919

20-
The converter class implements the `DataConverterInterface`. Specifically, it implements the `convert` function where it makes the actual DOM changes to the content types within each master format it receives.
20+
The converter class implements the `DataConverterInterface`. Specifically, it implements the `convert` function where it uses Page Builder's DOM helper classes to change the DOM of the Row content type within each master format it receives.
2121

22-
Page Builder's `FixFullWidthRowPadding` class is provided here as an example implementation:
22+
Page Builder's `FixFullWidthRowPadding` converter class is provided here as an example implementation:
2323

2424
```php
2525
<?php
@@ -84,7 +84,7 @@ class FixFullWidthRowPadding implements DataConverterInterface
8484

8585
### Patcher class example
8686

87-
The patcher class implements the `DataPatchInterface`. Specifically, it uses the framework's `UpgradeContentHelper.php` class to apply the converter class to all the database entities where Page Builder content exists. These locations are provided by the `UpgradableEntitiesPool`, described later in this topic
87+
The patcher class implements the `DataPatchInterface`. Specifically, it uses the framework's `UpgradeContentHelper` class to apply the converter class to all the database entities where Page Builder content exists. These locations are provided by the `UpgradableEntitiesPool`, described later in this topic.
8888

8989
Page Builder's `UpgradeFullWidthPadding` class is provided here as an example implementation:
9090

@@ -153,7 +153,7 @@ class UpgradeFullWidthPadding implements DataPatchInterface
153153

154154
## UpgradableEntitiesPool
155155

156-
The `UpgradableEntitiesPool` provides the locations in the database where Page Builder content can exist. By default, these entities include: `cms_block`, `cms_page`, `catalog_category_entity_text`, `catalog_product_entity_text`, and `pagebuilder_template`. Page Builder defines these entities in `Magento/PageBuilder/etc/di.xml`, as shown here:
156+
The `UpgradableEntitiesPool` provides the locations in the database where Page Builder content exists. By default, these entities include: `cms_block`, `cms_page`, `catalog_category_entity_text`, `catalog_product_entity_text`, and `pagebuilder_template`. Page Builder defines these entities in `Magento/PageBuilder/etc/di.xml`, as shown here:
157157

158158
```xml
159159
<type name="Magento\PageBuilder\Model\UpgradableEntitiesPool">
@@ -213,7 +213,7 @@ If you have created additional database entities for storing Page Builder conten
213213

214214
## How to upgrade your custom content types
215215

216-
To use this framework for your custom content-type configuration changes, follow these steps:
216+
To use Page Builder's content upgrade helpers for your own content-type configuration changes, follow these steps:
217217

218218
1. Set up a new environment that uses a _copy_ of your production data, far away from any real data.
219219

@@ -223,9 +223,9 @@ To use this framework for your custom content-type configuration changes, follow
223223

224224
![Custom converter and upgrader classes](../images/upgrade-framework-example-custom.png)
225225

226-
1. Implement the `DataConverterInterface` for your content type, using Page Builder's `FixFullWidthRowPadding` class as an example.
226+
1. Implement the `DataConverterInterface` to create a converter for your content type, using Page Builder's `FixFullWidthRowPadding` class as an example.
227227

228-
1. Implement the `DataPatchInterface` for your content type, using Page Builder's `UpgradeFullWidthPadding` class as an example.
228+
1. Implement the `DataPatchInterface` to create a patcher for your content type, using Page Builder's `UpgradeFullWidthPadding` class as an example.
229229

230230
1. Make a copy of the data in the `content` fields of existing entities (`cms_page`, `cms_block`, and so on). You will compare this content with the content changes made after running your upgrade patch.
231231

@@ -235,10 +235,10 @@ To use this framework for your custom content-type configuration changes, follow
235235

236236
1. Compare your post-upgraded content to the previous content.
237237

238-
If the conversion didn't convert your content as planned, remove your entry from the `patch_list` table, switch off away from your test branch, and run `bin/magento setup:upgrade` to reset the database content to try again.
238+
If the conversion didn't convert your content as planned, remove your entry from the `patch_list` table, switch away from your test branch, and run `bin/magento setup:upgrade` to reset the database content and try again.
239239

240240
## How to upgrade overloaded Page Builder content types
241241

242-
If you have overloaded the configurations of native Page Builder content types, you need to review Page Builder's native configuration changes for each release and create converters to customize how the native content types are updated for your changes, as necessary.
242+
If you have overloaded the configurations of native Page Builder content types, you need to review Page Builder's native configuration changes for each release. If necessary, you will need to create a converter and patcher to customize how the native content types are updated for your changes.
243243

244-
For example, In version 1.3, we updated the configuration of the native Row content type. Specifically, we moved the padding attribute of the `full-width` appearance from the `<main>` element to the `<inner>` element. So if the Row configuration is different in your custom content type, maybe you removed the `<inner>` element, then you will need to upgrade your overloaded Row as described in the previous steps.
244+
For example, in version 1.3, we updated the configuration of the native Row content type. As mentioned, we moved the padding attribute of the `full-width` appearance from the `<main>` element to the `<inner>` element. So if your Row configuration is different in your custom content type (for example, you removed the `<inner>` element), then you will need to upgrade your overloaded Row as described in the previous steps.

0 commit comments

Comments
 (0)