src/Biz/Article/Service/Impl/CategoryServiceImpl.php
(开头部分) 1KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
<?php
namespace Biz\Article\Service\Impl;
use Biz\Article\CategoryException;
use Biz\Article\Dao\CategoryDao;
use Biz\Article\Service\CategoryService;
use Biz\BaseService;
use Biz\Common\CommonException;
use Biz\System\Service\LogService;
use AppBundle\Common\ArrayToolkit;
use AppBundle\Common\TreeToolkit;
use AppBundle\Common\Tree;
class CategoryServiceImpl extends BaseService implements CategoryService
{
public function getCategory($id)
{
return $this->getCategoryDao()->get($id);
}
public function getCategoryByCode($code)
{
return $this->getCategoryDao()->findByCode($code);
}
public function getCategoryTree($isPublished = false)
{
$prepare = function ($categories) {
$prepared = array();
foreach ($categories as $category) {
if (!isset($prepared[$category['parentId']])) {
$prepared[$category['parentId']] = array();
}
$prepared[$category['parentId']][] = $category;
}
return $prepared;
};
if ($isPublished) {
$categories = $this->getCategoryDao()->search(array('published' => 1), null, 0, PHP_INT_MAX);
} else {
$categories = $this->findAllCategories();
}
$categories = $prepare($categories);
$tree = array();
$this->makeCategoryTree($tree, $categories, 0);
return $tree;
}
public function getCategoryStructureTree()
{
return TreeToolkit::makeTree($this->getCategoryTree(), 'weight');
}
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。