Completed
Push — master ( d17154...1fc820 )
by Sullivan
11:02 queued 08:59
created

LocaleSwitcherBlockService   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A execute() 0 7 1
A setDefaultSettings() 0 4 1
A configureSettings() 0 12 1
1
<?php
2
3
/*
4
 * This file is part of the Sonata Project package.
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
     * @deprecated Will be removed when upgrading to SonataBlockBundle 3
27
     */
28
    public function setDefaultSettings(OptionsResolverInterface $resolver)
29
    {
30
        $this->configureSettings($resolver);
0 ignored issues
show
Documentation introduced by
$resolver is of type object<Symfony\Component...tionsResolverInterface>, but the function expects a object<Symfony\Component...solver\OptionsResolver>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
31
    }
32
33
    /**
34
     * {@inheritdoc}
35
     */
36
    public function configureSettings(OptionsResolver $resolver)
37
    {
38
        $resolver->setDefaults(
39
            array(
40
                'admin'                            => null,
41
                'object'                           => null,
42
                'template'                         => 'SonataTranslationBundle:Block:block_locale_switcher.html.twig',
43
                'locale_switcher_route'            => null,
44
                'locale_switcher_route_parameters' => array(),
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