Move to IBootstrap initialization and remove the deprecated appinfo/app.php
This commit is contained in:
@@ -1,31 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Nextcloud - user_sql
|
||||
*
|
||||
* @copyright 2012-2015 Andreas Böhler <dev (at) aboehler (dot) at>
|
||||
* @copyright 2018 Marcin Łojewski <dev@mlojewski.me>
|
||||
* @author Marcin Łojewski <dev@mlojewski.me>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use OCA\UserSQL\AppInfo\Application;
|
||||
use OCP\AppFramework\QueryException;
|
||||
|
||||
try {
|
||||
$app = new Application();
|
||||
$app->registerBackends();
|
||||
} catch (QueryException $queryException) {
|
||||
OC::$server->getLogger()->logException($queryException);
|
||||
}
|
||||
@@ -4,6 +4,8 @@
|
||||
*
|
||||
* @copyright 2018 Marcin Łojewski <dev@mlojewski.me>
|
||||
* @author Marcin Łojewski <dev@mlojewski.me>
|
||||
* @copyright 2025 Claus-Justus Heine <himself@claus-justus-heine.de>
|
||||
* @author Claus-Justus Heine <himself@claus-justus-heine.de>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
@@ -22,14 +24,20 @@
|
||||
namespace OCA\UserSQL\AppInfo;
|
||||
|
||||
use OCP\AppFramework\App;
|
||||
use OCP\AppFramework\QueryException;
|
||||
use OCP\AppFramework\Bootstrap\IBootContext;
|
||||
use OCP\AppFramework\Bootstrap\IBootstrap;
|
||||
use OCP\AppFramework\Bootstrap\IRegistrationContext;
|
||||
use OCP\IGroupManager;
|
||||
use OCP\IUserManager;
|
||||
|
||||
use OCA\UserSQL\Backend;
|
||||
|
||||
/**
|
||||
* The application bootstrap class.
|
||||
*
|
||||
* @author Marcin Łojewski <dev@mlojewski.me>
|
||||
*/
|
||||
class Application extends App
|
||||
class Application extends App implements IBootstrap
|
||||
{
|
||||
/**
|
||||
* The class constructor.
|
||||
@@ -42,26 +50,21 @@ class Application extends App
|
||||
parent::__construct("user_sql", $urlParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the application backends
|
||||
* if all necessary configuration is provided.
|
||||
*
|
||||
* @throws QueryException If the query container's could not be resolved
|
||||
*/
|
||||
public function registerBackends()
|
||||
{
|
||||
$userBackend = $this->getContainer()->query(
|
||||
'\OCA\UserSQL\Backend\UserBackend'
|
||||
);
|
||||
$groupBackend = $this->getContainer()->query(
|
||||
'\OCA\UserSQL\Backend\GroupBackend'
|
||||
);
|
||||
/** {@inheritdoc} */
|
||||
public function register(IRegistrationContext $context): void
|
||||
{}
|
||||
|
||||
if ($userBackend->isConfigured()) {
|
||||
\OC::$server->getUserManager()->registerBackend($userBackend);
|
||||
}
|
||||
if ($groupBackend->isConfigured()) {
|
||||
\OC::$server->getGroupManager()->addBackend($groupBackend);
|
||||
}
|
||||
/** {@inheritdoc} */
|
||||
public function boot(IBootContext $context): void
|
||||
{
|
||||
$context->injectFn(function(
|
||||
IUserManager $userManager,
|
||||
Backend\UserBackend $userBackend,
|
||||
IGroupManager $groupManager,
|
||||
Backend\GroupBackend $groupBackend,
|
||||
) {
|
||||
$userManager->registerBackend($userBackend);
|
||||
$groupManager->addBackend($groupBackend);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user