diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..57872d0
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+/vendor/
diff --git a/appinfo/info.xml b/appinfo/info.xml
index b2ac3aa..82268a3 100644
--- a/appinfo/info.xml
+++ b/appinfo/info.xml
@@ -11,7 +11,7 @@
https://raw.githubusercontent.com/nextcloud/weather/master/screenshots/1.png
https://raw.githubusercontent.com/nextcloud/weather/master/screenshots/2.png
-
+
https://github.com/nextcloud/weather
https://github.com/nextcloud/weather/issues
@@ -20,12 +20,13 @@
OCA\Weather\Settings\AdminSettings
+
-
- weather
- Weather
- weather.city.index
- app.svg
-
-
+
+ weather
+ Weather
+ weather.city.index
+ app.svg
+
+
diff --git a/appinfo/routes.php b/appinfo/routes.php
index c15c427..0d61036 100644
--- a/appinfo/routes.php
+++ b/appinfo/routes.php
@@ -11,20 +11,21 @@
namespace OCA\Weather\AppInfo;
-$application = new Application();
+return [
+ 'routes' => [
+ array('name' => 'city#index', 'url' => '/', 'verb' => 'GET'),
-$application->registerRoutes($this, array('routes' => array(
- array('name' => 'city#index', 'url' => '/', 'verb' => 'GET'),
-
- array('name' => 'city#getall', 'url' => '/city/getall', 'verb' => 'GET'),
- array('name' => 'city#add', 'url' => '/city/add', 'verb' => 'POST'),
- array('name' => 'city#delete', 'url' => '/city/delete', 'verb' => 'POST'),
-
- array('name' => 'weather#get', 'url' => '/weather/get', 'verb' => 'GET'),
-
- array('name' => 'settings#homeset', 'url' => '/settings/home/set', 'verb' => 'POST'),
- 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'),
-)));
+ array('name' => 'city#getall', 'url' => '/city/getall', 'verb' => 'GET'),
+ array('name' => 'city#add', 'url' => '/city/add', 'verb' => 'POST'),
+ array('name' => 'city#delete', 'url' => '/city/delete', 'verb' => 'POST'),
+
+ array('name' => 'weather#get', 'url' => '/weather/get', 'verb' => 'GET'),
+
+ array('name' => 'settings#homeset', 'url' => '/settings/home/set', 'verb' => 'POST'),
+ 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'),
+ ]
+];
+
?>
diff --git a/composer.json b/composer.json
new file mode 100644
index 0000000..d5e3adb
--- /dev/null
+++ b/composer.json
@@ -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"
+ }
+ }
+}
diff --git a/composer.lock b/composer.lock
new file mode 100644
index 0000000..63deee8
--- /dev/null
+++ b/composer.lock
@@ -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"
+}
diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php
index df4baeb..7f17d6c 100644
--- a/lib/AppInfo/Application.php
+++ b/lib/AppInfo/Application.php
@@ -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 {
+
+ $context->registerService('UserId', function(ContainerInterface $c) {
+ /** @var Session */
+ $userSession = $c->get(IUserSession::class);
- /**
- * Core
- */
- $container->registerService('UserId', function(IContainer $c) {
- $user = $c->getServer()->getUserSession()->getUser();
- return $user ? $user->getUID() : null;
- });
-
- $container->registerService('Config', function($c) {
- return $c->query('ServerContainer')->getConfig();
+ return $userSession->getUser() ? $userSession->getUser()->getUID() : null;
});
- $container->registerService('L10N', function($c) {
- return $c->query('ServerContainer')->getL10N($c->query('AppName'));
+ $context->registerService('Config', function(ContainerInterface $c) {
+ return $c->get('ServerContainer')->getConfig();
+ });
+
+ $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 {
+ }
}
diff --git a/db/cityentity.php b/lib/Db/CityEntity.php
similarity index 99%
rename from db/cityentity.php
rename to lib/Db/CityEntity.php
index bd9714c..8598f0c 100644
--- a/db/cityentity.php
+++ b/lib/Db/CityEntity.php
@@ -24,4 +24,4 @@ class CityEntity extends Entity {
}
}
-?>
+?>
\ No newline at end of file
diff --git a/db/citymapper.php b/lib/Db/CityMapper.php
similarity index 99%
rename from db/citymapper.php
rename to lib/Db/CityMapper.php
index 15901b9..15ec3ff 100644
--- a/db/citymapper.php
+++ b/lib/Db/CityMapper.php
@@ -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;
}
};
-?>
+
+?>
\ No newline at end of file
diff --git a/db/settingsmapper.php b/lib/Db/SettingsMapper.php
similarity index 99%
rename from db/settingsmapper.php
rename to lib/Db/SettingsMapper.php
index 991cbe2..4e863e1 100644
--- a/db/settingsmapper.php
+++ b/lib/Db/SettingsMapper.php
@@ -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');
}