2023-06-22 18:10:30 +00:00
|
|
|
<?php
|
2023-06-23 07:44:48 +00:00
|
|
|
|
2023-06-22 18:10:30 +00:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace OCA\RePod\AppInfo;
|
|
|
|
|
2024-01-18 10:43:58 +00:00
|
|
|
use OCA\RePod\Service\SearchProvider;
|
2023-07-04 15:43:58 +00:00
|
|
|
use OCP\App\AppPathNotFoundException;
|
2023-07-03 14:17:00 +00:00
|
|
|
use OCP\App\IAppManager;
|
2023-06-22 18:10:30 +00:00
|
|
|
use OCP\AppFramework\App;
|
2023-07-03 14:17:00 +00:00
|
|
|
use OCP\AppFramework\Bootstrap\IBootContext;
|
|
|
|
use OCP\AppFramework\Bootstrap\IBootstrap;
|
|
|
|
use OCP\AppFramework\Bootstrap\IRegistrationContext;
|
2023-12-23 23:24:46 +00:00
|
|
|
use OCP\AppFramework\Services\IInitialState;
|
2023-06-22 18:10:30 +00:00
|
|
|
|
2023-07-03 14:17:00 +00:00
|
|
|
class Application extends App implements IBootstrap
|
2023-06-24 16:37:25 +00:00
|
|
|
{
|
2023-06-22 18:10:30 +00:00
|
|
|
public const APP_ID = 'repod';
|
2024-11-10 12:18:53 +00:00
|
|
|
|
2023-07-03 14:17:00 +00:00
|
|
|
private const GPODDERSYNC_ID = 'gpoddersync';
|
2023-06-22 18:10:30 +00:00
|
|
|
|
2023-12-23 16:25:20 +00:00
|
|
|
public function __construct() {
|
2023-06-22 18:10:30 +00:00
|
|
|
parent::__construct(self::APP_ID);
|
|
|
|
}
|
2023-07-03 14:17:00 +00:00
|
|
|
|
2023-12-23 16:25:20 +00:00
|
|
|
public function boot(IBootContext $context): void {
|
2023-07-03 14:17:00 +00:00
|
|
|
/** @psalm-suppress DeprecatedInterface */
|
|
|
|
$appContainer = $context->getAppContainer();
|
2023-07-27 21:01:24 +00:00
|
|
|
|
2023-07-03 14:17:00 +00:00
|
|
|
/** @var IAppManager $appManager */
|
|
|
|
$appManager = $appContainer->get(IAppManager::class);
|
|
|
|
|
2023-12-23 23:24:46 +00:00
|
|
|
/** @var IInitialState $initialState */
|
|
|
|
$initialState = $appContainer->get(IInitialState::class);
|
|
|
|
|
2024-08-26 14:10:30 +00:00
|
|
|
if (null === $appManager->getAppInfo(self::GPODDERSYNC_ID)) {
|
|
|
|
$appManager->disableApp(self::GPODDERSYNC_ID);
|
|
|
|
}
|
|
|
|
|
2023-07-04 15:43:58 +00:00
|
|
|
$gpoddersync = $appManager->isEnabledForUser(self::GPODDERSYNC_ID);
|
2023-07-03 14:17:00 +00:00
|
|
|
if (!$gpoddersync) {
|
2023-07-04 15:43:58 +00:00
|
|
|
try {
|
|
|
|
$appManager->enableApp(self::GPODDERSYNC_ID);
|
2024-11-10 12:18:53 +00:00
|
|
|
} catch (AppPathNotFoundException) {
|
2023-07-04 15:43:58 +00:00
|
|
|
}
|
2023-07-03 14:17:00 +00:00
|
|
|
}
|
2023-07-04 15:43:58 +00:00
|
|
|
|
2023-12-23 23:24:46 +00:00
|
|
|
$gpoddersync = $appManager->isEnabledForUser(self::GPODDERSYNC_ID);
|
|
|
|
$initialState->provideInitialState('gpodder', $gpoddersync);
|
2023-07-03 14:17:00 +00:00
|
|
|
}
|
|
|
|
|
2024-01-18 10:43:58 +00:00
|
|
|
public function register(IRegistrationContext $context): void {
|
|
|
|
$context->registerSearchProvider(SearchProvider::class);
|
|
|
|
}
|
2023-06-22 18:10:30 +00:00
|
|
|
}
|