diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/DoctrineMigrations/Version20190129120000.php | 160 |
1 files changed, 119 insertions, 41 deletions
diff --git a/app/DoctrineMigrations/Version20190129120000.php b/app/DoctrineMigrations/Version20190129120000.php index 61e0ef4c..5f25d67d 100644 --- a/app/DoctrineMigrations/Version20190129120000.php +++ b/app/DoctrineMigrations/Version20190129120000.php | |||
@@ -8,54 +8,132 @@ use Wallabag\CoreBundle\Doctrine\WallabagMigration; | |||
8 | /** | 8 | /** |
9 | * Add missing entries in craue_config_setting. | 9 | * Add missing entries in craue_config_setting. |
10 | */ | 10 | */ |
11 | class Version20190129120000 extends WallabagMigration | 11 | final class Version20190129120000 extends WallabagMigration |
12 | { | 12 | { |
13 | var $settings = array( | 13 | private $settings = [ |
14 | array("name" => "carrot", "value" => "1", "section" => "entry"), | 14 | [ |
15 | array("name" => "share_diaspora", "value" => "1", "section" => "entry"), | 15 | 'name' => 'carrot', |
16 | array("name" => "diaspora_url", "value" => "http://diasporapod.com", "section" => "entry"), | 16 | 'value' => '1', |
17 | array("name" => "share_shaarli", "value" => "1", "section" => "entry"), | 17 | 'section' => 'entry', |
18 | array("name" => "shaarli_url", "value" => "http://myshaarli.com", "section" => "entry"), | 18 | ], |
19 | array("name" => "share_mail", "value" => "1", "section" => "entry"), | 19 | [ |
20 | array("name" => "share_twitter", "value" => "1", "section" => "entry"), | 20 | 'name' => 'share_diaspora', |
21 | array("name" => "show_printlink", "value" => "1", "section" => "entry"), | 21 | 'value' => '1', |
22 | array("name" => "export_epub", "value" => "1", "section" => "export"), | 22 | 'section' => 'entry', |
23 | array("name" => "export_mobi", "value" => "1", "section" => "export"), | 23 | ], |
24 | array("name" => "export_pdf", "value" => "1", "section" => "export"), | 24 | [ |
25 | array("name" => "export_csv", "value" => "1", "section" => "export"), | 25 | 'name' => 'diaspora_url', |
26 | array("name" => "export_json", "value" => "1", "section" => "export"), | 26 | 'value' => 'http://diasporapod.com', |
27 | array("name" => "export_txt", "value" => "1", "section" => "export"), | 27 | 'section' => 'entry', |
28 | array("name" => "export_xml", "value" => "1", "section" => "export"), | 28 | ], |
29 | array("name" => "piwik_enabled", "value" => "0", "section" => "analytics"), | 29 | [ |
30 | array("name" => "piwik_host", "value" => "v2.wallabag.org", "section" => "analytics"), | 30 | 'name' => 'share_shaarli', |
31 | array("name" => "piwik_site_id", "value" => "1", "section" => "analytics"), | 31 | 'value' => '1', |
32 | array("name" => "demo_mode_enabled", "value" => "0", "section" => "misc"), | 32 | 'section' => 'entry', |
33 | array("name" => "demo_mode_username", "value" => "wallabag", "section" => "misc"), | 33 | ], |
34 | array("name" => "wallabag_support_url", "value" => "https://www.wallabag.org/pages/support.html", "section" => "misc"), | 34 | [ |
35 | ); | 35 | 'name' => 'shaarli_url', |
36 | 'value' => 'http://myshaarli.com', | ||
37 | 'section' => 'entry', | ||
38 | ], | ||
39 | [ | ||
40 | 'name' => 'share_mail', | ||
41 | 'value' => '1', | ||
42 | 'section' => 'entry', | ||
43 | ], | ||
44 | [ | ||
45 | 'name' => 'share_twitter', | ||
46 | 'value' => '1', | ||
47 | 'section' => 'entry', | ||
48 | ], | ||
49 | [ | ||
50 | 'name' => 'show_printlink', | ||
51 | 'value' => '1', | ||
52 | 'section' => 'entry', | ||
53 | ], | ||
54 | [ | ||
55 | 'name' => 'export_epub', | ||
56 | 'value' => '1', | ||
57 | 'section' => 'export', | ||
58 | ], | ||
59 | [ | ||
60 | 'name' => 'export_mobi', | ||
61 | 'value' => '1', | ||
62 | 'section' => 'export', | ||
63 | ], | ||
64 | [ | ||
65 | 'name' => 'export_pdf', | ||
66 | 'value' => '1', | ||
67 | 'section' => 'export', | ||
68 | ], | ||
69 | [ | ||
70 | 'name' => 'export_csv', | ||
71 | 'value' => '1', | ||
72 | 'section' => 'export', | ||
73 | ], | ||
74 | [ | ||
75 | 'name' => 'export_json', | ||
76 | 'value' => '1', | ||
77 | 'section' => 'export', | ||
78 | ], | ||
79 | [ | ||
80 | 'name' => 'export_txt', | ||
81 | 'value' => '1', | ||
82 | 'section' => 'export', | ||
83 | ], | ||
84 | [ | ||
85 | 'name' => 'export_xml', | ||
86 | 'value' => '1', | ||
87 | 'section' => 'export', | ||
88 | ], | ||
89 | [ | ||
90 | 'name' => 'piwik_enabled', | ||
91 | 'value' => '0', | ||
92 | 'section' => 'analytics', | ||
93 | ], | ||
94 | [ | ||
95 | 'name' => 'piwik_host', | ||
96 | 'value' => 'v2.wallabag.org', | ||
97 | 'section' => 'analytics', | ||
98 | ], | ||
99 | [ | ||
100 | 'name' => 'piwik_site_id', | ||
101 | 'value' => '1', | ||
102 | 'section' => 'analytics', | ||
103 | ], | ||
104 | [ | ||
105 | 'name' => 'demo_mode_enabled', | ||
106 | 'value' => '0', | ||
107 | 'section' => 'misc', | ||
108 | ], | ||
109 | [ | ||
110 | 'name' => 'demo_mode_username', | ||
111 | 'value' => 'wallabag', | ||
112 | 'section' => 'misc', | ||
113 | ], | ||
114 | [ | ||
115 | 'name' => 'wallabag_support_url', | ||
116 | 'value' => 'https://www.wallabag.org/pages/support.html', | ||
117 | 'section' => 'misc', | ||
118 | ], | ||
119 | ]; | ||
36 | 120 | ||
37 | /** | 121 | /** |
38 | * @param Schema $schema | 122 | * @param Schema $schema |
39 | */ | 123 | */ |
40 | public function up(Schema $schema) | 124 | public function up(Schema $schema) |
41 | { | 125 | { |
42 | $piwikEnabled = $this->container | 126 | foreach ($this->settings as $setting) { |
43 | ->get('doctrine.orm.default_entity_manager') | 127 | $settingEnabled = $this->container |
44 | ->getConnection() | 128 | ->get('doctrine.orm.default_entity_manager') |
45 | ->fetchArray('SELECT * FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'piwik_enabled'"); | 129 | ->getConnection() |
130 | ->fetchArray('SELECT * FROM ' . $this->getTable('craue_config_setting') . " WHERE name = '" . $setting['name'] . "'"); | ||
46 | 131 | ||
47 | $this->skipIf(false !== $piwikEnabled, 'It seems that you already played this migration, or user the wallabag:install command.'); | 132 | if (false !== $settingEnabled) { |
133 | continue; | ||
134 | } | ||
48 | 135 | ||
49 | foreach ($this->settings as $setting) { | 136 | $this->addSql('INSERT INTO ' . $this->getTable('craue_config_setting') . " (name, value, section) VALUES ('" . $setting['name'] . "', '" . $setting['value'] . "', '" . $setting['section'] . "');"); |
50 | $this->addSql(" | ||
51 | INSERT INTO " . $this->getTable('craue_config_setting') . " | ||
52 | (name, value, section) | ||
53 | VALUES ( | ||
54 | '" . $setting['name'] . "', | ||
55 | '" . $setting['value'] . "', | ||
56 | '" . $setting['section'] . "' | ||
57 | ); | ||
58 | "); | ||
59 | } | 137 | } |
60 | } | 138 | } |
61 | 139 | ||
@@ -65,8 +143,8 @@ class Version20190129120000 extends WallabagMigration | |||
65 | public function down(Schema $schema) | 143 | public function down(Schema $schema) |
66 | { | 144 | { |
67 | foreach ($this->settings as $setting) { | 145 | foreach ($this->settings as $setting) { |
68 | $this->addSql(" | 146 | $this->addSql(' |
69 | DELETE FROM " . $this->getTable('craue_config_setting') . " | 147 | DELETE FROM ' . $this->getTable('craue_config_setting') . " |
70 | WHERE name = '" . $setting['name'] . "'; | 148 | WHERE name = '" . $setting['name'] . "'; |
71 | "); | 149 | "); |
72 | } | 150 | } |