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

LocaleSwitcherListener   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A onBlock() 0 14 2
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\EventListener;
13
14
use Sonata\BlockBundle\Event\BlockEvent;
15
use Sonata\BlockBundle\Model\Block;
16
17
/**
18
 * @author Nicolas Bastien <[email protected]>
19
 */
20
class LocaleSwitcherListener
21
{
22
    /**
23
     * @param BlockEvent $event
24
     */
25
    public function onBlock(BlockEvent $event, $eventName)
26
    {
27
        $settings = $event->getSettings();
28
        if ($eventName == 'sonata.block.event.sonata.admin.show.top') {
29
            $settings['locale_switcher_route'] = 'show';
30
        }
31
32
        $block = new Block();
33
        $block->setSettings($settings);
34
        $block->setName('sonata_translation.block.locale_switcher');
35
        $block->setType('sonata_translation.block.locale_switcher');
36
37
        $event->addBlock($block);
38
    }
39
}
40