src/AppBundle/Controller/TagController.php

(开头部分) 1KB

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

<?php

namespace AppBundle\Controller;

use Biz\Course\Service\CourseService;
use Biz\Course\Service\CourseSetService;
use Biz\System\Service\SettingService;
use Biz\Taxonomy\Service\TagService;
use AppBundle\Common\Paginator;
use AppBundle\Common\ArrayToolkit;
use Symfony\Component\HttpFoundation\Request;

class TagController extends BaseController
{
    /**
     * 获取所有标签,以JSONM的方式返回数据.
     *
     * @return JSONM Response
     */
    public function allAction()
    {
        $data = array();

        $tags = $this->getTagService()->findAllTags(0, 100);
        foreach ($tags as $tag) {
            $data[] = array('id' => $tag['id'], 'name' => $tag['name']);
        }

        return $this->createJsonmResponse($data);
    }

    public function indexAction()
    {
        $tags = $this->getTagService()->findAllTags(0, 100);

        return $this->render('tag/index.html.twig', array(
            'tags' => $tags,
        ));
    }

    public function showAction(Request $request, $name)
    {
        $courseSets = $paginator = null;

        $tag = $this->getTagService()->getTagByName($name);

        if ($tag) {
            $tagOwnerRelations = $this->getTagService()->findTagOwnerRelationsByTagIdsAndOwnerType(array($tag['id']), 'course-set');

            $courseIds = ArrayToolkit::column($tagOwnerRelations, 'ownerId');
            if (empty($courseIds)) {
                $courseIds = array(0);
            }

            $conditions = array(
                'status' => 'published',
                'ids' => $courseIds,
                'parentId' => 0,
            );

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

AI 解读 AI

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

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