[ProfileColor] Visualize profile color
This commit is contained in:
parent
afae038cff
commit
d17582094d
@ -27,6 +27,7 @@ use function App\Core\I18n\_m;
|
|||||||
use App\Entity\ProfileColor as PColor;
|
use App\Entity\ProfileColor as PColor;
|
||||||
use App\Util\Common;
|
use App\Util\Common;
|
||||||
use App\Util\Exception\ClientException;
|
use App\Util\Exception\ClientException;
|
||||||
|
use App\Util\Exception\RedirectException;
|
||||||
use App\Util\Exception\ServerException;
|
use App\Util\Exception\ServerException;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\ColorType;
|
use Symfony\Component\Form\Extension\Core\Type\ColorType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
|
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
|
||||||
@ -88,6 +89,7 @@ class ProfileColor
|
|||||||
$pcolor = PColor::create(['gsactor_id' => $actor_id, 'color' => $data['color']]);
|
$pcolor = PColor::create(['gsactor_id' => $actor_id, 'color' => $data['color']]);
|
||||||
DB::persist($pcolor);
|
DB::persist($pcolor);
|
||||||
DB::flush();
|
DB::flush();
|
||||||
|
throw new RedirectException();
|
||||||
}
|
}
|
||||||
|
|
||||||
return ['_template' => 'profilecolor/profilecolor.html.twig', 'form' => $form->createView()];
|
return ['_template' => 'profilecolor/profilecolor.html.twig', 'form' => $form->createView()];
|
||||||
|
@ -20,9 +20,11 @@
|
|||||||
|
|
||||||
namespace Plugin\ProfileColor;
|
namespace Plugin\ProfileColor;
|
||||||
|
|
||||||
|
use App\Core\DB\DB;
|
||||||
use App\Core\Event;
|
use App\Core\Event;
|
||||||
use App\Core\Module;
|
use App\Core\Module;
|
||||||
use App\Core\Router\RouteLoader;
|
use App\Core\Router\RouteLoader;
|
||||||
|
use App\Util\Common;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Profile Color plugin main class
|
* Profile Color plugin main class
|
||||||
@ -61,6 +63,14 @@ class ProfileColor extends Module
|
|||||||
$vars['profile_tabs'][] = ['title' => 'Color',
|
$vars['profile_tabs'][] = ['title' => 'Color',
|
||||||
'route' => 'settings_profile_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;
|
return Event::next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
|
|
||||||
<a class="cover">
|
<a class="pcolor">
|
||||||
{% if vars is not empty %}
|
{% if vars is not empty %}
|
||||||
<img class="cover-img" src='{{ vars.img }}' alt="Your cover." class="">
|
<div class="profile-color" style="background-color: {{ vars.color }}">{{ vars.color }}</div>
|
||||||
{% else %}
|
{% else %}
|
||||||
<div class="no-cover" ></div>
|
<div class="no-profile-color" ></div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</a>
|
</a>
|
Loading…
Reference in New Issue
Block a user