Passed
Pull Request — master (#487)
by Andrew
06:01
created

Version20190114115107   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 10
dl 0
loc 29
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Application\Migrations;
4
5
use Doctrine\DBAL\Migrations\AbstractMigration;
6
use Doctrine\DBAL\Schema\Schema;
7
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
8
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
9
10
/**
11
 * Auto-generated Migration: Please modify to your needs!
12
 */
13
class Version20190114115107 extends AbstractMigration implements ContainerAwareInterface
14
{
15
    use ContainerAwareTrait;
16
17
    /**
18
     * @param Schema $schema
19
     */
20
    public function up(Schema $schema)
21
    {
22
        // this up() migration is auto-generated, please modify it to your needs
23
        /** @var Event[] $events */
24
        $em = $this->container->get('doctrine.orm.entity_manager');
25
        $events = $em->getRepository('StfalconEventBundle:Event')->findAll();
26
        foreach ($events as $event) {
27
            $position = 1;
28
            foreach ($event->getBlocks() as $block) {
29
                $block->setPosition($position);
30
                $position ++;
31
            }
32
        }
33
34
        $em->flush();
35
    }
36
37
    /**
38
     * @param Schema $schema
39
     */
40
    public function down(Schema $schema)
41
    {
42
        // this down() migration is auto-generated, please modify it to your needs
43
44
    }
45
}
46