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


PHP Workflow::setId方法代码示例

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


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

示例1: makeWorkflowBySavedWorkflow

 /**
  * @param SavedWorkflow $savedWorkflow
  * @return Workflow
  */
 public static function makeWorkflowBySavedWorkflow(SavedWorkflow $savedWorkflow)
 {
     $workflow = new Workflow();
     if ($savedWorkflow->id > 0) {
         $workflow->setId((int) $savedWorkflow->id);
     }
     $workflow->setDescription($savedWorkflow->description);
     $workflow->setIsActive((bool) $savedWorkflow->isActive);
     $workflow->setModuleClassName($savedWorkflow->moduleClassName);
     $workflow->setName($savedWorkflow->name);
     $workflow->setOrder((int) $savedWorkflow->order);
     $workflow->setType($savedWorkflow->type);
     $workflow->setTriggerOn($savedWorkflow->triggerOn);
     if ($savedWorkflow->serializedData != null) {
         $unserializedData = unserialize($savedWorkflow->serializedData);
         if (isset($unserializedData['triggersStructure'])) {
             $workflow->setTriggersStructure($unserializedData['triggersStructure']);
         }
         self::makeComponentFormAndPopulateWorkflowFromData($unserializedData[ComponentForWorkflowForm::TYPE_TRIGGERS], $workflow, 'Trigger');
         self::makeActionForWorkflowFormAndPopulateWorkflowFromData($unserializedData[ComponentForWorkflowForm::TYPE_ACTIONS], $workflow);
         self::makeEmailMessageForWorkflowFormAndPopulateWorkflowFromData($unserializedData[ComponentForWorkflowForm::TYPE_EMAIL_MESSAGES], $workflow);
         if (isset($unserializedData[ComponentForWorkflowForm::TYPE_TIME_TRIGGER])) {
             $moduleClassName = $workflow->getModuleClassName();
             $timeTrigger = new TimeTriggerForWorkflowForm($moduleClassName, $moduleClassName::getPrimaryModelName(), $workflow->getType());
             $timeTrigger->setAttributes($unserializedData[ComponentForWorkflowForm::TYPE_TIME_TRIGGER]);
             $workflow->setTimeTrigger($timeTrigger);
             $workflow->setTimeTriggerAttribute($timeTrigger->getAttributeIndexOrDerivedType());
         }
     }
     return $workflow;
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:35,代码来源:SavedWorkflowToWorkflowAdapter.php

示例2: testSetAndGetWorkflow

 /**
  * @depends testGetWorkflowSupportedModulesClassNamesCurrentUserHasAccessTo
  */
 public function testSetAndGetWorkflow()
 {
     $timeTrigger = new TimeTriggerForWorkflowForm('WorkflowsTestModule', 'WorkflowModelTestItem', Workflow::TYPE_ON_SAVE);
     $action = new ActionForWorkflowForm('WorkflowModelTestItem', Workflow::TYPE_ON_SAVE);
     $emailMessage = new EmailMessageForWorkflowForm('WorkflowModelTestItem', Workflow::TYPE_ON_SAVE);
     $trigger = new TriggerForWorkflowForm('WorkflowsTestModule', 'WorkflowModelTestItem', Workflow::TYPE_ON_SAVE);
     $workflow = new Workflow();
     $workflow->setModuleClassName('SomeModule');
     $workflow->setDescription('a description');
     $workflow->setTriggersStructure('1 AND 2');
     $workflow->setTimeTriggerAttribute('something');
     $workflow->setId(5);
     $workflow->setIsActive(true);
     $workflow->setOrder(6);
     $workflow->setName('my workflow rule');
     $workflow->setTriggerOn(Workflow::TRIGGER_ON_NEW);
     $workflow->setType(Workflow::TYPE_ON_SAVE);
     $workflow->setTimeTrigger($timeTrigger);
     $workflow->addTrigger($trigger);
     $workflow->addAction($action);
     $workflow->addEmailMessage($emailMessage);
     $this->assertEquals('SomeModule', $workflow->getModuleClassName());
     $this->assertEquals('a description', $workflow->getDescription());
     $this->assertEquals('1 AND 2', $workflow->getTriggersStructure());
     $this->assertEquals('something', $workflow->getTimeTriggerAttribute());
     $this->assertEquals(5, $workflow->getId());
     $this->assertTrue($workflow->getIsActive());
     $this->assertEquals(6, $workflow->getOrder());
     $this->assertEquals('my workflow rule', $workflow->getName());
     $this->assertEquals(Workflow::TRIGGER_ON_NEW, $workflow->getTriggerOn());
     $this->assertEquals(Workflow::TYPE_ON_SAVE, $workflow->getType());
     $this->assertEquals($timeTrigger, $workflow->getTimeTrigger());
     $actions = $workflow->getActions();
     $this->assertEquals($action, $actions[0]);
     $this->assertCount(1, $actions);
     $emailMessages = $workflow->getEmailMessages();
     $this->assertEquals($emailMessage, $emailMessages[0]);
     $this->assertCount(1, $emailMessages);
     $triggers = $workflow->getTriggers();
     $this->assertEquals($trigger, $triggers[0]);
     $this->assertCount(1, $triggers);
     $workflow->removeAllActions();
     $actions = $workflow->getActions();
     $this->assertCount(0, $actions);
     $workflow->removeAllEmailMessages();
     $emailMessages = $workflow->getEmailMessages();
     $this->assertCount(0, $emailMessages);
     $workflow->removeAllTriggers();
     $triggers = $workflow->getTriggers();
     $this->assertCount(0, $triggers);
     $workflow->removeTimeTrigger();
     $this->assertNull($workflow->getTimeTrigger());
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:56,代码来源:WorkflowTest.php

示例3: testProcessAfterSaveWhenSendIsImmediateAndToAContactThatIsRelatedToTheTriggeredModel

 public function testProcessAfterSaveWhenSendIsImmediateAndToAContactThatIsRelatedToTheTriggeredModel()
 {
     foreach (EmailMessage::getAll() as $emailMessage) {
         $emailMessage->delete();
     }
     $this->assertEquals(0, Yii::app()->emailHelper->getQueuedCount());
     $this->assertEquals(0, Yii::app()->emailHelper->getSentCount());
     $emailTemplate = new EmailTemplate();
     $emailTemplate->name = 'the name';
     $emailTemplate->modelClassName = 'Account';
     $emailTemplate->textContent = 'some content';
     $emailTemplate->type = 2;
     $emailTemplate->subject = 'subject';
     $saved = $emailTemplate->save();
     $this->assertTrue($saved);
     $workflow = new Workflow();
     $workflow->setId(self::$savedWorkflow->id);
     $workflow->type = Workflow::TYPE_ON_SAVE;
     $emailMessageForm = new EmailMessageForWorkflowForm('Account', Workflow::TYPE_ON_SAVE);
     $emailMessageForm->sendAfterDurationSeconds = 0;
     $emailMessageForm->emailTemplateId = $emailTemplate->id;
     $emailMessageForm->sendFromType = EmailMessageForWorkflowForm::SEND_FROM_TYPE_DEFAULT;
     $recipients = array(array('type' => WorkflowEmailMessageRecipientForm::TYPE_DYNAMIC_TRIGGERED_MODEL_RELATION, 'audienceType' => EmailMessageRecipient::TYPE_TO, 'relation' => 'contacts'));
     $emailMessageForm->setAttributes(array(EmailMessageForWorkflowForm::EMAIL_MESSAGE_RECIPIENTS => $recipients));
     $workflow->addEmailMessage($emailMessageForm);
     $model = new Account();
     $model->name = 'the account';
     $contact = new Contact();
     $contact->firstName = 'Jason';
     $contact->lastName = 'Blue';
     $contact->state = ContactsUtil::getStartingState();
     $contact->primaryEmail->emailAddress = 'jason@something.com';
     $this->assertTrue($contact->save());
     $contact2 = new Contact();
     $contact2->firstName = 'Laura';
     $contact2->lastName = 'Blue';
     $contact2->state = ContactsUtil::getStartingState();
     $contact2->primaryEmail->emailAddress = 'laura@something.com';
     $this->assertTrue($contact2->save());
     $model->contacts->add($contact);
     $model->contacts->add($contact2);
     $this->assertTrue($model->save());
     WorkflowEmailMessagesUtil::processAfterSave($workflow, $model, Yii::app()->user->userModel);
     $this->assertEquals(1, Yii::app()->emailHelper->getQueuedCount());
     $this->assertEquals(0, Yii::app()->emailHelper->getSentCount());
     $queuedEmailMessages = EmailMessage::getAllByFolderType(EmailFolder::TYPE_OUTBOX);
     $this->assertEquals(1, count($queuedEmailMessages));
     $this->assertEquals(2, count($queuedEmailMessages[0]->recipients));
     $this->assertEquals('Jason Blue', $queuedEmailMessages[0]->recipients[0]->toName);
     $this->assertEquals('jason@something.com', $queuedEmailMessages[0]->recipients[0]->toAddress);
     $this->assertEquals($contact->id, $queuedEmailMessages[0]->recipients[0]->personOrAccount->id);
     $this->assertEquals('Laura Blue', $queuedEmailMessages[0]->recipients[1]->toName);
     $this->assertEquals('laura@something.com', $queuedEmailMessages[0]->recipients[1]->toAddress);
     $this->assertEquals($contact2->id, $queuedEmailMessages[0]->recipients[1]->personOrAccount->id);
 }
开发者ID:sandeep1027,项目名称:zurmo_,代码行数:55,代码来源:WorkflowEmailMessagesUtilTest.php


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