From 429ca86ce9c42ad59e5412230694a7707b5792da Mon Sep 17 00:00:00 2001 From: Jonathan Treffler Date: Sun, 3 Nov 2024 02:13:10 +0100 Subject: [PATCH] initial implementation of demo organization provider --- appinfo/info.xml | 21 ++++ appinfo/routes.php | 8 ++ lib/AppInfo/Application.php | 28 ++++++ .../RegisterOrganizationProviderListener.php | 25 +++++ .../DemoOrganizationProvider.php | 98 +++++++++++++++++++ 5 files changed, 180 insertions(+) create mode 100644 appinfo/info.xml create mode 100644 appinfo/routes.php create mode 100644 lib/AppInfo/Application.php create mode 100644 lib/Listener/RegisterOrganizationProviderListener.php create mode 100644 lib/OrganizationProviders/DemoOrganizationProvider.php diff --git a/appinfo/info.xml b/appinfo/info.xml new file mode 100644 index 0000000..9e14e5d --- /dev/null +++ b/appinfo/info.xml @@ -0,0 +1,21 @@ + + + demo_organization_provider + Demo Organization Provider + + + 1.0.0 + agpl + Jonathan Treffler + DemoOrganizationProvider + files + https://git.verdigado.com/verdigado-public/demo_organization_provider/issues + + + pgsql + sqlite + mysql + + + \ No newline at end of file diff --git a/appinfo/routes.php b/appinfo/routes.php new file mode 100644 index 0000000..4aca6c4 --- /dev/null +++ b/appinfo/routes.php @@ -0,0 +1,8 @@ + [ + ], + 'routes' => [ + ] +]; \ No newline at end of file diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php new file mode 100644 index 0000000..b7f4032 --- /dev/null +++ b/lib/AppInfo/Application.php @@ -0,0 +1,28 @@ +registerEventListener(RegisterOrganizationProviderEvent::class, RegisterOrganizationProviderListener::class); + } + + public function boot(IBootContext $context): void { + } + +} \ No newline at end of file diff --git a/lib/Listener/RegisterOrganizationProviderListener.php b/lib/Listener/RegisterOrganizationProviderListener.php new file mode 100644 index 0000000..fb1e52a --- /dev/null +++ b/lib/Listener/RegisterOrganizationProviderListener.php @@ -0,0 +1,25 @@ +getOrganizationProviderManager(); + $organizationProviderManager->registerOrganizationProvider(new DemoOrganizationProvider()); + } + } +} \ No newline at end of file diff --git a/lib/OrganizationProviders/DemoOrganizationProvider.php b/lib/OrganizationProviders/DemoOrganizationProvider.php new file mode 100644 index 0000000..cbed1ad --- /dev/null +++ b/lib/OrganizationProviders/DemoOrganizationProvider.php @@ -0,0 +1,98 @@ += 1 && $roleNumber <= 3) { + return new OrganizationRole( + id: $id, + organizationId: $organizationId, + friendlyName: "Role " . $roleNumber . " of org " . $organizationId, + membersGroup: $id + ); + } + } + + throw new OrganizationRoleNotFound("demo", $id); + } + + /** + * @return OrganizationRole[] + */ + public function getRolesOfOrganization(int $organizationId): array { + if(in_array($organizationId, self::DEMO_ORGANIZATIONS)) { + $result = []; + for($i = 1; $i <= 3; $i++) { + $result[] = new OrganizationRole( + id: $organizationId . "_" . $i, + organizationId: $organizationId, + friendlyName: "Role " . $i . " of org " . $organizationId, + membersGroup: $organizationId . "_" . $i + ); + } + return $result; + } else { + return []; + } + } + +} \ No newline at end of file