コード例 #1
0
ファイル: workflow.php プロジェクト: robinmuilwijk/ezpublish
/**
 * File containing the workflow.php cronjob
 *
 * @copyright Copyright (C) 1999-2011 eZ Systems AS. All rights reserved.
 * @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2
 * @version //autogentag//
 * @package kernel
 */

$runInBrowser = true;
if ( isset( $webOutput ) )
    $runInBrowser = $webOutput;

$db = eZDB::instance();

$workflowProcessList = eZWorkflowProcess::fetchForStatus( eZWorkflow::STATUS_DEFERRED_TO_CRON );

$cli->output( "Checking for workflow processes"  );
$removedProcessCount = 0;
$processCount = 0;
$statusMap = array();
foreach( $workflowProcessList as $process )
{
    $db->begin();

    $workflow = eZWorkflow::fetch( $process->attribute( "workflow_id" ) );

    if ( $process->attribute( "event_id" ) != 0 )
        $workflowEvent = eZWorkflowEvent::fetch( $process->attribute( "event_id" ) );
    $process->run( $workflow, $workflowEvent, $eventLog );
// Store changes to process
コード例 #2
0
 function runWorkflow()
 {
     $workflowProcessList = eZWorkflowProcess::fetchForStatus(eZWorkflow::STATUS_DEFERRED_TO_CRON);
     foreach ($workflowProcessList as $process) {
         $workflow = eZWorkflow::fetch($process->attribute("workflow_id"));
         if ($process->attribute("event_id") != 0) {
             $workflowEvent = eZWorkflowEvent::fetch($process->attribute("event_id"));
         }
         $process->run($workflow, $workflowEvent, $eventLog);
         // Store changes to process
         if ($process->attribute('status') != eZWorkflow::STATUS_DONE) {
             if ($process->attribute('status') == eZWorkflow::STATUS_RESET || $process->attribute('status') == eZWorkflow::STATUS_FAILED || $process->attribute('status') == eZWorkflow::STATUS_NONE || $process->attribute('status') == eZWorkflow::STATUS_CANCELLED || $process->attribute('status') == eZWorkflow::STATUS_BUSY) {
                 $bodyMemento = eZOperationMemento::fetchMain($process->attribute('memento_key'));
                 $mementoList = eZOperationMemento::fetchList($process->attribute('memento_key'));
                 $bodyMemento->remove();
                 foreach ($mementoList as $memento) {
                     $memento->remove();
                 }
             }
             if ($process->attribute('status') == eZWorkflow::STATUS_CANCELLED) {
                 $process->removeThis();
             } else {
                 $process->store();
             }
         } else {
             //restore memento and run it
             $bodyMemento = eZOperationMemento::fetchChild($process->attribute('memento_key'));
             if (is_null($bodyMemento)) {
                 eZDebug::writeError($bodyMemento, "Empty body memento in workflow.php");
                 continue;
             }
             $bodyMementoData = $bodyMemento->data();
             $mainMemento = $bodyMemento->attribute('main_memento');
             if (!$mainMemento) {
                 continue;
             }
             $mementoData = $bodyMemento->data();
             $mainMementoData = $mainMemento->data();
             $mementoData['main_memento'] = $mainMemento;
             $mementoData['skip_trigger'] = true;
             $mementoData['memento_key'] = $process->attribute('memento_key');
             $bodyMemento->remove();
             $operationParameters = array();
             if (isset($mementoData['parameters'])) {
                 $operationParameters = $mementoData['parameters'];
             }
             $operationResult = eZOperationHandler::execute($mementoData['module_name'], $mementoData['operation_name'], $operationParameters, $mementoData);
             $process->removeThis();
         }
     }
 }