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>
|
* @copyright 2018 Marcin Łojewski <dev@mlojewski.me>
|
||||||
* @author 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
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -22,14 +24,20 @@
|
|||||||
namespace OCA\UserSQL\AppInfo;
|
namespace OCA\UserSQL\AppInfo;
|
||||||
|
|
||||||
use OCP\AppFramework\App;
|
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.
|
* The application bootstrap class.
|
||||||
*
|
*
|
||||||
* @author Marcin Łojewski <dev@mlojewski.me>
|
* @author Marcin Łojewski <dev@mlojewski.me>
|
||||||
*/
|
*/
|
||||||
class Application extends App
|
class Application extends App implements IBootstrap
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The class constructor.
|
* The class constructor.
|
||||||
@@ -42,26 +50,21 @@ class Application extends App
|
|||||||
parent::__construct("user_sql", $urlParams);
|
parent::__construct("user_sql", $urlParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** {@inheritdoc} */
|
||||||
* Register the application backends
|
public function register(IRegistrationContext $context): void
|
||||||
* 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'
|
|
||||||
);
|
|
||||||
|
|
||||||
if ($userBackend->isConfigured()) {
|
/** {@inheritdoc} */
|
||||||
\OC::$server->getUserManager()->registerBackend($userBackend);
|
public function boot(IBootContext $context): void
|
||||||
}
|
{
|
||||||
if ($groupBackend->isConfigured()) {
|
$context->injectFn(function(
|
||||||
\OC::$server->getGroupManager()->addBackend($groupBackend);
|
IUserManager $userManager,
|
||||||
}
|
Backend\UserBackend $userBackend,
|
||||||
|
IGroupManager $groupManager,
|
||||||
|
Backend\GroupBackend $groupBackend,
|
||||||
|
) {
|
||||||
|
$userManager->registerBackend($userBackend);
|
||||||
|
$groupManager->addBackend($groupBackend);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user