Passed
Push — 1.11.x ( 47915c...7101db )
by Yannick
09:38
created

plugin/lti_provider/src/Form/FrmEdit.php (1 issue)

Labels
Severity
1
<?php
2
/* For licensing terms, see /license.txt */
3
4
namespace Chamilo\PluginBundle\LtiProvider\Form;
5
6
use Chamilo\PluginBundle\Entity\LtiProvider\Platform;
7
use Exception;
8
use FormValidator;
9
use LtiProviderPlugin;
10
11
/**
12
 * Class FrmEdit.
13
 */
14
class FrmEdit extends FormValidator
15
{
16
    /**
17
     * @var Platform|null
18
     */
19
    private $platform;
20
21
    /**
22
     * FrmEdit constructor.
23
     */
24
    public function __construct(
25
        string $name,
26
        array $attributes = [],
27
        Platform $platform = null
28
    ) {
29
        parent::__construct($name, 'POST', '', '', $attributes, self::LAYOUT_HORIZONTAL);
30
31
        $this->platform = $platform;
32
    }
33
34
    /**
35
     * Build the form.
36
     */
37
    public function build()
38
    {
39
        $plugin = LtiProviderPlugin::create();
40
        $this->addHeader($plugin->get_lang('ConnectionDetails'));
41
42
        $this->addText('issuer', $plugin->get_lang('PlatformName'));
43
        $this->addUrl('auth_login_url', $plugin->get_lang('AuthLoginUrl'));
44
        $this->addUrl('auth_token_url', $plugin->get_lang('AuthTokenUrl'));
45
        $this->addUrl('key_set_url', $plugin->get_lang('KeySetUrl'));
46
        $this->addText('client_id', $plugin->get_lang('ClientId'));
47
        $this->addText('deployment_id', $plugin->get_lang('DeploymentId'));
48
        $this->addText('kid', $plugin->get_lang('KeyId'));
49
50
        $this->addButtonCreate($plugin->get_lang('EditPlatform'));
51
        $this->addHidden('id', $this->platform->getId());
0 ignored issues
show
The method getId() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

51
        $this->addHidden('id', $this->platform->/** @scrutinizer ignore-call */ getId());

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
52
        $this->addHidden('action', 'edit');
53
        $this->applyFilter('__ALL__', 'trim');
54
    }
55
56
    /**
57
     * @throws Exception
58
     */
59
    public function setDefaultValues(): void
60
    {
61
        $defaults = [];
62
        $defaults['issuer'] = $this->platform->getIssuer();
63
        $defaults['auth_login_url'] = $this->platform->getAuthLoginUrl();
64
        $defaults['auth_token_url'] = $this->platform->getAuthTokenUrl();
65
        $defaults['key_set_url'] = $this->platform->getKeySetUrl();
66
        $defaults['client_id'] = $this->platform->getClientId();
67
        $defaults['deployment_id'] = $this->platform->getDeploymentId();
68
        $defaults['kid'] = $this->platform->getKid();
69
70
        $this->setDefaults($defaults);
71
    }
72
}
73