本文整理汇总了PHP中Entry::fromId方法的典型用法代码示例。如果您正苦于以下问题:PHP Entry::fromId方法的具体用法?PHP Entry::fromId怎么用?PHP Entry::fromId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Entry
的用法示例。
在下文中一共展示了Entry::fromId方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
function create()
{
Auth::checkLoggedIn();
$entry = Entry::fromId(Input::get('entryid'));
if (!$entry->canView(Auth::getUser())) {
throw new Exception('You are not allowed to ask a question in this entry.');
}
$question = Question::create(Auth::getUser(), $entry, Input::get('title'), Input::get('text'), Input::getBoolean('private'));
View::renderJson($question->getContext(Auth::getUser()));
}
示例2: upload_attachment
function upload_attachment()
{
Auth::checkLoggedIn();
$entry = Entry::fromId(Input::get('entryid'));
// Make sure the user can edit this entry
if (!$entry->canEdit(Auth::getUser())) {
throw new Exception('You are not allowed to edit this entry.');
}
// Get the uploaded attachments and add them to the entry
$attachments = Attachment::handleUpload();
foreach ($attachments as $attachment) {
$entry->addAttachment($attachment);
}
// Render the new context
View::renderJson($entry->getContext(Auth::getUser()));
}
示例3: canEdit
/**
* Determines whether or not a given user can edit the question.
* @param User $user The user to check.
* @return boolean
*/
public function canEdit(User $user)
{
// See if they are a professor for the course
$entry = Entry::fromId($this->getEntryId());
if ($entry->canEdit($user)) {
return true;
}
// See if they asked the question
$firstAnswer = QuestionAnswer::fromId($this->getFirstAnswerId());
if ($firstAnswer->getUserId() == $user->getUserId()) {
return true;
}
// They cannot edit
return false;
}