aboutsummaryrefslogtreecommitdiff
path: root/lib/models/LtiPlatform.php
blob: 6a76adda87806fc199b310cc90712a3151b5872f (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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
/*
 * This file is part of Stud.IP.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 *
 * @author      Moritz Strohm <strohm@data-quest.de>
 * @copyright   2025
 * @license     http://www.gnu.org/licenses/gpl-2.0.html GPL version 2
 * @category    Stud.IP
 */


/**
 * The LtiPlatform class represents LTI 1.3A platforms that are using
 * parts of this Stud.IP as LTI tool.
 *
 * @property int $id database column
 * @property int $range_id database column
 * @property string $creator_id database column
 * @property string $name database column
 * @property string $url database column
 * @property string $oauth2_access_token_url database column
 * @property string $oidc_init_url database column
 * @property string $jwks_url database column
 * @property string $jwks_key_id database column
 */
class LtiPlatform extends SimpleORMap
{
    /**
     * @inheritDoc
     */
    protected static function configure($config = [])
    {
        $config['db_table'] = 'lti_platforms';

        $config['belongs_to']['course'] = [
            'class_name'  => Course::class,
            'foreign_key' => 'range_id'
        ];
        $config['belongs_to']['creator'] = [
            'class_name'  => User::class,
            'foreign_key' => 'creator_id'
        ];

        parent::configure($config);
    }

    public function getKeyring() : ?Keyring
    {
        return Keyring::findOneBySQL(
            "`range_type` = 'lti_platform'
            AND `range_id` = :platform_id",
            ['platform_id' => $this->id]
        );
    }
}