[SETTINGS][PLUGIN][CONTROLLER] Populate profile tabs event added. Settings base template populated with such event for plugins and components.

Signed-off-by: Eliseu Amaro <mail@eliseuama.ro>
This commit is contained in:
2021-07-29 20:20:32 +01:00
committed by Hugo Sales
parent 6dd0292397
commit c8a8e94d48
11 changed files with 91 additions and 77 deletions

View File

@@ -53,7 +53,7 @@ class ProfileColor
*
* @return array template
*/
public function profileColorSettings(Request $request)
public static function profileColorSettings(Request $request)
{
$user = Common::user();
$actor_id = $user->getId();

View File

@@ -25,6 +25,8 @@ use App\Core\Event;
use App\Core\Modules\Plugin;
use App\Core\Router\RouteLoader;
use App\Util\Common;
use Plugin\ProfileColor\Controller as C;
use Symfony\Component\HttpFoundation\Request;
/**
* Profile Color plugin main class
@@ -51,6 +53,18 @@ class ProfileColor extends Plugin
return Event::next;
}
public function onPopulateProfileSettingsTabs(Request $request, &$tabs)
{
// TODO avatar template shouldn't be on settings folder
$tabs[] = [
'title' => 'Color',
'desc' => 'Change your profile color.',
'controller' => C\ProfileColor::profileColorSettings($request),
];
return Event::next;
}
/**
* Populate twig vars
*
@@ -60,9 +74,11 @@ class ProfileColor extends Plugin
*/
public function onStartTwigPopulateVars(array &$vars): bool
{
$vars['profile_tabs'][] = ['title' => 'Color',
'route' => 'settings_profile_color',
];
/*$vars['profile_tabs'][] = [
'title' => 'Color',
'desc' => 'Change your profile color.',
'path' => 'profilecolor/profilecolor.html.twig',
];*/
if (Common::user() != null) {
$color = DB::find('profile_color', ['gsactor_id' => Common::user()->getId()]);
if ($color != null) {