本文整理汇总了PHP中Jelly::builder方法的典型用法代码示例。如果您正苦于以下问题:PHP Jelly::builder方法的具体用法?PHP Jelly::builder怎么用?PHP Jelly::builder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Jelly
的用法示例。
在下文中一共展示了Jelly::builder方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: meta_alias
/**
* Resolves meta-aliases
*
* @param mixed $meta
* @param string $field
* @param mixed $value
* @return string
*/
public static function meta_alias($meta, $field, $value = NULL)
{
// Allow passing the model name
if (is_string($meta) or $meta instanceof Jelly_Model) {
$meta = Jelly::meta($meta);
}
// Check for a model operator
if (substr($field, 0, 1) !== ':') {
list($model, $field) = explode(':', $field);
// Append the : back onto $field, it's key for recognizing the alias below
$field = ':' . $field;
// We should be able to find a valid meta object here
if (FALSE == ($meta = Jelly::meta($model))) {
throw new Kohana_Exception('Meta data for :model was not found while trying to resolve :field', array(':model' => $model, ':field' => $field));
}
}
switch ($field) {
case ':primary_key':
$field = $meta->primary_key();
break;
case ':name_key':
$field = $meta->name_key();
break;
case ':foreign_key':
$field = $meta->foreign_key();
break;
case ':unique_key':
$field = Jelly::builder($meta->model())->unique_key($value);
break;
default:
throw new Kohana_Exception('Unknown meta alias :field', array(':field' => $field));
}
return $field;
}