ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilStudyProgrammeCommonSettingsGUI.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
6{
7 const CMD_EDIT = 'editSettings';
8 const CMD_SAVE = 'saveSettings';
9
13 protected $object;
14
18 protected $ctrl;
19
23 protected $tpl;
24
28 protected $lng;
29
33 protected $object_service;
34
35 public function __construct(
40 ) {
41 $this->ctrl = $ctrl;
42 $this->tpl = $tpl;
43 $this->lng = $lng;
44 $this->object_service = $object_service;
45 }
46
47 public function executeCommand()
48 {
49 if (is_null($this->object)) {
50 throw new ilException('Object of ilObjStudyProgramme is not set');
51 }
52
53 $cmd = $this->ctrl->getCmd();
54 switch ($cmd) {
55 case self::CMD_EDIT:
56 return $this->editSettings();
57 break;
58 case self::CMD_SAVE:
59 $this->saveSettings();
60 break;
61 default:
62 throw new Exception('Unknown command ' . $cmd);
63 }
64 }
65
67 {
68 $this->object = $object;
69 }
70
71 protected function editSettings(ilPropertyFormGUI $form = null)
72 {
73 if (is_null($form)) {
74 $form = $this->buildForm();
75 }
76 return $form->getHTML();
77 }
78
79 protected function buildForm() : ilPropertyFormGUI
80 {
81 $form = new ilPropertyFormGUI();
82 $form->setFormAction($this->ctrl->getFormAction($this));
83 $form->setTitle($this->txt('obj_features'));
84 $form->addCommandButton(self::CMD_SAVE, $this->txt('save'));
85 $form->addCommandButton(self::CMD_EDIT, $this->txt('cancel'));
86
87 $this->addServiceSettingsToForm($form);
88
89 return $form;
90 }
91
93 {
95 $this->object->getId(),
96 $form,
97 [
99 ]
100 );
101 }
102
103 protected function saveSettings()
104 {
105 $form = $this->buildForm();
106
107 if (!$form->checkInput()) {
108 $form->setValuesByPost();
109 $this->editSettings($form);
110 return;
111 }
112
114 $this->object->getId(),
115 $form,
116 [
118 ]
119 );
120
121 ilUtil::sendSuccess($this->lng->txt('msg_obj_modified'), true);
122 $this->ctrl->redirect($this, self::CMD_EDIT);
123 }
124
125 protected function txt(string $code) : string
126 {
127 return $this->lng->txt($code);
128 }
129}
An exception for terminatinating execution or to throw for unit testing.
This class provides processing control methods.
Base class for ILIAS Exception handling.
language handling
static initServiceSettingsForm($a_obj_id, ilPropertyFormGUI $form, $services)
Init service settings form.
static updateServiceSettingsForm($a_obj_id, ilPropertyFormGUI $form, $services)
Update service settings.
This class represents a property form user interface.
__construct(ilCtrl $ctrl, ilGlobalTemplateInterface $tpl, ilLanguage $lng, ilObjectService $object_service)