Skip to content
This repository has been archived by the owner on May 29, 2023. It is now read-only.

Commit

Permalink
Ref #23: Create a page to display strips to public
Browse files Browse the repository at this point in the history
  • Loading branch information
hundrex committed Feb 16, 2018
1 parent eb86018 commit f4af5c4
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 9 deletions.
12 changes: 5 additions & 7 deletions app/Resources/views/strip/display.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
{# TODO : do something clean #}
<th>Stripelements</th>
{% for stripElement in strip.stripElements %}
<td>
<img src="{{ app.request.scheme ~ '://' ~ app.request.host ~ ':8000/images/strips/' ~ stripElement }}"/>
</td>
{% endfor %}
<td>
<img src="{{ app.request.scheme ~ '://' ~ app.request.host ~ ':8000/images/strips/' ~ stripElement }}"/>
</td>
{% endfor %}
</tr>
<tr>
<th>Publicationdate</th>
Expand All @@ -29,9 +29,7 @@
<tr>
<th>Author</th>
<td>
{% for account in strip.author%}
<a href="{{ path('acount_show', { 'slug': account.slug }) }}">{{ account.slug }}</a>
{% endfor %}
<a href="{{ path('account_show', { 'slug': strip.author.slug }) }}">{{ strip.author.username }}</a>
</td>
</tr>
</tbody>
Expand Down
12 changes: 10 additions & 2 deletions src/AppBundle/Controller/StripController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,24 @@
*
* @Route("strip")
*/
class StripController extends Controller {
class StripController extends Controller
{

/**
* Finds and displays a strip entity to the public.
*
* @Route("/{id}", name="strip_display")
* @Method("GET")
*/
public function displayStripAction(Request $request, Strip $strip) {
public function displayStripAction(Request $request, Strip $strip)
{

$strip = $this->getDoctrine()
->getRepository(Strip::class)
->findAuthors($strip);

// dump($strip);
// die();
return $this->render('strip/display.html.twig', [
'strip' => $strip,
]);
Expand Down
22 changes: 22 additions & 0 deletions src/AppBundle/Repository/StripRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,26 @@
*/
class StripRepository extends \Doctrine\ORM\EntityRepository
{

public function findAuthors($strip)
{
$query = $this->getEntityManager()
->createQuery(
'SELECT s, a
FROM AppBundle:Strip s
JOIN s.author a
WHERE s.id = :id'
)
->setParameter('id', $strip);

try
{
return $query->getSingleResult();
}
catch (\Doctrine\ORM\NoResultException $e)
{
return null;
}
}

}

0 comments on commit f4af5c4

Please sign in to comment.