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();
}

public function __construct(
    ModuleDataSetupInterface $moduleDataSetup,
    \Space48\CmsContentSetup\Model\Setup\Pages $pagesSetup
) {
    $this->moduleDataSetup = $moduleDataSetup;
    $this->pagesSetup = $pagesSetup;
}

...

public function apply()
{
    $this->moduleDataSetup->startSetup();

    $this->pagesSetup->install(
        [
            [
                'title' => 'Test Page',
                'page_layout' => '1column',
                'meta_keywords' => '',
                'meta_description' => '',
                'identifier' => 'test_page',
                'content_heading' => 'Content Heading',
                'layout_update_xml' => '',
                'url_key' => 'test_page',
                'stores' => ['de', 'fr'], // code or id
                'sort_order' => 0,
                'is_active' => true,
                'file' => 'MyProject_CmsSetup::pages/test_page.html', // starting from 'fixtures' folder
            ]
        ]
    );

    $this->moduleDataSetup->endSetup();
}