Completed
Push — master ( 530ce9...1b2ae5 )
by Paweł
23:42 queued 20:31
created

DefaultController::indexAction()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 18
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 18
rs 9.4285
cc 2
eloc 11
nc 2
nop 0
1
<?php
2
3
/**
4
 * This file is part of the Superdesk Web Publisher Web Renderer Bundle.
5
 *
6
 * Copyright 2015 Sourcefabric z.u. and contributors.
7
 *
8
 * For the full copyright and license information, please see the
9
 * AUTHORS and LICENSE files distributed with this source code.
10
 *
11
 * @copyright 2015 Sourcefabric z.ú.
12
 * @license http://www.superdesk.org/license
13
 */
14
namespace SWP\Bundle\WebRendererBundle\Controller;
15
16
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
17
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
18
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
19
20
class DefaultController extends Controller
21
{
22
    /**
23
     * @Route("/", name="homepage")
24
     * @Method("GET")
25
     */
26
    public function indexAction()
27
    {
28
        $pathBuilder = $this->get('swp_multi_tenancy.path_builder');
29
        $manager = $this->get('doctrine_phpcr')->getManager();
30
        $site = $manager->find('SWP\Bundle\ContentBundle\Document\Site', $pathBuilder->build('/'));
31
        $homepage = $site->getHomepage();
32
33
        if (!$homepage) {
34
            throw $this->createNotFoundException('No homepage configured!');
35
        }
36
37
        $tenantContext = $this->get('swp_multi_tenancy.tenant_context');
38
39
        return $this->render('index.html.twig', [
40
            'tenant' => $tenantContext->getTenant(),
41
            'page' => $homepage,
42
        ]);
43
    }
44
}
45