Completed
Push — master ( 530ce9...1b2ae5 )
by Paweł
23:42 queued 20:31
created

LoadSitesData   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A load() 0 21 3
1
<?php
2
3
/**
4
 * This file is part of the Superdesk Web Publisher Fixtures Bundle.
5
 *
6
 * Copyright 2015 Sourcefabric z.u. 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
namespace SWP\Bundle\FixturesBundle\DataFixtures\PHPCR;
15
16
use Doctrine\Common\DataFixtures\FixtureInterface;
17
use Doctrine\Common\Persistence\ObjectManager;
18
use SWP\Bundle\FixturesBundle\AbstractFixture;
19
20
class LoadSitesData extends AbstractFixture implements FixtureInterface
21
{
22
    /**
23
     * {@inheritdoc}
24
     */
25
    public function load(ObjectManager $manager)
26
    {
27
        $site = $manager->find('SWP\Bundle\ContentBundle\Document\Site', '/swp/default');
28
29
        if (!$site) {
30
            throw new \Exception('Could not find /swp/default document!');
31
        }
32
33
        $page = $manager->find('SWP\Bundle\ContentBundle\Document\Route', '/swp/default/routes/homepage');
34
        $site->setHomepage($page);
35
36
        $site = $manager->find('SWP\Bundle\ContentBundle\Document\Site', '/swp/client1');
37
38
        if (!$site) {
39
            throw new \Exception('Could not find /swp/client1 document!');
40
        }
41
42
        $page2 = $manager->find('SWP\Bundle\ContentBundle\Document\Route', '/swp/client1/routes/homepage');
43
        $site->setHomepage($page2);
44
        $manager->flush();
45
    }
46
}
47