Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Mathieu Loiseau
MagicWord
Commits
f1c3d24a
Commit
f1c3d24a
authored
Oct 15, 2018
by
Arnaud Bey
Browse files
display user wordbox in profile. fix
#78
parent
e803ebfb
Changes
5
Hide whitespace changes
Inline
Side-by-side
application/src/MagicWordBundle/Controller/WordboxController.php
View file @
f1c3d24a
...
...
@@ -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")
...
...
application/src/MagicWordBundle/Manager/WordboxManager.php
View file @
f1c3d24a
...
...
@@ -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
();
}
...
...
application/src/MagicWordBundle/Resources/translations/messages.fr.yml
View file @
f1c3d24a
...
...
@@ -218,5 +218,5 @@ verb: verbe
weight
:
Poids
wiktionary_def
:
Définition wiktionary
word_length
:
Longueur de la forme
wordbox
:
Ma w
ordbox
wordbox
:
W
ordbox
wordlengthpoints
:
Points bonus longueur de forme
application/src/MagicWordBundle/Resources/views/Player/profile.html.twig
View file @
f1c3d24a
...
...
@@ -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
%}
application/src/MagicWordBundle/Resources/views/Wordbox/index.html.twig
View file @
f1c3d24a
...
...
@@ -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"
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment