當前位置: 首頁>>代碼示例>>PHP>>正文


PHP RedBeanModel::isADerivedRelationViaCastedUpModel方法代碼示例

本文整理匯總了PHP中RedBeanModel::isADerivedRelationViaCastedUpModel方法的典型用法代碼示例。如果您正苦於以下問題:PHP RedBeanModel::isADerivedRelationViaCastedUpModel方法的具體用法?PHP RedBeanModel::isADerivedRelationViaCastedUpModel怎麽用?PHP RedBeanModel::isADerivedRelationViaCastedUpModel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在RedBeanModel的用法示例。


在下文中一共展示了RedBeanModel::isADerivedRelationViaCastedUpModel方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: processCreateRelatedAction

 /**
  * Notice the use of $modelToForgetCache. This was needed to avoid a caching issue with the following example.
  * If an opportunity fires, and a related account's opportunity is created. This new opportunity had a cached
  * model for account that was null.  So this is fixed by forgetting the new model after it is added to the account.
  * @throws FailedToSaveModelException
  * @throws NotSupportedException
  */
 protected function processCreateRelatedAction()
 {
     if ($this->action->relationFilter != ActionForWorkflowForm::RELATION_FILTER_ALL) {
         throw new NotSupportedException();
     }
     $modelClassName = get_class($this->triggeredModel);
     if ($this->triggeredModel->isADerivedRelationViaCastedUpModel($this->action->relation) && $this->triggeredModel->getDerivedRelationType($this->action->relation) == RedBeanModel::MANY_MANY) {
         foreach (WorkflowUtil::resolveDerivedModels($this->triggeredModel, $this->action->relation) as $relatedModel) {
             if ($this->resolveCreateModel($relatedModel, $this->action->relatedModelRelation)) {
                 $saved = $relatedModel->save();
                 if (!$saved) {
                     throw new FailedToSaveModelException();
                 }
             }
         }
     } elseif ($this->triggeredModel->getInferredRelationModelClassNamesForRelation(ModelRelationsAndAttributesToWorkflowAdapter::resolveRealAttributeName($this->action->relation)) != null) {
         foreach (WorkflowUtil::getInferredModelsByAtrributeAndModel($this->action->relation, $this->triggeredModel) as $relatedModel) {
             if ($this->resolveCreateModel($relatedModel, $this->action->relatedModelRelation)) {
                 $saved = $relatedModel->save();
                 if (!$saved) {
                     throw new FailedToSaveModelException();
                 }
             }
         }
     } elseif ($this->triggeredModel->{$this->action->relation} instanceof RedBeanMutableRelatedModels) {
         foreach ($this->triggeredModel->{$this->action->relation} as $relatedModel) {
             if ($this->resolveCreateModel($relatedModel, $this->action->relatedModelRelation)) {
                 $saved = $relatedModel->save();
                 if (!$saved) {
                     throw new FailedToSaveModelException();
                 }
             }
         }
     } elseif ($modelClassName::isRelationTypeAHasOneVariant($this->action->relation) && !$modelClassName::isOwnedRelation($this->action->relation)) {
         $relatedModel = $this->triggeredModel->{$this->action->relation};
         $modelToForgetCache = null;
         if ($this->resolveCreateModel($relatedModel, $this->action->relatedModelRelation, $modelToForgetCache)) {
             $saved = $relatedModel->save();
             if (!$saved) {
                 throw new FailedToSaveModelException();
             }
             if ($modelToForgetCache instanceof RedBeanModel) {
                 $modelToForgetCache->forget();
             }
         }
     } else {
         throw new NotSupportedException();
     }
 }
開發者ID:maruthisivaprasad,項目名稱:zurmo,代碼行數:56,代碼來源:WorkflowActionProcessingHelper.php

示例2: makeRecipients

 /**
  * @param RedBeanModel $model
  * @param User $triggeredByUser
  * @return array
  * @throws NotSupportedException
  */
 public function makeRecipients(RedBeanModel $model, User $triggeredByUser)
 {
     $modelClassName = $this->modelClassName;
     $recipients = array();
     if ($model->isADerivedRelationViaCastedUpModel($this->relation) && $model->getDerivedRelationType($this->relation) == RedBeanModel::MANY_MANY) {
         foreach (WorkflowUtil::resolveDerivedModels($model, $this->relation) as $resolvedModel) {
             $recipients = self::resolveRecipientsAsUniquePeople($recipients, $this->resolveRecipients($resolvedModel));
         }
     } elseif ($modelClassName::getInferredRelationModelClassNamesForRelation(ModelRelationsAndAttributesToWorkflowAdapter::resolveRealAttributeName($this->relation)) != null) {
         foreach (WorkflowUtil::getInferredModelsByAtrributeAndModel($this->relation, $model) as $resolvedModel) {
             $recipients = self::resolveRecipientsAsUniquePeople($recipients, $this->resolveRecipients($resolvedModel));
         }
     } elseif ($model->{$this->relation} instanceof RedBeanMutableRelatedModels) {
         if (!$this->relationFilter == self::RELATION_FILTER_ALL) {
             throw new NotSupportedException();
         }
         foreach ($model->{$this->relation} as $resolvedModel) {
             $recipients = self::resolveRecipientsAsUniquePeople($recipients, $this->resolveRecipients($resolvedModel));
         }
     } elseif ($modelClassName::isRelationTypeAHasOneVariant($this->relation)) {
         if ($model->{$this->relation}->id > 0) {
             $recipients = $this->resolveRecipients($model->{$this->relation});
         }
     } else {
         throw new NotSupportedException();
     }
     return $recipients;
 }
開發者ID:maruthisivaprasad,項目名稱:zurmo,代碼行數:34,代碼來源:DynamicTriggeredModelRelationWorkflowEmailMessageRecipientForm.php


注:本文中的RedBeanModel::isADerivedRelationViaCastedUpModel方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。