Download the PHP package sifuen/module-upgradable-content without Composer
On this page you can find all versions of the php package sifuen/module-upgradable-content. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download sifuen/module-upgradable-content
More information about sifuen/module-upgradable-content
Files in sifuen/module-upgradable-content
Package module-upgradable-content
Short Description Upgrade your CMS content using UpgradeData scripts
License MIT
Informations about the package module-upgradable-content
Sifuen_UpgradableContent
This Magento 2 module allows you to upgrade your CMS blocks and pages using UpgradeData scripts.
Installation
You can install this module using composer
Or you can clone this repository and place it into app/code/Sifuen/UpgradableContent/
.
How To Use
Your UpgradeData
script should inject Sifuen\UpgradableContent\Model\ContentUpgrader
. In your constructor, you
should initialize the ContentUpgrader using $this->contentUpgrader->setContentModule([your module name])
. This is used
to find your CMS content files.
Initializing
Assuming the module you create your UpgradeData file in is called Sifuen_CmsTest
, you would invoke
setContentModule('Sifuen_CmsTest')
to tell the ContentUpgrader that this module is where you can find your CMS
content files.
By default, CMS content files are read from [your module directory]/Setup/content/[version]/[pages/blocks]/[identifier].html
.
To change this, see Advanced Initialization
See Advanced Initialization for other ways to initialize the ContentUpgrader.
Upgrading Content
You are given access to two main methods on the ContentUpgrader instance.
$this->upgradeCmsPages($version, $identifiers)
$this->upgradeCmsBlocks($version, $identifiers)
$version
is the module version you are upgrading to.
$identifiers
can be two things:
- An array of page/block identifiers
- An array of arrays, where the index of each element is the identifier of the page/block being updated/created and the value is the page/block data, minus the content.
You usually use the second version of $identifiers
if you are creating CMS content, while you will use the first
if you are updating CMS content.
Example
The files that the ContentUpgrader will read are:
- app/code/Sifuen/CmsTest/Setup/content/1.0.1/pages/examplepage-test.html
- app/code/Sifuen/CmsTest/Setup/content/1.0.2/pages/examplepage-test.html
- app/code/Sifuen/CmsTest/Setup/content/1.0.3/blocks/exampleblock-test.html
- app/code/Sifuen/CmsTest/Setup/content/1.0.4/blocks/exampleblock-test.html
Advanced Initialization
There are a few constructor arguments that can be overridden on Sifuen\UpgradableContent\Model\ContentUpgrader
. See
the following di.xml
example to see what is available to override.
If you set contentDirectory
on ContentUpgrader
, then contentModuleName
and moduleContentFolder
are ignored.
contentDirectory
is meant to completely override how the module finds the content files.
You can also set these manually in the constructor of your UpgradeData script.