当前位置: 首页>>代码示例>>PHP>>正文


PHP Entry::fromId方法代码示例

本文整理汇总了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()));
 }
开发者ID:brandonfrancis,项目名称:scsapi,代码行数:10,代码来源:question_controller.php

示例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()));
 }
开发者ID:brandonfrancis,项目名称:scsapi,代码行数:16,代码来源:entry_controller.php

示例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;
 }
开发者ID:brandonfrancis,项目名称:scsapi,代码行数:20,代码来源:question.php


注:本文中的Entry::fromId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。