diff options
author | Jeremy Benoist <jeremy.benoist@gmail.com> | 2016-01-21 12:23:45 +0100 |
---|---|---|
committer | Jeremy Benoist <jeremy.benoist@gmail.com> | 2016-01-31 14:48:26 +0100 |
commit | d6ba77e888064dcf5757fb008426eb8bfcd6dd4c (patch) | |
tree | 211af8242a6fe1f342fc8e3393eb1ad7808cf0d3 | |
parent | 278b221e6545c5990e9d79a4c6bb4491b22a7a85 (diff) | |
download | wallabag-d6ba77e888064dcf5757fb008426eb8bfcd6dd4c.tar.gz wallabag-d6ba77e888064dcf5757fb008426eb8bfcd6dd4c.tar.zst wallabag-d6ba77e888064dcf5757fb008426eb8bfcd6dd4c.zip |
Create internal setting on install & fixtures
-rw-r--r-- | src/Wallabag/CoreBundle/Command/InstallCommand.php | 90 | ||||
-rw-r--r-- | src/Wallabag/CoreBundle/DataFixtures/ORM/LoadSettingData.php | 113 |
2 files changed, 203 insertions, 0 deletions
diff --git a/src/Wallabag/CoreBundle/Command/InstallCommand.php b/src/Wallabag/CoreBundle/Command/InstallCommand.php index 7a7e3a64..f6c85cf9 100644 --- a/src/Wallabag/CoreBundle/Command/InstallCommand.php +++ b/src/Wallabag/CoreBundle/Command/InstallCommand.php | |||
@@ -12,6 +12,7 @@ use Symfony\Component\Console\Output\OutputInterface; | |||
12 | use Symfony\Component\Console\Question\ConfirmationQuestion; | 12 | use Symfony\Component\Console\Question\ConfirmationQuestion; |
13 | use Symfony\Component\Console\Question\Question; | 13 | use Symfony\Component\Console\Question\Question; |
14 | use Wallabag\CoreBundle\Entity\Config; | 14 | use Wallabag\CoreBundle\Entity\Config; |
15 | use Craue\ConfigBundle\Entity\Setting; | ||
15 | 16 | ||
16 | class InstallCommand extends ContainerAwareCommand | 17 | class InstallCommand extends ContainerAwareCommand |
17 | { | 18 | { |
@@ -212,6 +213,95 @@ class InstallCommand extends ContainerAwareCommand | |||
212 | 213 | ||
213 | $em->persist($config); | 214 | $em->persist($config); |
214 | 215 | ||
216 | // cleanup before insert new stuff | ||
217 | $em->createQuery('DELETE FROM CraueConfigBundle:Setting')->execute(); | ||
218 | |||
219 | $settings = [ | ||
220 | [ | ||
221 | 'name' => 'download_pictures', | ||
222 | 'value' => '1', | ||
223 | 'section' => 'entry', | ||
224 | ], | ||
225 | [ | ||
226 | 'name' => 'carrot', | ||
227 | 'value' => '1', | ||
228 | 'section' => 'entry', | ||
229 | ], | ||
230 | [ | ||
231 | 'name' => 'share_diaspora', | ||
232 | 'value' => '1', | ||
233 | 'section' => 'entry', | ||
234 | ], | ||
235 | [ | ||
236 | 'name' => 'diaspora_url', | ||
237 | 'value' => 'http://diasporapod.com', | ||
238 | 'section' => 'entry', | ||
239 | ], | ||
240 | [ | ||
241 | 'name' => 'share_shaarli', | ||
242 | 'value' => '1', | ||
243 | 'section' => 'entry', | ||
244 | ], | ||
245 | [ | ||
246 | 'name' => 'shaarli_url', | ||
247 | 'value' => 'http://myshaarli.com', | ||
248 | 'section' => 'entry', | ||
249 | ], | ||
250 | [ | ||
251 | 'name' => 'share_mail', | ||
252 | 'value' => '1', | ||
253 | 'section' => 'entry', | ||
254 | ], | ||
255 | [ | ||
256 | 'name' => 'share_twitter', | ||
257 | 'value' => '1', | ||
258 | 'section' => 'entry', | ||
259 | ], | ||
260 | [ | ||
261 | 'name' => 'export_epub', | ||
262 | 'value' => '1', | ||
263 | 'section' => 'export', | ||
264 | ], | ||
265 | [ | ||
266 | 'name' => 'export_mobi', | ||
267 | 'value' => '1', | ||
268 | 'section' => 'export', | ||
269 | ], | ||
270 | [ | ||
271 | 'name' => 'export_pdf', | ||
272 | 'value' => '1', | ||
273 | 'section' => 'export', | ||
274 | ], | ||
275 | [ | ||
276 | 'name' => 'pocket_consumer_key', | ||
277 | 'value' => NULL, | ||
278 | 'section' => 'import', | ||
279 | ], | ||
280 | [ | ||
281 | 'name' => 'show_printlink', | ||
282 | 'value' => '1', | ||
283 | 'section' => 'entry', | ||
284 | ], | ||
285 | [ | ||
286 | 'name' => 'wallabag_support_url', | ||
287 | 'value' => 'https://www.wallabag.org/pages/support.html', | ||
288 | 'section' => 'misc', | ||
289 | ], | ||
290 | [ | ||
291 | 'name' => 'wallabag_url', | ||
292 | 'value' => 'http://v2.wallabag.org', | ||
293 | 'section' => 'misc', | ||
294 | ], | ||
295 | ]; | ||
296 | |||
297 | foreach ($settings as $setting) { | ||
298 | $newSetting = new Setting(); | ||
299 | $newSetting->setName($setting['name']); | ||
300 | $newSetting->setValue($setting['value']); | ||
301 | $newSetting->setSection($setting['section']); | ||
302 | $em->persist($newSetting); | ||
303 | } | ||
304 | |||
215 | $em->flush(); | 305 | $em->flush(); |
216 | 306 | ||
217 | $this->defaultOutput->writeln(''); | 307 | $this->defaultOutput->writeln(''); |
diff --git a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadSettingData.php b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadSettingData.php new file mode 100644 index 00000000..863d28f5 --- /dev/null +++ b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadSettingData.php | |||
@@ -0,0 +1,113 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Wallabag\CoreBundle\DataFixtures\ORM; | ||
4 | |||
5 | use Doctrine\Common\DataFixtures\AbstractFixture; | ||
6 | use Doctrine\Common\DataFixtures\OrderedFixtureInterface; | ||
7 | use Doctrine\Common\Persistence\ObjectManager; | ||
8 | use Craue\ConfigBundle\Entity\Setting; | ||
9 | |||
10 | class LoadSettingData extends AbstractFixture implements OrderedFixtureInterface | ||
11 | { | ||
12 | /** | ||
13 | * {@inheritdoc} | ||
14 | */ | ||
15 | public function load(ObjectManager $manager) | ||
16 | { | ||
17 | $settings = [ | ||
18 | [ | ||
19 | 'name' => 'download_pictures', | ||
20 | 'value' => '1', | ||
21 | 'section' => 'entry', | ||
22 | ], | ||
23 | [ | ||
24 | 'name' => 'carrot', | ||
25 | 'value' => '1', | ||
26 | 'section' => 'entry', | ||
27 | ], | ||
28 | [ | ||
29 | 'name' => 'share_diaspora', | ||
30 | 'value' => '1', | ||
31 | 'section' => 'entry', | ||
32 | ], | ||
33 | [ | ||
34 | 'name' => 'diaspora_url', | ||
35 | 'value' => 'http://diasporapod.com', | ||
36 | 'section' => 'entry', | ||
37 | ], | ||
38 | [ | ||
39 | 'name' => 'share_shaarli', | ||
40 | 'value' => '1', | ||
41 | 'section' => 'entry', | ||
42 | ], | ||
43 | [ | ||
44 | 'name' => 'shaarli_url', | ||
45 | 'value' => 'http://myshaarli.com', | ||
46 | 'section' => 'entry', | ||
47 | ], | ||
48 | [ | ||
49 | 'name' => 'share_mail', | ||
50 | 'value' => '1', | ||
51 | 'section' => 'entry', | ||
52 | ], | ||
53 | [ | ||
54 | 'name' => 'share_twitter', | ||
55 | 'value' => '1', | ||
56 | 'section' => 'entry', | ||
57 | ], | ||
58 | [ | ||
59 | 'name' => 'export_epub', | ||
60 | 'value' => '1', | ||
61 | 'section' => 'export', | ||
62 | ], | ||
63 | [ | ||
64 | 'name' => 'export_mobi', | ||
65 | 'value' => '1', | ||
66 | 'section' => 'export', | ||
67 | ], | ||
68 | [ | ||
69 | 'name' => 'export_pdf', | ||
70 | 'value' => '1', | ||
71 | 'section' => 'export', | ||
72 | ], | ||
73 | [ | ||
74 | 'name' => 'pocket_consumer_key', | ||
75 | 'value' => NULL, | ||
76 | 'section' => 'import', | ||
77 | ], | ||
78 | [ | ||
79 | 'name' => 'show_printlink', | ||
80 | 'value' => '1', | ||
81 | 'section' => 'entry', | ||
82 | ], | ||
83 | [ | ||
84 | 'name' => 'wallabag_support_url', | ||
85 | 'value' => 'https://www.wallabag.org/pages/support.html', | ||
86 | 'section' => 'misc', | ||
87 | ], | ||
88 | [ | ||
89 | 'name' => 'wallabag_url', | ||
90 | 'value' => 'http://v2.wallabag.org', | ||
91 | 'section' => 'misc', | ||
92 | ], | ||
93 | ]; | ||
94 | |||
95 | foreach ($settings as $setting) { | ||
96 | $newSetting = new Setting(); | ||
97 | $newSetting->setName($setting['name']); | ||
98 | $newSetting->setValue($setting['value']); | ||
99 | $newSetting->setSection($setting['section']); | ||
100 | $manager->persist($newSetting); | ||
101 | } | ||
102 | |||
103 | $manager->flush(); | ||
104 | } | ||
105 | |||
106 | /** | ||
107 | * {@inheritdoc} | ||
108 | */ | ||
109 | public function getOrder() | ||
110 | { | ||
111 | return 50; | ||
112 | } | ||
113 | } | ||