src/AppBundle/Extensions/DataTag/PublishedArticlesDataTag.php
(开头部分) 1KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
<?php
namespace AppBundle\Extensions\DataTag;
use Biz\Article\Service\ArticleService;
use AppBundle\Common\ArrayToolkit;
class PublishedArticlesDataTag extends CourseBaseDataTag implements DataTag
{
/**
* 获取全部资讯列表.
*
* 可传入的参数:
* count 必需 课程数量,取值不能超过100
* sort: created 创建时间
* published 发布时间,带置顶
* normal 发布时间
* popular 热门
*
* @param array $arguments 参数
*
* @return array 资讯列表
*/
public function getData(array $arguments)
{
$this->checkCount($arguments);
$conditions['status'] = 'published';
$sort = isset($arguments['sort']) ? $arguments['sort'] : 'published';
$articles = $this->getArticleService()->searchArticles($conditions, $sort, 0, $arguments['count']);
if (empty($articles)) {
return array();
}
$categorise = $this->getCategoryService()->findCategoriesByIds(ArrayToolkit::column($articles, 'categoryId'));
foreach ($articles as $key => $article) {
if (empty($article['categoryId'])) {
continue;
}
if (!empty($categorise[$article['categoryId']]) && $categorise[$article['categoryId']]['id'] == $article['categoryId']) {
$articles[$key]['category'] = $categorise[$article['categoryId']];
}
}
return $articles;
}
/**
* @return ArticleService
*/
private function getArticleService()
{
return $this->createService('Article:ArticleService');
}
protected function getCategoryService()
{
return $this->createService('Article:CategoryService');
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。