From b364a51f800ba450636b5dc40344fd832b4aee02 Mon Sep 17 00:00:00 2001 From: Hugo Sales Date: Fri, 4 Sep 2020 18:44:20 +0000 Subject: [PATCH] [Directory] Add directory plugin, for listing people and groups --- plugins/Directory/Controller/Directory.php | 38 ++++++++++++++++++++++ plugins/Directory/Directory.php | 34 +++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 plugins/Directory/Controller/Directory.php create mode 100644 plugins/Directory/Directory.php diff --git a/plugins/Directory/Controller/Directory.php b/plugins/Directory/Controller/Directory.php new file mode 100644 index 0000000000..5f75e7b881 --- /dev/null +++ b/plugins/Directory/Controller/Directory.php @@ -0,0 +1,38 @@ +. + +// }}} + +namespace Plugin\Directory\Controller; + +use App\Core\DB\DB; +use Symfony\Component\HttpFoundation\Request; + +class Directory +{ + public function people(Request $request) + { + return ['_template' => 'directory/people.html.twig', 'people' => DB::dql('select g from App\Entity\GSActor g order by g.nickname ASC')]; + } + + public function groups(Request $request) + { + return ['_template' => 'directory/group.html.twig', 'groups' => DB::dql('select g from App\Entity\Group g order by g.nickname ASC')]; + } +} diff --git a/plugins/Directory/Directory.php b/plugins/Directory/Directory.php new file mode 100644 index 0000000000..ca731c2962 --- /dev/null +++ b/plugins/Directory/Directory.php @@ -0,0 +1,34 @@ +. + +// }}} + +namespace Plugin\Directory; + +use App\Core\Module; + +class Directory extends Module +{ + public function onAddRoute($r) + { + $r->connect('people', '/people', [Controller\Directory::class, 'people']); + $r->connect('groups', '/groups', [Controller\Directory::class, 'groups']); + return Event::next; + } +}