From d17582094df60372b107cb1301b66c42e87fa475 Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 18 Dec 2020 19:45:45 +0000 Subject: [PATCH] [ProfileColor] Visualize profile color --- plugins/ProfileColor/Controller/ProfileColor.php | 2 ++ plugins/ProfileColor/ProfileColor.php | 10 ++++++++++ templates/profilecolor/view.html.twig | 6 +++--- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/plugins/ProfileColor/Controller/ProfileColor.php b/plugins/ProfileColor/Controller/ProfileColor.php index 12c2820ff2..afe16f2efc 100644 --- a/plugins/ProfileColor/Controller/ProfileColor.php +++ b/plugins/ProfileColor/Controller/ProfileColor.php @@ -27,6 +27,7 @@ use function App\Core\I18n\_m; use App\Entity\ProfileColor as PColor; use App\Util\Common; use App\Util\Exception\ClientException; +use App\Util\Exception\RedirectException; use App\Util\Exception\ServerException; use Symfony\Component\Form\Extension\Core\Type\ColorType; use Symfony\Component\Form\Extension\Core\Type\HiddenType; @@ -88,6 +89,7 @@ class ProfileColor $pcolor = PColor::create(['gsactor_id' => $actor_id, 'color' => $data['color']]); DB::persist($pcolor); DB::flush(); + throw new RedirectException(); } return ['_template' => 'profilecolor/profilecolor.html.twig', 'form' => $form->createView()]; diff --git a/plugins/ProfileColor/ProfileColor.php b/plugins/ProfileColor/ProfileColor.php index 6451df627e..3aa2c36f74 100644 --- a/plugins/ProfileColor/ProfileColor.php +++ b/plugins/ProfileColor/ProfileColor.php @@ -20,9 +20,11 @@ namespace Plugin\ProfileColor; +use App\Core\DB\DB; use App\Core\Event; use App\Core\Module; use App\Core\Router\RouteLoader; +use App\Util\Common; /** * Profile Color plugin main class @@ -61,6 +63,14 @@ class ProfileColor extends Module $vars['profile_tabs'][] = ['title' => 'Color', 'route' => 'settings_profile_color', ]; + if (Common::user() != null) { + $color = DB::find('profile_color', ['gsactor_id' => Common::user()->getId()]); + if ($color != null) { + $vars['profile_extras'][] = ['name' => 'profilecolor', 'vars' => ['color' => $color->getColor()]]; + } else { + $vars['profile_extras'][] = ['name' => 'profilecolor', 'vars' => []]; + } + } return Event::next; } diff --git a/templates/profilecolor/view.html.twig b/templates/profilecolor/view.html.twig index 1274454de7..334234db7d 100644 --- a/templates/profilecolor/view.html.twig +++ b/templates/profilecolor/view.html.twig @@ -1,8 +1,8 @@ - + {% if vars is not empty %} - Your cover. +
{{ vars.color }}
{% else %} -
+
{% endif %}
\ No newline at end of file