1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Sylius\Migrations; |
4
|
|
|
|
5
|
|
|
use Doctrine\DBAL\Migrations\AbstractMigration; |
6
|
|
|
use Doctrine\DBAL\Schema\Schema; |
7
|
|
|
use Sylius\Component\Addressing\Model\Scope; |
8
|
|
|
use Sylius\Component\Addressing\Model\ZoneInterface; |
9
|
|
|
use Sylius\Component\Addressing\Model\ZoneMemberInterface; |
10
|
|
|
use Sylius\Component\Core\Formatter\StringInflector; |
11
|
|
|
use Sylius\Component\Core\Model\TaxRateInterface; |
12
|
|
|
use Sylius\Component\Resource\Model\CodeAwareInterface; |
13
|
|
|
use Symfony\Component\DependencyInjection\ContainerAwareInterface; |
14
|
|
|
use Symfony\Component\DependencyInjection\ContainerInterface; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Auto-generated Migration: Please modify to your needs! |
18
|
|
|
*/ |
19
|
|
|
class Version20161209095131 extends AbstractMigration implements ContainerAwareInterface |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* @var ContainerInterface |
23
|
|
|
*/ |
24
|
|
|
private $container; |
25
|
|
|
|
26
|
|
|
public function setContainer(ContainerInterface $container = null) |
27
|
|
|
{ |
28
|
|
|
$this->container = $container; |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @param Schema $schema |
33
|
|
|
*/ |
34
|
|
|
public function up(Schema $schema) |
35
|
|
|
{ |
36
|
|
|
// this up() migration is auto-generated, please modify it to your needs |
37
|
|
|
|
38
|
|
|
$zoneRepository = $this->container->get('sylius.repository.zone'); |
39
|
|
|
$entityManager = $this->container->get('doctrine.orm.default_entity_manager'); |
40
|
|
|
|
41
|
|
|
/** @var ZoneInterface $zone */ |
42
|
|
|
foreach ($zoneRepository->findBy(['scope' => null]) as $zone) { |
43
|
|
|
$zone->setScope(Scope::ALL); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
$entityManager->flush(); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @param Schema $schema |
51
|
|
|
*/ |
52
|
|
|
public function down(Schema $schema) |
53
|
|
|
{ |
54
|
|
|
// this down() migration is auto-generated, please modify it to your needs |
55
|
|
|
|
56
|
|
|
$zoneRepository = $this->container->get('sylius.repository.zone'); |
57
|
|
|
$entityManager = $this->container->get('doctrine.orm.default_entity_manager'); |
58
|
|
|
|
59
|
|
|
/** @var ZoneInterface $zone */ |
60
|
|
|
foreach ($zoneRepository->findBy(['scope' => Scope::ALL]) as $zone) { |
61
|
|
|
$zone->setScope(''); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
$entityManager->flush(); |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
|