[Directory] Add documentation

This commit is contained in:
Daniel 2020-12-01 18:09:01 +00:00 committed by Hugo Sales
parent 019e3d91e4
commit 0289888397
Signed by untrusted user: someonewithpc
GPG Key ID: 7D0C7EAFC9D835A0
3 changed files with 19 additions and 11 deletions

View File

@ -61,15 +61,11 @@ class Cover extends Module
*/ */
public function onStartTwigPopulateVars(array &$vars): bool public function onStartTwigPopulateVars(array &$vars): bool
{ {
$vars['profile_tabs'] = [['title' => 'Cover', $vars['profile_tabs'][] = ['title' => 'Cover',
'route' => 'settings_profile_cover', 'route' => 'settings_profile_cover',
]]; ];
if (Common::user() != null) { if (Common::user() != null) {
if (array_key_exists('profile_extras',$vars)) {
$vars['profile_extras'] = [];
}
$cover = DB::find('cover', ['gsactor_id' => Common::user()->getId()]); $cover = DB::find('cover', ['gsactor_id' => Common::user()->getId()]);
if ($cover != null) { if ($cover != null) {
$vars['profile_extras'][] = ['name' => 'cover', 'vars' => ['img' => '/cover']]; $vars['profile_extras'][] = ['name' => 'cover', 'vars' => ['img' => '/cover']];

View File

@ -26,6 +26,13 @@ use Symfony\Component\HttpFoundation\Request;
class Directory class Directory
{ {
/**
* actors stream
*
* @param Request $request
*
* @return array template
*/
public function actors(Request $request) public function actors(Request $request)
{ {
return ['_template' => 'directory/actors.html.twig', 'actors' => DB::dql('select g from App\Entity\GSActor g order by g.nickname ASC')]; return ['_template' => 'directory/actors.html.twig', 'actors' => DB::dql('select g from App\Entity\GSActor g order by g.nickname ASC')];

View File

@ -23,10 +23,18 @@ namespace Plugin\Directory;
use App\Core\Event; use App\Core\Event;
use App\Core\Module; use App\Core\Module;
use App\Core\Router\RouteLoader;
class Directory extends Module class Directory extends Module
{ {
public function onAddRoute($r) /**
* Map URLs to actions
*
* @param RouteLoader $r
*
* @return bool hook value; true means continue processing, false means stop.
*/
public function onAddRoute(RouteLoader $r)
{ {
$r->connect('actors', '/actors', [Controller\Directory::class, 'actors']); $r->connect('actors', '/actors', [Controller\Directory::class, 'actors']);
$r->connect('groups', '/groups', [Controller\Directory::class, 'groups']); $r->connect('groups', '/groups', [Controller\Directory::class, 'groups']);
@ -42,9 +50,6 @@ class Directory extends Module
*/ */
public function onStartTwigPopulateVars(array &$vars): bool public function onStartTwigPopulateVars(array &$vars): bool
{ {
if (array_key_exists('main_nav_tabs',$vars)) {
$vars['main_nav_tabs'] = [];
}
$vars['main_nav_tabs'][] = ['title' => 'Actors', $vars['main_nav_tabs'][] = ['title' => 'Actors',
'route' => 'actors', 'route' => 'actors',
]; ];