Completed
Push — master ( 087209...c3cd5e )
by chihiro
393:45 queued 393:26
created

Version20170217184500::up()   B

Complexity

Conditions 4
Paths 8

Size

Total Lines 22
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 4
eloc 12
nc 8
nop 1
dl 0
loc 22
rs 8.9197
c 2
b 0
f 0
1
<?php
2
3
namespace DoctrineMigrations;
4
5
use Doctrine\DBAL\Migrations\AbstractMigration;
6
use Doctrine\DBAL\Schema\Schema;
7
use Eccube\Application;
8
use Symfony\Component\Yaml\Yaml;
9
10
/**
11
 * Auto-generated Migration: Please modify to your needs!
12
 */
13
class Version20170217184500 extends AbstractMigration
14
{
15
    /**
16
     * @param Schema $schema
17
     */
18
    public function up(Schema $schema)
19
    {
20
        // config.ymlの更新
21
        $app = Application::getInstance();
22
        $file = $app['config']['root_dir'].'/app/config/eccube/config.yml';
23
        $config = Yaml::parse(file_get_contents($file));
24
25
        $appendConfig = array();
26
27
        // キーが未定義の場合は初期値を設定する
28
        if (!array_key_exists('trusted_proxies_connection_only', $config)) {
29
            $appendConfig['trusted_proxies_connection_only'] = 0;
30
        }
31
        if (!array_key_exists('trusted_proxies', $config)) {
32
            $appendConfig['trusted_proxies'] = array();
33
        }
34
35
        if (count($appendConfig)) {
36
            file_put_contents($file, "\n", FILE_APPEND);
37
            file_put_contents($file, Yaml::dump($appendConfig), FILE_APPEND);
38
        }
39
    }
40
41
    /**
42
     * @param Schema $schema
43
     */
44
    public function down(Schema $schema)
45
    {
46
        // do nothing
47
    }
48
}
49