71 lines
1.6 KiB
PHP
71 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace OCA\SideMenu\Service;
|
|
|
|
use \OC_App;
|
|
|
|
/**
|
|
* class AppRepository.
|
|
*
|
|
* @author Simon Vieille <simon@deblan.fr>
|
|
*/
|
|
class AppRepository
|
|
{
|
|
/**
|
|
* @var OC_App
|
|
*/
|
|
protected $ocApp;
|
|
|
|
/**
|
|
* @param OC_App $ocApp
|
|
*/
|
|
public function __construct(OC_App $ocApp)
|
|
{
|
|
$this->ocApp = $ocApp;
|
|
}
|
|
|
|
/**
|
|
* Retrieves visibles apps.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function getVisibleApps()
|
|
{
|
|
$navigation = $this->ocApp->getNavigation();
|
|
$apps = $this->ocApp->listAllApps();
|
|
$visibleApps = [];
|
|
|
|
foreach ($apps as $app) {
|
|
$id = $app['id'];
|
|
|
|
if (isset($navigation[$id])) {
|
|
$visibleApps[$id] = $app;
|
|
}
|
|
}
|
|
|
|
foreach ($navigation as $app) {
|
|
if (substr($app['id'], 0, 14) === 'external_index') {
|
|
$visibleApps[$app['id']] = [
|
|
'id' => $app['id'],
|
|
'name' => $app['name'],
|
|
'preview' => $app['icon'],
|
|
'previewAsIcon' => true,
|
|
'category' => [
|
|
'external_links',
|
|
],
|
|
];
|
|
} elseif ($app['id'] === 'files') {
|
|
$visibleApps[$app['id']] = [
|
|
'id' => $app['id'],
|
|
'name' => $app['name'],
|
|
'preview' => $app['icon'],
|
|
'previewAsIcon' => true,
|
|
'category' => [],
|
|
];
|
|
}
|
|
}
|
|
|
|
return $visibleApps;
|
|
}
|
|
}
|