2016-09-30 29 views
1

我正在處理每個內容發佈或更新後請求清除緩存的項目。 事情是通常EZpublish自己做,但在我的情況下,它不夠,所以我試圖做的是做一個工作流事件來做到這一點。如何在EZPublish中配置工作流程?

我已經諮詢了這個tutorial但我不能調用我創建的執行功能。

是否有人有一個想法如何創建內容發佈後調用的工作流事件?

回答

1

您可以檢查此tutoriel1和此tutoriel2關於如何創建工作流程。 當創建一個新的事件形式的管理界面尋找類型,你有正確的創建,而不是預先確定的事件類型(多路複用器,approuve ....) 希望這種幫助。

1

您必須創建一個擴展名,我將其稱爲「yourextension」,使用新的事件類型,我將稱其爲「publishevent」。

注:如果您在使用EZ 5.0版本發佈之前,你必須在路徑離開了 「ezpublish_legacy /」

ezpublish_legacy /擴展/ yourextension /事件類型/事件/ 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 

這是否幫助你嗎?

+0

感謝您的回答,我有完成了所有這些,但是我找不到我使用eZLog :: write在執行函數中編寫的texte。 – Mahmoud

+0

你正在尋找@Mahmoud的哪些文字? –

+1

當我創建我的工作流時,我在我的執行函數中添加了這一行'(eZLog :: write(「test」))',問題是我從來沒有在我的「common.log」文件中找到「test」這意味着執行功能永遠不會被調用。 那是因爲我使用類型多路複用器爲我的事件工作流程(感謝@ ADA15我注意到了這一點) – Mahmoud

0

附註:您知道您可以調整使用所謂的「智能視圖緩存」發佈時哪些內容的緩存過期嗎?有一個ini文件:viewcache.ini。這有點神祕,但在ez4文檔上有很好的文檔記錄。 也許你可以逃脫使用這種功能,並沒有自定義工作流程?

邊注2:你可以看一下社區延伸ezworkflowcollection了很多,你可以使用不同的東西有用的工作流事件(即使清除緩存是不是其中之一)