ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilLTIConsumeProviderSettingsGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
4
5
15{
16 const CMD_SHOW_SETTINGS = 'showSettings';
17 const CMD_SAVE_SETTINGS = 'saveSettings';
18
22 protected $object;
23
27 protected $access;
28
34 {
35 $this->object = $object;
36 $this->access = $access;
37 }
38
42 public function executeCommand()
43 {
44 global $DIC; /* @var \ILIAS\DI\Container $DIC */
45
46 switch ($DIC->ctrl()->getNextClass()) {
47 default:
48
49 $command = $DIC->ctrl()->getCmd(self::CMD_SHOW_SETTINGS) . 'Cmd';
50 $this->{$command}();
51 }
52 }
53
54 protected function showSettingsCmd(ilLTIConsumeProviderFormGUI $form = null)
55 {
56 global $DIC; /* @var \ILIAS\DI\Container $DIC */
57
58 if ($form === null) {
59 $form = $this->buildForm($this->object->getProvider());
60 }
61
62 $DIC->ui()->mainTemplate()->setContent($form->getHTML());
63 }
64
65 protected function saveSettingsCmd()
66 {
67 global $DIC; /* @var \ILIAS\DI\Container $DIC */
68
69 $form = $this->buildForm($this->object->getProvider());
70
71 if ($form->checkInput()) {
72 $form->initProvider($this->object->getProvider());
73 $this->object->getProvider()->save();
74
75 $DIC->ctrl()->redirect($this, self::CMD_SHOW_SETTINGS);
76 }
77
78 $this->showSettingsCmd($form);
79 }
80
84 protected function buildForm(ilLTIConsumeProvider $provider)
85 {
86 global $DIC; /* @var \ILIAS\DI\Container $DIC */
87
88 $form = new ilLTIConsumeProviderFormGUI($provider);
89
90 $form->initForm(
91 $DIC->ctrl()->getFormAction($this),
92 self::CMD_SAVE_SETTINGS,
93 self::CMD_SHOW_SETTINGS
94 );
95
96 return $form;
97 }
98}
An exception for terminatinating execution or to throw for unit testing.
showSettingsCmd(ilLTIConsumeProviderFormGUI $form=null)
__construct(ilObjLTIConsumer $object, ilLTIConsumerAccess $access)
ilLTIConsumerAccess constructor.
global $DIC
Definition: goto.php:24