Completed
Push — bc-block-settings ( 54507f )
by David
02:13
created

LocaleSwitcherBlockService   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setDefaultSettings() 0 4 1
A configureSettings() 0 11 1
A execute() 0 7 1
1
<?php
2
3
/*
4
 * This file is part of the Sonata project.
5
 *
6
 * (c) Thomas Rabaix <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Sonata\TranslationBundle\Block;
13
14
use Sonata\BlockBundle\Block\BaseBlockService;
15
use Sonata\BlockBundle\Block\BlockContextInterface;
16
use Symfony\Component\HttpFoundation\Response;
17
use Symfony\Component\OptionsResolver\OptionsResolver;
18
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
19
20
/**
21
 * @author Nicolas Bastien <[email protected]>
22
 */
23
class LocaleSwitcherBlockService extends BaseBlockService
24
{
25
26
    /**
27
     * @deprecated Will be removed when upgrading to SonataBlockBundle 3
28
     */
29
    public function setDefaultSettings(OptionsResolverInterface $resolver)
30
    {
31
        $this->configureSettings($resolver);
32
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37
    public function configureSettings(OptionsResolver $resolver)
38
    {
39
        $resolver->setDefaults(
40
            array(
41
                'admin'                 => null,
42
                'object'                => null,
43
                'template'              => 'SonataTranslationBundle:Block:block_locale_switcher.html.twig',
44
                'locale_switcher_route' => null,
45
            )
46
        );
47
    }
48
49
    /**
50
     * {@inheritdoc}
51
     */
52
    public function execute(BlockContextInterface $blockContext, Response $response = null)
53
    {
54
        return $this->renderPrivateResponse($blockContext->getTemplate(), array(
55
            'block_context'  => $blockContext,
56
            'block'          => $blockContext->getBlock(),
57
        ), $response);
58
    }
59
}
60