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

DefaultController   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 2
c 2
b 0
f 0
lcom 1
cbo 2
dl 0
loc 25
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A indexAction() 0 18 2
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