Backport Server into app
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Michel Roux 2023-06-22 13:41:48 +02:00
parent 0575f11864
commit 257039be80
5 changed files with 66 additions and 9 deletions

View File

@ -29,7 +29,7 @@ See [README] for more exhaustive information on features and potential misfeatur
[README]: https://github.com/e-alfred/epubreader/blob/master/epubreader/README.md
]]>
</description>
<version>1.4.8</version>
<version>1.4.9</version>
<licence>agpl</licence>
<author>Frank de Lange</author>
<author>e-alfred</author>

View File

@ -1,7 +1,7 @@
{
"name": "nextcloud/epubreader",
"description": "EPUB/CBZ/PDF ebook reader",
"version": "1.4.8",
"version": "1.4.9",
"type": "project",
"license": "AGPL-3.0-or-later",
"require-dev": {

12
composer.lock generated
View File

@ -94,16 +94,16 @@
},
{
"name": "php-cs-fixer/shim",
"version": "v3.17.0",
"version": "v3.18.0",
"source": {
"type": "git",
"url": "https://github.com/PHP-CS-Fixer/shim.git",
"reference": "f51b4aed90565c447136f1d015798f6f7c82490f"
"reference": "a517e03dd0727336e502e071cc08e406ac878dba"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/PHP-CS-Fixer/shim/zipball/f51b4aed90565c447136f1d015798f6f7c82490f",
"reference": "f51b4aed90565c447136f1d015798f6f7c82490f",
"url": "https://api.github.com/repos/PHP-CS-Fixer/shim/zipball/a517e03dd0727336e502e071cc08e406ac878dba",
"reference": "a517e03dd0727336e502e071cc08e406ac878dba",
"shasum": ""
},
"require": {
@ -140,9 +140,9 @@
"description": "A tool to automatically fix PHP code style",
"support": {
"issues": "https://github.com/PHP-CS-Fixer/shim/issues",
"source": "https://github.com/PHP-CS-Fixer/shim/tree/v3.17.0"
"source": "https://github.com/PHP-CS-Fixer/shim/tree/v3.18.0"
},
"time": "2023-05-22T20:00:38+00:00"
"time": "2023-06-18T22:26:36+00:00"
},
{
"name": "psalm/phar",

View File

@ -11,13 +11,13 @@
namespace OCA\Epubreader;
use OCA\Epubreader\AppInfo\Application;
use OCA\Epubreader\Utility\Server;
use OCP\Files\IRootFolder;
use OCP\Files\Node;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\IUser;
use OCP\IUserSession;
use OCP\Server;
class Hooks {

57
lib/Utility/Server.php Normal file
View File

@ -0,0 +1,57 @@
<?php
declare(strict_types=1);
/**
* @copyright Carl Schwan <carl@carlschwan.eu>
*
* @license AGPL-3.0-or-later
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* 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, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
namespace OCA\Epubreader\Utility;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
/**
* Class allowing to inject services into your application. You should
* use whenever possible dependency injections instead.
*
* ```php
* use OCP\Server;
*
* $tagManager = Server::get(ITagManager::class);
* ```
*
* @since 25.0.0
*/
final class Server {
/**
* @template T
* @param class-string<T>|string $serviceName
* @return T|mixed
* @psalm-template S as class-string<T>|string
* @psalm-param S $serviceName
* @psalm-return (S is class-string<T> ? T : mixed)
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
* @since 25.0.0
*/
public static function get(string $serviceName) {
/** @psalm-suppress UndefinedClass */
return \OC::$server->get($serviceName);
}
}