Fix deprecations and errors for nc 27

master
Jonas Letzbor 2023-07-24 21:24:05 +02:00
parent f46f16f119
commit 4158ddb2db
Signed by: RPJosh
GPG Key ID: 46D72F589702E55A
9 changed files with 374 additions and 72 deletions

1
.gitignore vendored 100644
View File

@ -0,0 +1 @@
/vendor/

View File

@ -11,7 +11,7 @@
<screenshot>https://raw.githubusercontent.com/nextcloud/weather/master/screenshots/1.png</screenshot>
<screenshot>https://raw.githubusercontent.com/nextcloud/weather/master/screenshots/2.png</screenshot>
<dependencies>
<nextcloud min-version="22" max-version="26"/>
<nextcloud min-version="22" max-version="27"/>
</dependencies>
<website>https://github.com/nextcloud/weather</website>
<bugs>https://github.com/nextcloud/weather/issues</bugs>
@ -20,6 +20,7 @@
<settings>
<admin>OCA\Weather\Settings\AdminSettings</admin>
</settings>
<navigations>
<navigation>
<id>weather</id>

View File

@ -11,9 +11,8 @@
namespace OCA\Weather\AppInfo;
$application = new Application();
$application->registerRoutes($this, array('routes' => array(
return [
'routes' => [
array('name' => 'city#index', 'url' => '/', 'verb' => 'GET'),
array('name' => 'city#getall', 'url' => '/city/getall', 'verb' => 'GET'),
@ -26,5 +25,7 @@ $application->registerRoutes($this, array('routes' => array(
array('name' => 'settings#apikeyset', 'url' => '/settings/apikey', 'verb' => 'POST'),
array('name' => 'settings#metricset', 'url' => '/settings/metric/set','verb' => 'POST'),
array('name' => 'settings#metricget', 'url' => '/settings/metric/get','verb' => 'GET'),
)));
]
];
?>

21
composer.json 100644
View File

@ -0,0 +1,21 @@
{
"name": "nextcloud/weather",
"description": "Weather app for nextcloud",
"type": "project",
"authors": [
{
"name": "RPJosh",
"email": "RPJosh@rpjosh.de"
}
],
"require": {},
"require-dev": {
"nextcloud/ocp": "dev-master"
},
"autoload-dev": {
"psr-4": {
"OCP\\": "vendor/nextcloud/ocp/OCP"
}
}
}

267
composer.lock generated 100644
View File

@ -0,0 +1,267 @@
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "8b472dc0ee79104cbd69c0b2d4ac2b4f",
"packages": [],
"packages-dev": [
{
"name": "nextcloud/ocp",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/nextcloud-deps/ocp.git",
"reference": "e1882fc96e3676e7628eaa82f1f8294c0d778db2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nextcloud-deps/ocp/zipball/e1882fc96e3676e7628eaa82f1f8294c0d778db2",
"reference": "e1882fc96e3676e7628eaa82f1f8294c0d778db2",
"shasum": ""
},
"require": {
"php": "~8.0 || ~8.1 || ~8.2",
"psr/clock": "^1.0",
"psr/container": "^2.0.2",
"psr/event-dispatcher": "^1.0",
"psr/log": "^1.1.4"
},
"default-branch": true,
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "28.0.0-dev"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"AGPL-3.0-or-later"
],
"authors": [
{
"name": "Christoph Wurst",
"email": "christoph@winzerhof-wurst.at"
}
],
"description": "Composer package containing Nextcloud's public API (classes, interfaces)",
"support": {
"issues": "https://github.com/nextcloud-deps/ocp/issues",
"source": "https://github.com/nextcloud-deps/ocp/tree/master"
},
"time": "2023-07-22T00:39:08+00:00"
},
{
"name": "psr/clock",
"version": "1.0.0",
"source": {
"type": "git",
"url": "https://github.com/php-fig/clock.git",
"reference": "e41a24703d4560fd0acb709162f73b8adfc3aa0d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/clock/zipball/e41a24703d4560fd0acb709162f73b8adfc3aa0d",
"reference": "e41a24703d4560fd0acb709162f73b8adfc3aa0d",
"shasum": ""
},
"require": {
"php": "^7.0 || ^8.0"
},
"type": "library",
"autoload": {
"psr-4": {
"Psr\\Clock\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "https://www.php-fig.org/"
}
],
"description": "Common interface for reading the clock.",
"homepage": "https://github.com/php-fig/clock",
"keywords": [
"clock",
"now",
"psr",
"psr-20",
"time"
],
"support": {
"issues": "https://github.com/php-fig/clock/issues",
"source": "https://github.com/php-fig/clock/tree/1.0.0"
},
"time": "2022-11-25T14:36:26+00:00"
},
{
"name": "psr/container",
"version": "2.0.2",
"source": {
"type": "git",
"url": "https://github.com/php-fig/container.git",
"reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/container/zipball/c71ecc56dfe541dbd90c5360474fbc405f8d5963",
"reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963",
"shasum": ""
},
"require": {
"php": ">=7.4.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\Container\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "https://www.php-fig.org/"
}
],
"description": "Common Container Interface (PHP FIG PSR-11)",
"homepage": "https://github.com/php-fig/container",
"keywords": [
"PSR-11",
"container",
"container-interface",
"container-interop",
"psr"
],
"support": {
"issues": "https://github.com/php-fig/container/issues",
"source": "https://github.com/php-fig/container/tree/2.0.2"
},
"time": "2021-11-05T16:47:00+00:00"
},
{
"name": "psr/event-dispatcher",
"version": "1.0.0",
"source": {
"type": "git",
"url": "https://github.com/php-fig/event-dispatcher.git",
"reference": "dbefd12671e8a14ec7f180cab83036ed26714bb0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/event-dispatcher/zipball/dbefd12671e8a14ec7f180cab83036ed26714bb0",
"reference": "dbefd12671e8a14ec7f180cab83036ed26714bb0",
"shasum": ""
},
"require": {
"php": ">=7.2.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\EventDispatcher\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "http://www.php-fig.org/"
}
],
"description": "Standard interfaces for event handling.",
"keywords": [
"events",
"psr",
"psr-14"
],
"support": {
"issues": "https://github.com/php-fig/event-dispatcher/issues",
"source": "https://github.com/php-fig/event-dispatcher/tree/1.0.0"
},
"time": "2019-01-08T18:20:26+00:00"
},
{
"name": "psr/log",
"version": "1.1.4",
"source": {
"type": "git",
"url": "https://github.com/php-fig/log.git",
"reference": "d49695b909c3b7628b6289db5479a1c204601f11"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11",
"reference": "d49695b909c3b7628b6289db5479a1c204601f11",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.1.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\Log\\": "Psr/Log/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "https://www.php-fig.org/"
}
],
"description": "Common interface for logging libraries",
"homepage": "https://github.com/php-fig/log",
"keywords": [
"log",
"psr",
"psr-3"
],
"support": {
"source": "https://github.com/php-fig/log/tree/1.1.4"
},
"time": "2021-05-03T11:20:27+00:00"
}
],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": {
"nextcloud/ocp": 20
},
"prefer-stable": false,
"prefer-lowest": false,
"platform": [],
"platform-dev": [],
"plugin-api-version": "2.2.0"
}

View File

@ -13,84 +13,92 @@
namespace OCA\Weather\AppInfo;
use \OCP\AppFramework\App;
use \OCP\IContainer;
use Psr\Container\ContainerInterface;
use \OCA\Weather\Controller\CityController;
use \OCA\Weather\Controller\SettingsController;
use \OCA\Weather\Controller\WeatherController;
use OCA\Weather\Controller\CityController;
use OCA\Weather\Controller\SettingsController;
use OCA\Weather\Controller\WeatherController;
use \OCA\Weather\Db\CityMapper;
use \OCA\Weather\Db\SettingsMapper;
use OCA\Weather\Db\CityMapper;
use OCA\Weather\Db\SettingsMapper;
use OCP\AppFramework\Bootstrap\IBootContext;
use OCP\AppFramework\Bootstrap\IBootstrap;
use OCP\AppFramework\Bootstrap\IRegistrationContext;
use OCP\IUserSession;
use OC\User\Session;
class Application extends App {
class Application extends App implements IBootstrap {
public function __construct (array $urlParams=array()) {
public function __construct (array $urlParams = []) {
parent::__construct('weather', $urlParams);
}
$container = $this->getContainer();
public function register(IRegistrationContext $context): void {
/**
* Core
*/
$container->registerService('UserId', function(IContainer $c) {
$user = $c->getServer()->getUserSession()->getUser();
return $user ? $user->getUID() : null;
$context->registerService('UserId', function(ContainerInterface $c) {
/** @var Session */
$userSession = $c->get(IUserSession::class);
return $userSession->getUser() ? $userSession->getUser()->getUID() : null;
});
$container->registerService('Config', function($c) {
return $c->query('ServerContainer')->getConfig();
$context->registerService('Config', function(ContainerInterface $c) {
return $c->get('ServerContainer')->getConfig();
});
$container->registerService('L10N', function($c) {
return $c->query('ServerContainer')->getL10N($c->query('AppName'));
$context->registerService('L10N', function(ContainerInterface $c) {
return $c->get('ServerContainer')->getL10N($c->get('AppName'));
});
/**
* Database Layer
*/
$container->registerService('CityMapper', function(IContainer $c) {
return new CityMapper($c->query('ServerContainer')->getDatabaseConnection());
$context->registerService('CityMapper', function(ContainerInterface $c) {
return new CityMapper($c->get('ServerContainer')->getDatabaseConnection());
});
$container->registerService('SettingsMapper', function(IContainer $c) {
return new SettingsMapper($c->query('ServerContainer')->getDatabaseConnection());
$context->registerService('SettingsMapper', function(ContainerInterface $c) {
return new SettingsMapper($c->get('ServerContainer')->getDatabaseConnection());
});
/**
* Controllers
*/
$container->registerService('CityController', function(IContainer $c) {
$context->registerService('CityController', function(ContainerInterface $c) {
return new CityController(
$c->query('AppName'),
$c->query('Config'),
$c->query('Request'),
$c->query('UserId'),
$c->query('CityMapper'),
$c->query('SettingsMapper')
$c->get('AppName'),
$c->get('Config'),
$c->get('Request'),
$c->get('UserId'),
$c->get('CityMapper'),
$c->get('SettingsMapper')
);
});
$container->registerService('SettingsController', function(IContainer $c) {
$context->registerService('SettingsController', function(ContainerInterface $c) {
return new SettingsController(
$c->query('AppName'),
$c->query('Config'),
$c->query('Request'),
$c->query('UserId'),
$c->query('SettingsMapper'),
$c->query('CityMapper')
$c->get('AppName'),
$c->get('Config'),
$c->get('Request'),
$c->get('UserId'),
$c->get('SettingsMapper'),
$c->get('CityMapper')
);
});
$container->registerService('WeatherController', function(IContainer $c) {
$context->registerService('WeatherController', function(ContainerInterface $c) {
return new WeatherController(
$c->query('AppName'),
$c->query('Config'),
$c->query('Request'),
$c->query('UserId'),
$c->query('CityMapper'),
$c->query('SettingsMapper'),
$c->query('L10N')
$c->get('AppName'),
$c->get('Config'),
$c->get('Request'),
$c->get('UserId'),
$c->get('CityMapper'),
$c->get('SettingsMapper'),
$c->get('L10N')
);
});
}
public function boot(IBootContext $context): void {
}
}

View File

@ -17,6 +17,7 @@ use \OCP\IDBConnection;
use \OCP\AppFramework\Db\QbMapper;
class CityMapper extends QbMapper {
public function __construct (IDBConnection $db) {
parent::__construct($db, 'weather_city');
}
@ -70,4 +71,5 @@ class CityMapper extends QbMapper {
return null;
}
};
?>

View File

@ -17,6 +17,7 @@ use \OCP\IDBConnection;
use \OCP\AppFramework\Db\QbMapper;
class SettingsMapper extends QbMapper {
public function __construct (IDBConnection $db) {
parent::__construct($db, 'weather_config');
}