src/AppBundle/Controller/Course/MaterialController.php

(开头部分) 2KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

<?php

namespace AppBundle\Controller\Course;

use AppBundle\Common\Paginator;
use AppBundle\Common\ArrayToolkit;
use Biz\Course\MaterialException;
use Biz\Course\MemberException;
use Symfony\Component\HttpFoundation\Request;

class MaterialController extends CourseBaseController
{
    public function indexAction(Request $request, $course, $member = array())
    {
        $courseMember = $this->getCourseMember($request, $course);
        if (empty($courseMember)) {
            $this->createNewException(MemberException::NOTFOUND_MEMBER());
        }

        $courseSet = $this->getCourseSetService()->getCourseSet($course['courseSetId']);

        $conditions = array(
            'courseId' => $course['id'],
            'excludeLessonId' => 0,
            'source' => 'coursematerial',
            'type' => 'course',
        );

        $paginator = new Paginator(
            $request,
            $this->getMaterialService()->countMaterials($conditions),
            20
        );

        $materials = $this->getMaterialService()->searchMaterials(
            $conditions,
            array('createdTime' => 'DESC'),
            $paginator->getOffsetCount(),
            $paginator->getPerPageCount()
        );

        $tasks = $this->getTaskService()->searchTasks(array('courseId' => $course['id'], 'type' => 'download'), array(), 0, 100);
        $tasks = ArrayToolkit::index($tasks, 'activityId');

        return $this->render('course/tabs/material.html.twig', array(
            'courseSet' => $courseSet,
            'course' => $course,
            'member' => $member,
            'tasks' => $tasks,
            'materials' => $materials,
            'paginator' => $paginator,
        ));
    }

    public function downloadAction(Request $request, $courseId, $materialId)
    {
        list($course, $member) = $this->getCourseService()->tryTakeCourse($courseId);

        if ($member && !$this->getMemberService()->isMemberNonExpired($course, $member)) {
            return $this->redirect($this->generateUrl('my_course_show', array('id' => $courseId, 'tab' => 'material')));

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。