aboutsummaryrefslogtreecommitdiffhomepage
path: root/app/DoctrineMigrations/Version20170602075214.php
diff options
context:
space:
mode:
authorJérémy Benoist <j0k3r@users.noreply.github.com>2017-06-06 15:25:05 +0200
committerGitHub <noreply@github.com>2017-06-06 15:25:05 +0200
commit6ed2627bb35561e32d702fbe67247349dd67453e (patch)
tree75d8c130d26f0591fe858cd9eacf6b97aed4af7e /app/DoctrineMigrations/Version20170602075214.php
parent9fe87bc2e20fa95573287a61ef9798cc15648187 (diff)
parent438329be467d77595f549da48a6b49f38ece9b55 (diff)
downloadwallabag-6ed2627bb35561e32d702fbe67247349dd67453e.tar.gz
wallabag-6ed2627bb35561e32d702fbe67247349dd67453e.tar.zst
wallabag-6ed2627bb35561e32d702fbe67247349dd67453e.zip
Merge pull request #3177 from wallabag/api-create-user-update
API user creation behing a toggle
Diffstat (limited to 'app/DoctrineMigrations/Version20170602075214.php')
-rw-r--r--app/DoctrineMigrations/Version20170602075214.php52
1 files changed, 52 insertions, 0 deletions
diff --git a/app/DoctrineMigrations/Version20170602075214.php b/app/DoctrineMigrations/Version20170602075214.php
new file mode 100644
index 00000000..451d16ba
--- /dev/null
+++ b/app/DoctrineMigrations/Version20170602075214.php
@@ -0,0 +1,52 @@
1<?php
2
3namespace Application\Migrations;
4
5use Doctrine\DBAL\Migrations\AbstractMigration;
6use Doctrine\DBAL\Schema\Schema;
7use Symfony\Component\DependencyInjection\ContainerAwareInterface;
8use Symfony\Component\DependencyInjection\ContainerInterface;
9
10/**
11 * Add api_user_registration in craue_config_setting.
12 */
13class Version20170602075214 extends AbstractMigration implements ContainerAwareInterface
14{
15 /**
16 * @var ContainerInterface
17 */
18 private $container;
19
20 public function setContainer(ContainerInterface $container = null)
21 {
22 $this->container = $container;
23 }
24
25 private function getTable($tableName)
26 {
27 return $this->container->getParameter('database_table_prefix').$tableName;
28 }
29
30 /**
31 * @param Schema $schema
32 */
33 public function up(Schema $schema)
34 {
35 $apiUserRegistration = $this->container
36 ->get('doctrine.orm.default_entity_manager')
37 ->getConnection()
38 ->fetchArray('SELECT * FROM '.$this->getTable('craue_config_setting')." WHERE name = 'api_user_registration'");
39
40 $this->skipIf(false !== $apiUserRegistration, 'It seems that you already played this migration.');
41
42 $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('api_user_registration', '0', 'api')");
43 }
44
45 /**
46 * @param Schema $schema
47 */
48 public function down(Schema $schema)
49 {
50 $this->addSql('DELETE FROM '.$this->getTable('craue_config_setting')." WHERE name = 'api_user_registration';");
51 }
52}