PHP code example of space48 / magento2-cms-content-setup
1. Go to this page and download the library: Download space48/magento2-cms-content-setup library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
space48 / magento2-cms-content-setup example snippets
public function __construct(
ModuleDataSetupInterface $moduleDataSetup,
\Space48\CmsContentSetup\Model\Setup\Blocks $blockSetup
) {
$this->moduleDataSetup = $moduleDataSetup;
$this->blockSetup = $blockSetup;
}
...
public function apply()
{
$this->moduleDataSetup->startSetup();
$this->blockSetup->install(
[
[
'title' => 'Test Block',
'identifier' => 'test_block',
'file' => 'MyProject_CmsSetup::blocks/test/test_block.html', // starting from 'fixtures' folder
'stores' => ['nl', 'fr'], // can be id or code
'is_active' => true
]
]
);
$this->moduleDataSetup->endSetup();
}