repod/lib/AppInfo/Application.php
Michel Roux 1eeb718a88
All checks were successful
repod / xml (push) Successful in 28s
repod / php (push) Successful in 1m23s
repod / nodejs (push) Successful in 2m35s
Add initial-state
2023-12-24 00:24:46 +01:00

48 lines
1.3 KiB
PHP

<?php
declare(strict_types=1);
namespace OCA\RePod\AppInfo;
use OCP\App\AppPathNotFoundException;
use OCP\App\IAppManager;
use OCP\AppFramework\App;
use OCP\AppFramework\Bootstrap\IBootContext;
use OCP\AppFramework\Bootstrap\IBootstrap;
use OCP\AppFramework\Bootstrap\IRegistrationContext;
use OCP\AppFramework\Services\IInitialState;
class Application extends App implements IBootstrap
{
public const APP_ID = 'repod';
private const GPODDERSYNC_ID = 'gpoddersync';
public function __construct() {
parent::__construct(self::APP_ID);
}
public function boot(IBootContext $context): void {
/** @psalm-suppress DeprecatedInterface */
$appContainer = $context->getAppContainer();
/** @var IAppManager $appManager */
$appManager = $appContainer->get(IAppManager::class);
/** @var IInitialState $initialState */
$initialState = $appContainer->get(IInitialState::class);
$gpoddersync = $appManager->isEnabledForUser(self::GPODDERSYNC_ID);
if (!$gpoddersync) {
try {
$appManager->enableApp(self::GPODDERSYNC_ID);
} catch (AppPathNotFoundException $e) {
}
}
$gpoddersync = $appManager->isEnabledForUser(self::GPODDERSYNC_ID);
$initialState->provideInitialState('gpodder', $gpoddersync);
}
public function register(IRegistrationContext $context): void {}
}