本文整理汇总了PHP中RedBeanModel::getDerivedRelationType方法的典型用法代码示例。如果您正苦于以下问题:PHP RedBeanModel::getDerivedRelationType方法的具体用法?PHP RedBeanModel::getDerivedRelationType怎么用?PHP RedBeanModel::getDerivedRelationType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RedBeanModel
的用法示例。
在下文中一共展示了RedBeanModel::getDerivedRelationType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
}
示例2: isRelationASingularRelation
/**
* @param string $relation
* @return bool
* @throws NotSupportedException if the relation string is malformed
*/
public function isRelationASingularRelation($relation)
{
assert('is_string($relation)');
$delimiter = FormModelUtil::DELIMITER;
$relationAndInferredData = explode($delimiter, $relation);
$derivedRelations = $this->getDerivedRelationsViaCastedUpModelData();
if (count($relationAndInferredData) == 3) {
list($modelClassName, $relation, $notUsed) = $relationAndInferredData;
$type = $this->model->getRelationType($relation);
} elseif (count($relationAndInferredData) == 2) {
list($relation, $notUsed) = $relationAndInferredData;
$type = $this->model->getRelationType($relation);
} elseif (count($relationAndInferredData) == 1 && isset($derivedRelations[$relation])) {
$type = $this->model->getDerivedRelationType($relation);
} elseif (count($relationAndInferredData) == 1) {
$type = $this->model->getRelationType($relation);
} else {
throw new NotSupportedException();
}
if ($type == RedBeanModel::HAS_ONE || $type == RedBeanModel::HAS_ONE_BELONGS_TO || $type == RedBeanModel::HAS_MANY_BELONGS_TO) {
return true;
}
return false;
}
示例3: 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