本文整理汇总了PHP中RedBeanModel::isAttribute方法的典型用法代码示例。如果您正苦于以下问题:PHP RedBeanModel::isAttribute方法的具体用法?PHP RedBeanModel::isAttribute怎么用?PHP RedBeanModel::isAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RedBeanModel
的用法示例。
在下文中一共展示了RedBeanModel::isAttribute方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: relationIsReportedAsAttribute
/**
* @param string $relation
* @return bool
*/
public function relationIsReportedAsAttribute($relation)
{
assert('is_string($relation)');
if ($this->model->isAttribute($relation) && $this->isReportedOnAsARelation($relation)) {
return false;
}
if ($this->model->isAttribute($relation) && !$this->model->isRelation($relation)) {
return false;
}
if ($this->isDerivedAttribute($relation)) {
return false;
}
return $this->rules->relationIsReportedAsAttribute($this->model, $relation);
}
示例2: relationLinksToPrecedingRelation
/**
* @param string $relation
* @param null|RedBeanModel $precedingModel
* @param null|string $precedingRelation
* @return bool
*/
protected function relationLinksToPrecedingRelation($relation, RedBeanModel $precedingModel = null, $precedingRelation = null)
{
assert('is_string($relation)');
if ($precedingModel == null || $precedingRelation == null) {
return false;
}
//Check if the relation is a derived relation in which case return false because it is handled by
//@see self::inferredRelationLinksToPrecedingRelation
if (!$precedingModel->isAttribute($precedingRelation)) {
return false;
}
if (get_class($precedingModel) != $this->model->getRelationmodelClassName($relation)) {
return false;
}
if ($precedingModel->getRelationLinkType($precedingRelation) == RedBeanModel::LINK_TYPE_ASSUMPTIVE && $this->model->getRelationLinkType($relation) == RedBeanModel::LINK_TYPE_ASSUMPTIVE) {
return true;
}
//Check for LINK_TYPE_SPECIFIC
if ($precedingModel->getRelationLinkType($precedingRelation) == RedBeanModel::LINK_TYPE_SPECIFIC && $this->model->getRelationLinkType($relation) == RedBeanModel::LINK_TYPE_SPECIFIC && $precedingModel->getRelationLinkName($precedingRelation) == $this->model->getRelationLinkName($relation)) {
return true;
}
return false;
}
示例3: manageModelRelations
/**
* @param RedBeanModel $model
* @param array $modelRelations
* @return bool
* @throws ApiException
*/
protected function manageModelRelations($model, $modelRelations)
{
try {
if (isset($modelRelations) && !empty($modelRelations)) {
foreach ($modelRelations as $modelRelation => $relations) {
if ($model->isAttribute($modelRelation) && ($model->getRelationType($modelRelation) == RedBeanModel::HAS_MANY || $model->getRelationType($modelRelation) == RedBeanModel::MANY_MANY)) {
foreach ($relations as $relation) {
$relatedModelClassName = $relation['modelClassName'];
try {
$relatedModel = $relatedModelClassName::getById(intval($relation['modelId']));
} catch (Exception $e) {
$message = Zurmo::t('ZurmoModule', 'The related model ID specified was invalid.');
throw new NotFoundException($message);
}
if ($relation['action'] == 'add') {
$model->{$modelRelation}->add($relatedModel);
} elseif ($relation['action'] == 'remove') {
$model->{$modelRelation}->remove($relatedModel);
} else {
$message = Zurmo::t('ZurmoModule', 'Unsupported action.');
throw new NotSupportedException($message);
}
}
} else {
$message = Zurmo::t('ZurmoModule', 'You can add relations only for HAS_MANY and MANY_MANY relations.');
throw new NotSupportedException($message);
}
}
}
} catch (Exception $e) {
$message = $e->getMessage();
throw new ApiException($message);
}
return true;
}
示例4: resolveModelAttributeValueForPenultimateRelation
/**
* @param RedBeanModel $model
* @param string $attribute
* @param DisplayAttributeForReportForm $displayAttribute
* @return mixedg $value
* @throws NotSupportedException
*/
protected function resolveModelAttributeValueForPenultimateRelation(RedBeanModel $model, $attribute, DisplayAttributeForReportForm $displayAttribute)
{
if ($model->isAttribute($attribute)) {
return $model->{$attribute};
}
$penultimateRelation = $displayAttribute->getPenultimateRelation();
if (!$model->isAttribute($penultimateRelation)) {
throw new NotSupportedException();
}
return $model->{$penultimateRelation}->{$attribute};
}
示例5: resolveModelAttributeValueForPenultimateRelation
/**
* The check for OwnedModel below, is because it is possible that something like Address 'state' would be coming
* into this method for retrieval. but depending how things are called, it might need to use the penultimate
* relation instead of looking for the attribute on the $model.
* @param RedBeanModel $model
* @param string $attribute
* @param DisplayAttributeForReportForm $displayAttribute
* @return mixedg $value
* @throws NotSupportedException
*/
protected function resolveModelAttributeValueForPenultimateRelation(RedBeanModel $model, $attribute, DisplayAttributeForReportForm $displayAttribute)
{
if ($model->isAttribute($attribute) && !is_subclass_of($displayAttribute->getResolvedAttributeModelClassName(), 'OwnedModel')) {
return $model->{$attribute};
}
$penultimateRelation = $displayAttribute->getPenultimateRelation();
if (!$model->isAttribute($penultimateRelation)) {
//Fallback. For some reason this could in fact reference the original $model attribute, but because it is
//not owned, it gets confused. todo: need to investigate this further because this is not proper.
if ($model->isAttribute($attribute)) {
return $model->{$attribute};
}
throw new NotSupportedException();
}
return $model->{$penultimateRelation}->{$attribute};
}