add a way to create custom categories and manage application categories
This commit is contained in:
@@ -21,10 +21,27 @@ class AppRepository
|
||||
*/
|
||||
protected $l10nFactory;
|
||||
|
||||
public function __construct(\OC_App $ocApp, IFactory $l10nFactory)
|
||||
/**
|
||||
* @var ConfigProxy
|
||||
*/
|
||||
protected $config;
|
||||
|
||||
/**
|
||||
* @var CategoryRepository
|
||||
*/
|
||||
protected $categoryRepository;
|
||||
|
||||
public function __construct(
|
||||
\OC_App $ocApp,
|
||||
IFactory $l10nFactory,
|
||||
ConfigProxy $config,
|
||||
CategoryRepository $categoryRepository
|
||||
)
|
||||
{
|
||||
$this->ocApp = $ocApp;
|
||||
$this->l10nFactory = $l10nFactory;
|
||||
$this->config = $config;
|
||||
$this->categoryRepository = $categoryRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -35,6 +52,9 @@ class AppRepository
|
||||
public function getVisibleApps()
|
||||
{
|
||||
$navigation = $this->ocApp->getNavigation();
|
||||
$appCategoriesCustom = $this->config->getAppValueArray('apps-categories-custom', '[]');
|
||||
$categoriesCustom = $this->config->getAppValueArray('categories-custom', '[]');
|
||||
$categories = $this->categoryRepository->getOrderedCategories();
|
||||
$apps = $this->ocApp->listAllApps();
|
||||
$visibleApps = [];
|
||||
|
||||
@@ -74,6 +94,12 @@ class AppRepository
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($visibleApps as $id => $app) {
|
||||
if (isset($appCategoriesCustom[$id]) && (isset($categoriesCustom[$id]) || isset($categories[$id]))) {
|
||||
$visibleApps[$id]['category'] = [$appCategoriesCustom[$id]];
|
||||
}
|
||||
}
|
||||
|
||||
usort($visibleApps, function ($a, $b) {
|
||||
return ($a['name'] < $b['name']) ? -1 : 1;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user