src/Biz/Course/Job/CloneCourseSetJob.php

(开头部分) 1KB

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

<?php

namespace Biz\Course\Job;

use Biz\Course\Service\CourseSetService;
use Biz\User\CurrentUser;
use Biz\User\Service\NotificationService;
use Biz\User\Service\UserService;
use Codeages\Biz\Framework\Scheduler\AbstractJob;
use Biz\Role\Util\PermissionBuilder;

class CloneCourseSetJob extends AbstractJob
{
    public function execute()
    {
        $currentUser = $this->biz['user'];
        $userId = $this->args['userId'];
        $user = $this->getUserService()->getUser($userId);
        $user['currentIp'] = '127.0.0.1';
        if (!empty($user)) {
            $this->setCurrentUser($user);
        }

        $courseSetId = $this->args['courseSetId'];
        $courseSet = $this->getCourseSetService()->getCourseSet($courseSetId);
        $params = $this->args['params'];
        $originTitle = $courseSet['title'];
        $newTitle = $params['title'];
        $message = array(
            'newTitle' => $newTitle,
            'originTitle' => $originTitle,
        );

        try {
            $this->getCourseSetService()->cloneCourseSet($courseSetId, $params);
            $message['status'] = 'success';
            $this->getNotificationService()->notify($userId, 'course-copy', $message);
        } catch (\Exception $e) {
            $message['status'] = 'failure';
            $this->getNotificationService()->notify($userId, 'course-copy', $message);
        }

        $this->setCurrentUser($currentUser->toArray());
    }

    private function setCurrentUser($user)
    {
        $currentUser = new CurrentUser();
        $currentUser->fromArray($user);
        $currentUser->setPermissions(PermissionBuilder::instance()->getPermissionsByRoles($currentUser->getRoles()));
        $this->biz['user'] = $currentUser;
    }

    /**
     * @return CourseSetService
     */
    private function getCourseSetService()
    {
        return $this->biz->service('Course:CourseSetService');
    }

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

AI 解读 AI

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

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