Commit f1c3d24a authored by Arnaud Bey's avatar Arnaud Bey
Browse files

display user wordbox in profile. fix #78

parent e803ebfb
......@@ -2,12 +2,13 @@
namespace MagicWordBundle\Controller;
use LexiconBundle\Entity\Language;
use LexiconBundle\Entity\Lemma;
use MagicWordBundle\Entity\Player;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use LexiconBundle\Entity\Lemma;
use LexiconBundle\Entity\Language;
class WordboxController extends Controller
{
......@@ -24,6 +25,22 @@ class WordboxController extends Controller
]);
}
/**
* @Route("/wordbox/{playerId}/{languageId}", name ="wordbox_user")
* @ParamConverter("player", class="MagicWordBundle:Player", options={"id" = "playerId"})
* @ParamConverter("language", class="LexiconBundle:Language", options={"id" = "languageId"})
*/
public function displaySomeoneWordboxAction(Player $player, Language $language)
{
$acquisitions = $this->get('mw_manager.wordbox')->getAcquisitionsByLanguage($language, $player);
return $this->render('MagicWordBundle:Wordbox:index.html.twig', [
'acquisitions' => $acquisitions,
'language' => $language,
'player' => $player
]);
}
/**
* @Route("/wordbox/add/{id}", name="add-to-wordbox")
* @ParamConverter("lemma", class="LexiconBundle:Lemma")
......
......@@ -30,18 +30,19 @@ class WordboxManager
$this->acquisitionManager = $acquisitionManager;
}
public function getAcquisitionsByLanguage(Language $language)
public function getAcquisitionsByLanguage(Language $language, $user = null)
{
$wordbox = $this->getWordbox();
$wordbox = $this->getWordbox($user);
$acquisitions = $this->em->getRepository("MagicWordBundle:Wordbox\Acquisition")->findOneByWordboxAndLanguage($wordbox, $language);
return $acquisitions;
}
public function getWordbox()
public function getWordbox($user = null)
{
$user = $this->tokenStorage->getToken()->getUser();
if (!$user) {
$user = $this->tokenStorage->getToken()->getUser();
}
return $user->getWordbox();
}
......
......@@ -218,5 +218,5 @@ verb: verbe
weight: Poids
wiktionary_def: Définition wiktionary
word_length: Longueur de la forme
wordbox: Ma wordbox
wordbox: Wordbox
wordlengthpoints: Points bonus longueur de forme
......@@ -41,8 +41,18 @@
{% endif %}
{% if app.user == user or user.displayMail %}
<h4> {{ "profile_email" | trans }} </h4>
{{ user.email }}
{{ user.email }}
<hr/>
{% endif %}
</div>
<h4>{{ 'wordbox' | trans }}</h4>
{% set languages = get_languages() %}
{% for language in languages %}
<a href="{{ path('wordbox_user', {playerId:user.id, languageId: language.id}) }}">
{{ language.name | trans }}
</a>
{% endfor %}
</div>
</div>
{% endblock %}
......@@ -5,7 +5,10 @@
<div class="panel-heading">
<h4>
{% include "MagicWordBundle:Common:backtohome.html.twig" %}
{{ 'wordbox' | trans }} <strong>{{ language.name | trans }}</strong> ({{ acquisitions|length }})
{{ 'wordbox' | trans }}
{{ player is defined ? ' - '~player.username~' - ' }}
<strong>{{ language.name | trans }}</strong>
({{ acquisitions|length }})
</h4>
</div>
<ul class="list-group">
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment