本文整理汇总了PHP中Model\User::dispense方法的典型用法代码示例。如果您正苦于以下问题:PHP User::dispense方法的具体用法?PHP User::dispense怎么用?PHP User::dispense使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model\User
的用法示例。
在下文中一共展示了User::dispense方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: perform
public static function perform(Comment $comment)
{
if ($comment->comment_id) {
return;
}
$article = $comment->article()->find_one();
if ($article->user_id != $comment->user_id) {
Notify::dispense()->create(array('user_id' => $article->user_id, 'from_user_id' => $comment->user_id, 'type' => Notify::REPLY, 'object_type' => $article->type(), 'object_id' => $article->id, 'message' => $comment->text))->save();
}
if (!preg_match_all('/@(\\w+)/', $comment->text, $match)) {
return;
}
$users = array();
foreach ($match[1] as $username) {
if (isset($users[$username])) {
continue;
}
if (!($user = User::dispense()->where('name', $username)->find_one())) {
continue;
}
// If mention in reply, ignore mention notify
if ($user->id == $article->user_id) {
continue;
}
$users[$username] = $user->id;
}
foreach ($users as $user_id) {
Notify::dispense()->create(array('user_id' => $user_id, 'from_user_id' => $comment->user_id, 'type' => Notify::MENTION, 'object_type' => $article->type(), 'object_id' => $article->id, 'message' => $comment->text))->save();
}
}
示例2: get
/**
* GET /
*/
public function get()
{
$id = $this->params['id'];
$post = \Model\User::dispense()->find_one($id);
if (!$post) {
$this->error('Unknown User');
}
$this->data = $post->as_array();
}
示例3: parserUser
public function parserUser($text)
{
return preg_replace_callback('{
(?<!(?:\\[|`))\\s?
@([\\w]{1,20})
\\s(?!(?:\\]|`))
}xs', function ($match) {
if ($user = User::dispense()->where('name', $match[1])->find_one()) {
return '[' . trim($match[0]) . '](' . Url::to('/u/' . $user->id) . ')';
} else {
return $match[0];
}
}, $text);
}