magento-hackathon / m2-content-provisioning

Configure CMS (pages or block) entries via XML and define how them should be deployed.
MIT License
45 stars 19 forks source link

Export CMS page/block to a module #13

Open vadimjustus opened 5 years ago

vadimjustus commented 5 years ago

Idea In most cases developers create content on the local machine and copy the results from database to the content_provisioning.xml in their module. Automate this process would save time and reduce possible errors.

Solution Create a CLI command, which "dumps" one dedicated CMS entry to the XML file.

Additional context It should be possible to define into which module the content should be dumped.

roma-glushko commented 5 years ago

Hi @vadimjustus , Nice idea 👍 For the first version of this feature, we can simply dump needed content to var directory.

The working flow will be the following (for a brand new CMS content):

  1. Develop CMS page/block changing content from the Magento Admin.
  2. Use CLI to export needed content to var/cms_provisioning/[identifier].html content
  3. The developer moves the html file to the needed module directory
  4. The developer registers needed content in the cms_provisioning.xml file

The export flow will provide an extensible points to be able to export 3rd-party information.

What do you think about this approach?

vadimjustus commented 5 years ago

Hi @roma-glushko,

sounds like a good first approach. Let's do it this way.

Bonus Probably also media files can be moved to the directory var/content_provisioning/media including the subdirectory structure. Therefore Firegento\ContentProvisioning\Model\Config\Parser\Query\ FetchMediaFilesFromContent to detect all necessary media files in given content.

vadimjustus commented 5 years ago

Like discussed in last Hackathon. We will introduce following interfaces in order to execute content dumping to file system.

The strategy interface defines dumping strategy in order to be able to extend dumping process in different ways.

interface StrategyInterface
{
    public function getTargetPath(): string;
}

Example strategies: ExportToModuleStrategy, ExportToVarDirectoryStrategy

The export dumps the content by given strategy.

interface ExportInterface
{
    public execute(StrategyInterface $strategy, EntryInterface $entry): void;
}