aboutsummaryrefslogtreecommitdiff
path: root/db/migrations/1.265_jsonapi_cors_origin_config.php
blob: 58a8fe7413c4cd34fc11cbb9ac8c11713f760f3f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php

class JsonapiCorsOriginConfig extends Migration
{
    public function description()
    {
        return 'Adds system config option allowing given domains as allowed CORS origins.';
    }

    /**
     * @SuppressWarnings(ShortMethodName)
     */
    public function up()
    {
        $query = "INSERT INTO `config` (
                    `field`, `value`, `type`, `range`, `section`,
                    `mkdate`, `chdate`,
                    `description`
                  ) VALUES (
                    'JSONAPI_CORS_ORIGIN', '[]', 'array', 'global', 'global',
                    UNIX_TIMESTAMP(), UNIX_TIMESTAMP(),
                    'Diese Einstellung definiert URIs, die mittels CORS auf die JSONAPI zugreifen dürfen.'
                  )";
        DBManager::get()->exec($query);
    }

    public function down()
    {
        $query = "DELETE `config`, `config_values`
                  FROM `config`
                  LEFT JOIN `config_values` USING (`field`)
                  WHERE `field` = 'JSONAPI_CORS_ORIGIN'";
        DBManager::get()->exec($query);
    }
}