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