如何在EZPublish中配置工作流


How to configure a workflow in EZPublish?

我正在做一个项目,要求在每次内容发布或更新后清除缓存。事情是,通常EZpublish自己做,但在我的情况下,这是不够的,所以我想做的是做一个工作流事件来做到这一点。

我已经参考了本教程,但是我不能调用我创建的execute函数。

是否有人知道如何创建内容发布后调用的工作流事件?

您可以查看本教程1和本教程2,了解如何创建工作流。在管理界面创建新事件表单时,查找刚刚创建的类型,而不是预定义的事件类型(multiplexer,批准....)。

你必须创建一个扩展,我将其命名为" youextension ",新的事件类型,我将其命名为"publishevent"。

注意:如果你在5.0版本之前使用eZ Publish,你必须在路径

中省略"ezpublish_legacy/"

ezpublish_legacy/扩展/yourextension/eventtypes/事件/publishevent/publisheventtype.php:

<?php
/**
 * Class PublishEventType
 */
class PublishEventType extends eZWorkflowEventType
{
    function __construct()
    {
        $this->eZWorkflowEventType( 'publishevent', 'description of what you are doing' );
        $this->setTriggerTypes( array(
            'content' => array(
                'publish' => array( 'after' ),
            )
        ) );
    }
    /**
     * This is where your code goes
     *
     * @param eZWorkflowProcess $process
     * @param eZWorkflowEvent $event
     * @return int
     */
    function execute( $process, $event )
    {
        $parameters = $process->attribute( 'parameter_list' );
        if ( isset( $parameters['object_id'] ) && isset( $parameters['version'] ) )
        {
            $objectId = (int) $parameters['object_id'];
            $version = (int) $parameters['version'];
            // your code goes here
        }
        return eZWorkflowType::STATUS_ACCEPTED;
    }
}
eZWorkflowEventType::registerEventType( 'publishevent', 'PublishEventType' );

ezpublish_legacy/扩展/yourextension/设置/workflow.ini.append.php:

<?php /*
[EventSettings]
ExtensionDirectories[]=yourextension
AvailableEventTypes[]=event_publishevent
*/

别忘了激活你的新扩展。

ezpublish_legacy/设置/覆盖/site.ini.append.php:

[ExtensionSettings]
ActiveExtensions[]=yourextension

这个对你有帮助吗?

作为旁注:你知道你可以调整哪些内容的缓存在发布时使用所谓的"智能视图缓存"过期吗?有一个ini文件:viewcache.ini。这是一个有点神秘,但相当好地记录在ez4文档在线。也许您可以使用此功能而不使用自定义工作流?

边注2:您可以查找社区扩展ezworkflowcollection的许多有用的工作流事件,您可以使用不同的事情(即使缓存清除不是其中之一)