src/AppBundle/Controller/ContentController.php
(开头部分) 1KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
<?php
namespace AppBundle\Controller;
use Biz\Content\ContentException;
use Biz\Content\Service\ContentService;
use Biz\Taxonomy\Service\CategoryService;
use Symfony\Component\HttpFoundation\Request;
use AppBundle\Common\Paginator;
use AppBundle\Common\ArrayToolkit;
class ContentController extends BaseController
{
public function articleShowAction(Request $request, $alias)
{
$content = $this->getContentByAlias('article', $alias);
return $this->render('content/show.html.twig', array(
'type' => 'article',
'content' => $content,
));
}
public function articleListAction(Request $request)
{
$conditions = array(
'type' => 'article',
'status' => 'published',
'promoted' => '1',
'categoryId' => $request->query->get('categoryId'),
);
$conditions = array_filter($conditions);
$paginator = new Paginator(
$this->get('request'),
$this->getContentService()->searchContentCount($conditions),
10
);
$contents = $this->getContentService()->searchContents(
$conditions, 'latest',
$paginator->getOffsetCount(),
$paginator->getPerPageCount()
);
$categoryIds = ArrayToolkit::column($contents, 'categoryId');
$categories = $this->getCategoryService()->findCategoriesByIds($categoryIds);
$group = $this->getCategoryService()->getGroupByCode('default');
$categoryTree = $this->getCategoryService()->getCategoryTree($group['id']);
return $this->render('content/list.html.twig', array(
'type' => 'article',
'contents' => $contents,
'categories' => $categories,
'categoryTree' => $categoryTree,
'paginator' => $paginator,
));
}
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。