Completed
Push — 0.1 ( e9e76a...75f716 )
by Paweł
234:22 queued 184:44
created

LoadWidgetsData   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
c 0
b 0
f 0
lcom 0
cbo 5
dl 0
loc 42
ccs 0
cts 29
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
B load() 0 31 1
A getOrder() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the Superdesk Web Publisher Fixtures Bundle.
5
 *
6
 * Copyright 2015 Sourcefabric z.ú. 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
15
namespace SWP\Bundle\FixturesBundle\DataFixtures\ORM;
16
17
use Doctrine\Common\DataFixtures\FixtureInterface;
18
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
19
use SWP\Bundle\FixturesBundle\AbstractFixture;
20
use Doctrine\Common\Persistence\ObjectManager;
21
use SWP\Bundle\CoreBundle\Model\WidgetModel;
22
use SWP\Component\MultiTenancy\Model\TenantInterface;
23
24
class LoadWidgetsData extends AbstractFixture implements FixtureInterface, OrderedFixtureInterface
25
{
26
    /**
27
     * {@inheritdoc}
28
     */
29
    public function load(ObjectManager $manager)
30
    {
31
        /** @var TenantInterface $tenant */
32
        $tenant = $this->container->get('swp.repository.tenant')->findOneBySubdomain('default');
33
34
        $widget = new WidgetModel();
35
        $widget->setType(WidgetModel::TYPE_MENU);
36
        $widget->setName('NavigationMain');
37
        $widget->setParameters([
38
            'menu_name' => 'mainNavigation',
39
            'template_name' => 'menu1.html.twig',
40
        ]);
41
        $widget->setTenantCode($tenant->getCode());
42
        $manager->persist($widget);
43
44
        $this->addReference('menu_widget_main', $widget);
45
46
        $widget = new WidgetModel();
47
        $widget->setType(WidgetModel::TYPE_MENU);
48
        $widget->setName('NavigationFooterPrim');
49
        $widget->setParameters([
50
            'menu_name' => 'footerPrim',
51
            'template_name' => 'menu2.html.twig',
52
        ]);
53
        $widget->setTenantCode($tenant->getCode());
54
        $manager->persist($widget);
55
56
        $manager->flush();
57
58
        $this->addReference('menu_widget_footer', $widget);
59
    }
60
61
    public function getOrder()
62
    {
63
        return 1;
64
    }
65
}
66