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

LocaleSwitcherBlockService::setDefaultSettings()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 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