stevecohenfr/legacy-publish-handler-bundle

处理从LegacyBridge到Symfony内容预发布/后发布的包

1.1.0 2018-09-19 14:26 UTC

This package is auto-updated.

Last update: 2024-09-20 03:08:01 UTC


README

处理从LegacyBridge到Symfony内容预发布/后发布的包

安装

步骤 1:下载包

打开命令行,进入您的项目目录,并执行以下命令以下载此包的最新稳定版本

    $ composer require stevecohenfr/legacy-publish-handler-bundle:"*"

此命令需要您全局安装了Composer,如Composer文档中的安装章节所述。

步骤 2:启用包

然后,通过将其添加到项目中的app/AppKernel.php文件中注册的包列表来启用包

    <?php
    // app/AppKernel.php

    // ...
    class AppKernel extends Kernel
    {
        public function registerBundles()
        {
            $bundles = array(
                // ...

                new SteveCohenFr\LegacyPublishHandlerBundle\SteveCohenFrLegacyPublishHandlerBundle(),
            );

            // ...
        }

        // ...
    }

部署旧扩展

php bin/console ezpublish:legacybundles:install_extensions --relative

然后清除缓存

php bin/console cache:clear

步骤 3:创建工作流程并触发它

  • 转到“管理” -> “工作流程”
  • 创建一个新的工作流程组或使用“标准”
  • 创建一个新的工作流程过程,并按您希望的名称命名
  • 在下拉菜单中选择“Legacy Publish Handler
  • 保存
  • 转到“管理” -> “触发器”
  • 在“内容发布后”或“内容发布前”的行中,使用下拉菜单选择您之前创建的工作流程

步骤 4:处理发布事件

此处理程序使用标签 'legacy.publish_handler'

service.yml

services:
    on_publish_handler:
        class: ACME\ACMEBundle\Handlers\OnPublishHandler
        tags:
            - { name: stevecohenfr.legacy_publish_handler }

ACME\ACMEBundle\Handlers\OnPublishHandler.php

namespace ACME\ACMEBundle\Handlers;

use eZ\Publish\API\Repository\Values\Content\Content;
use SteveCohenFr\LegacyPublishHandlerBundle\Classes\LegacyPublishHandlerInterface;

class OnPublishHandler implements LegacyPublishHandlerInterface
{
    /**
     * This function is called from legacy part before an object publication (called by workflow)
     * You must link the "before publish" trigger to the custom workflow
     *
     * @param Content $content              The legacy object
     * @param int     $version              The object version
     *
     */
    function beforePublish(Content $content, $version)
    {
        //TODO this function will be called before the content is published
    }

    /**
     * This function is called from legacy part after an object publication (called by workflow)
     * You must link the "after publish" trigger to the custom workflow
     *
     * @param Content $content              The legacy object
     * @param int     $version              The object version
     *
     */
    function afterPublish(Content $content, $version)
    {
       //TODO this function will be called after the content is published
    }
}