src/Biz/User/Event/CourseThreadEventSubscriber.php
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
<?php
namespace Biz\User\Event;
use Biz\Classroom\Service\ClassroomService;
use Biz\Course\Service\CourseService;
use Biz\Course\Service\MemberService;
use Biz\Course\Service\ThreadService;
use Biz\User\Service\StatusService;
use Codeages\Biz\Framework\Event\Event;
use Codeages\PluginBundle\Event\EventSubscriber;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class CourseThreadEventSubscriber extends EventSubscriber implements EventSubscriberInterface
{
public static function getSubscribedEvents()
{
return array(
'course.thread.post.create' => 'onThreadPostCreate',
);
}
public function onThreadPostCreate(Event $event)
{
$post = $event->getSubject();
$thread = $this->getThreadService()->getThread($post['courseId'], $post['threadId']);
$course = $this->getCourseService()->getCourse($post['courseId']);
if ($course['parentId']) {
$classrooms = $this->getClassroomService()->findClassroomIdsByCourseId($course['id']);
$classroom = array_shift($classrooms);
$isTeacher = $this->getClassroomService()->isClassroomTeacher($classroom['classroomId'], $post['userId']);
} else {
$isTeacher = $this->getCourseMemberService()->isCourseTeacher($post['courseId'], $post['userId']);
}
if ($isTeacher && $thread['type'] == 'question') {
$this->getStatusService()->publishStatus(array(
'userId' => $thread['userId'],
'courseId' => $post['courseId'],
'type' => 'teacher_thread_post',
'objectType' => 'thread_post',
'objectId' => $post['id'],
'private' => $course['status'] == 'published' ? 0 : 1,
'properties' => array(
'thread' => $thread,
'post' => $post,
),
));
}
}
/**
* @return StatusService
*/
protected function getStatusService()
{
return $this->getBiz()->service('User:StatusService');
}
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。