ArchivedController::showAction()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 1
1
<?php
2
3
/*
4
 * This file is part of the MilioooMessageBundle package.
5
 *
6
 * (c) Michiel boeckaert <[email protected]>
7
 * This source file is subject to the MIT license that is bundled
8
 * with this source code in the file LICENSE.
9
 */
10
11
namespace Miliooo\MessagingBundle\Controller;
12
13
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface;
14
use Miliooo\Messaging\User\ParticipantProviderInterface;
15
use Symfony\Component\HttpFoundation\Response;
16
use Miliooo\Messaging\ThreadProvider\Folder\ArchivedProviderPagerFantaInterface;
17
18
/**
19
 * The archived controller is responsible for showing archived threads to the logged in user.
20
 *
21
 * @author Michiel Boeckaert <[email protected]>
22
 */
23
class ArchivedController
24
{
25
    /**
26
     * A participant provider instance.
27
     *
28
     * @var ParticipantProviderInterface
29
     */
30
    protected $participantProvider;
31
32
    /**
33
     * An archived provider pagerfanta instance.
34
     *
35
     * @var ArchivedProviderPagerFantaInterface
36
     */
37
    protected $archivedProvider;
38
39
    /**
40
     * A templating engine instance.
41
     *
42
     * @var EngineInterface
43
     */
44
    protected $templating;
45
46
    /**
47
     * Constructor.
48
     *
49
     * @param ParticipantProviderInterface $participantProvider
50
     * @param ArchivedProviderPagerFantaInterface $archivedProvider
51
     * @param EngineInterface $templating
52
     */
53
    public function __construct(
54
        ParticipantProviderInterface $participantProvider,
55
        ArchivedProviderPagerFantaInterface $archivedProvider,
56
        EngineInterface $templating
57
    ) {
58
        $this->participantProvider = $participantProvider;
59
        $this->archivedProvider = $archivedProvider;
60
        $this->templating = $templating;
61
    }
62
63
    /**
64
     * Shows archived threads for the logged in user
65
     *
66
     * @param integer $page The page we are on
67
     *
68
     * @return Response
69
     */
70
    public function showAction($page)
71
    {
72
        $loggedInUser = $this->participantProvider->getAuthenticatedParticipant();
73
        $pagerfanta = $this->archivedProvider->getArchivedThreadsPagerfanta($loggedInUser, $page);
74
        $view = 'MilioooMessagingBundle:Folders:archived.html.twig';
75
76
        return $this->templating->renderResponse($view, ['pagerfanta' => $pagerfanta]);
77
    }
78
}
79