本文整理汇总了PHP中Jam::find_or_build方法的典型用法代码示例。如果您正苦于以下问题:PHP Jam::find_or_build方法的具体用法?PHP Jam::find_or_build怎么用?PHP Jam::find_or_build使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Jam
的用法示例。
在下文中一共展示了Jam::find_or_build方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_user
public function get_user()
{
if ($this->enabled() and $this->logged_in()) {
$user = Jam::find_or_build($this->_user_model, array($this->_service_field => $this->service_uid()));
$user->_is_new = TRUE;
$data = $this->service_user_info();
if (!$user->loaded()) {
if (isset($data['email'])) {
$user = Jam::find_or_build($this->_user_model, array('email' => $data['email']));
if ($user->loaded()) {
$user->_is_new = FALSE;
}
}
if (!$user->loaded() and Arr::get($this->_config, 'create_user')) {
$user = $this->build_user($data, TRUE);
}
if (!$user) {
throw new Auth_Exception_Service('Service :service user with service uid :id does not exist and faild to create', array(':service' => $this->type(), ':id' => $this->service_uid()));
}
$user->set($this->_service_field, $this->service_uid());
$user->save();
} elseif (Arr::get($this->_config, 'update_user')) {
$user->_is_new = FALSE;
$user->load_service_values($this, $data, FALSE);
$user->save();
} else {
$user->_is_new = FALSE;
}
return $user;
}
return FALSE;
}
示例2: model_before_check
public function model_before_check(Jam_Model $model)
{
if (!$model->loaded() or $model->changed($this->_ip_field)) {
$info = $this->geoip_record($model->{$this->_ip_field});
foreach ($this->_locations as $association => $info_name) {
if (isset($info[$info_name])) {
$model->{$association} = Jam::find_or_build('location', array('name' => $info[$info_name]));
}
}
}
}