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

Version20170217184500   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 2
Bugs 0 Features 0
Metric Value
dl 0
loc 36
rs 10
c 2
b 0
f 0
wmc 5
lcom 0
cbo 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
B up() 0 22 4
A down() 0 4 1
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