src/ApiBundle/Api/Resource/Course/CourseAttachment.php

(开头部分) 1KB

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

<?php

namespace ApiBundle\Api\Resource\Course;

use ApiBundle\Api\ApiRequest;
use ApiBundle\Api\Resource\AbstractResource;
use AppBundle\Common\ArrayToolkit;
use Biz\Common\CommonException;
use Biz\File\UploadFileException;

class CourseAttachment extends AbstractResource
{
    public function get(ApiRequest $request, $courseId, $fileId)
    {
        $params = $request->query->all();
        if (!ArrayToolkit::requireds($params, array('targetType', 'targetId'))) {
            throw CommonException::ERROR_PARAMETER_MISSING();
        }
        $this->getCourseService()->tryTakeCourse($courseId);
        $fileUseds = $this->getUploadFileService()->findUseFilesByTargetTypeAndTargetIdAndType($params['targetType'], $params['targetId'], 'attachment', false);

        if (!in_array($fileId, ArrayToolkit::column($fileUseds, 'fileId'))) {
            throw UploadFileException::NOTFOUND_FILE();
        }

        $download = $this->getUploadFileService()->getDownloadMetas($fileId);

        return array('url' => $download['url']);
    }

    /**
     * @return \Biz\File\Service\Impl\UploadFileServiceImpl
     */
    protected function getUploadFileService()
    {
        return $this->service('File:UploadFileService');
    }

    /**
     * @return \Biz\Course\Service\Impl\CourseServiceImpl
     */
    protected function getCourseService()
    {
        return $this->service('Course:CourseService');
    }
}

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

AI 解读 AI

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

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