当前位置: 首页>>代码示例>>PHP>>正文


PHP Workflow::revertStage方法代码示例

本文整理汇总了PHP中Workflow::revertStage方法的典型用法代码示例。如果您正苦于以下问题:PHP Workflow::revertStage方法的具体用法?PHP Workflow::revertStage怎么用?PHP Workflow::revertStage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Workflow的用法示例。


在下文中一共展示了Workflow::revertStage方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: execute

 public function execute(&$params)
 {
     $workflowId = $this->parseOption('workflowId', $params);
     $stageNumber = $this->parseOption('stageNumber', $params);
     $model = $params['model'];
     $type = lcfirst(X2Model::getModuleName(get_class($model)));
     $modelId = $model->id;
     $workflowStatus = Workflow::getWorkflowStatus($workflowId, $modelId, $type);
     $message = '';
     if (Workflow::validateAction('revert', $workflowStatus, $stageNumber, '', $message)) {
         list($started, $workflowStatus) = Workflow::revertStage($workflowId, $stageNumber, $model, $workflowStatus);
         assert($started);
         return array(true, Yii::t('studio', 'Stage "{stageName}" reverted for {recordName}', array('{stageName}' => $workflowStatus['stages'][$stageNumber]['name'], '{recordName}' => $model->getLink())));
     } else {
         return array(false, $message);
     }
 }
开发者ID:dsyman2,项目名称:X2CRM,代码行数:17,代码来源:X2FlowWorkflowRevertStage.php

示例2: actionRevertStage

 public function actionRevertStage($workflowId, $stageNumber, $modelId, $type)
 {
     $model = $this->validateParams($workflowId, $stageNumber, $modelId, $type);
     if ($model === null) {
         throw new CHttpException(400, 'Bad Request');
     }
     $workflowStatus = Workflow::getWorkflowStatus($workflowId, $modelId, $type);
     $message = '';
     if (Workflow::validateAction('revert', $workflowStatus, $stageNumber, '', $message)) {
         list($completed, $workflowStatus) = Workflow::revertStage($workflowId, $stageNumber, $model);
     }
     echo CJSON::encode(array('workflowStatus' => $workflowStatus, 'flashes' => array('error' => !empty($message) ? array($message) : array(), 'success' => empty($message) ? array(Yii::t('workflow', 'Stage reverted')) : array())));
 }
开发者ID:shuvro35,项目名称:X2CRM,代码行数:13,代码来源:WorkflowController.php

示例3: moveFromStageAToStageB

 /**
  * Moves a record up or down a workflow. Assumes that stageA is started but not completed.
  * Intermediate stages and stageB can be in any state.
  * @param int $workflowId
  * @param int $stageA Start stage (indexed by 1) 
  * @param int $stageB End stage (indexed by 1) 
  * @param object $model model associated with workflow
  * @param array $comments comment strings indexed by workflow stage number
  * Precondition: $stageA !== $stageB
  * @return array first element is success, the second is an optional message
  */
 public static function moveFromStageAToStageB($workflowId, $stageA, $stageB, $model, $comments = array())
 {
     if ($stageA === $stageB && YII_DEBUG) {
         throw new CException('Precondition violation: $stageA === $stageB');
     }
     $modelId = $model->id;
     $type = lcfirst(X2Model::getModuleName(get_class($model)));
     $retVal = self::validateStageChange($workflowId, $stageA, $stageB, $modelId, $type, $comments);
     if (!$retVal[0]) {
         return $retVal;
     }
     // enact stage change
     if ($stageA < $stageB) {
         // complete first stage
         list($success, $status) = Workflow::completeStage($workflowId, $stageA, $model, isset($comments[$stageA]) ? $comments[$stageA] : '', false);
         for ($i = $stageA + 1; $i < $stageB; ++$i) {
             // start and complete intermediate stages
             list($success, $status) = Workflow::startStage($workflowId, $i, $model, $status);
             list($success, $status) = Workflow::completeStage($workflowId, $i, $model, isset($comments[$i]) ? $comments[$i] : '', false, $status);
         }
         list($success, $status) = Workflow::startStage($workflowId, $stageB, $model, $status);
         // uncomplete a completed final stage
         list($success, $status) = Workflow::revertStage($workflowId, $stageB, $model, false, $status);
     } else {
         // $stageA > $stageB
         // unstart first stage
         list($success, $status) = Workflow::revertStage($workflowId, $stageA, $model);
         for ($i = $stageA - 1; $i > $stageB; --$i) {
             // uncomplete and unstart intermediate stages
             list($success, $status) = Workflow::revertStage($workflowId, $i, $model, $status);
             list($success, $status) = Workflow::revertStage($workflowId, $i, $model, $status);
         }
         // uncomplete a completed final stage
         list($success, $status) = Workflow::revertStage($workflowId, $stageB, $model, false, $status);
         list($success, $status) = Workflow::startStage($workflowId, $stageB, $model, false, $status);
     }
     return array(true);
 }
开发者ID:keyeMyria,项目名称:CRM,代码行数:49,代码来源:Workflow.php

示例4: testRevertStage

 public function testRevertStage()
 {
     $workflow = $this->workflows('workflow2');
     $model = $this->contacts('contact935');
     list($success, $status) = Workflow::revertStage($workflow->id, 4, $model);
     // reverted a started stage
     $this->assertTrue($success);
     list($success, $status) = Workflow::revertStage($workflow->id, 4, $model);
     // couldn't revert an unstarted stage
     $this->assertFalse($success);
 }
开发者ID:tymiles003,项目名称:X2CRM,代码行数:11,代码来源:WorkflowTest.php


注:本文中的Workflow::revertStage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。