ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilCertificateMigrationGUI Class Reference

Class ilCertificateMigrationGUI. More...

+ Collaboration diagram for ilCertificateMigrationGUI:

Public Member Functions

 __construct (\ilCtrl $ctrl=null, \ilLanguage $lng=null, \ilAccessHandler $access=null, \ILIAS\DI\BackgroundTaskServices $backgroundTasks=null, \ilObjUser $user=null, \ilLearningHistoryService $learningHistoryService=null, \ilSetting $certificateSettings=null, \ilCertificateMigrationValidator $migrationValidator=null, \ilErrorHandling $errorHandler=null, \ilLog $logger=null)
 ilCertificateMigrationGUI constructor. More...
 
 executeCommand ()
 execute command More...
 
 getCommand (string $cmd)
 Retrieves the ilCtrl command. More...
 
 startMigrationAndReturnMessage ()
 

Protected Attributes

 $ctrl
 
 $lng
 
 $access
 
 $tpl
 
 $user
 
 $backgroundTasks
 
 $learningHistoryService
 

Private Attributes

 $logger
 
 $migrationValidator
 
 $errorHandler
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilCertificateMigrationGUI::__construct ( \ilCtrl  $ctrl = null,
\ilLanguage  $lng = null,
\ilAccessHandler  $access = null,
\ILIAS\DI\BackgroundTaskServices  $backgroundTasks = null,
\ilObjUser  $user = null,
\ilLearningHistoryService  $learningHistoryService = null,
\ilSetting  $certificateSettings = null,
\ilCertificateMigrationValidator  $migrationValidator = null,
\ilErrorHandling  $errorHandler = null,
\ilLog  $logger = null 
)

ilCertificateMigrationGUI constructor.

Parameters
\ilCtrl$ctrl
\ilLanguage$lng
ilAccessHandler | null$access
\ILIAS\DI\BackgroundTaskServices$backgroundTasks
\ilObjUser$user
\ilLearningHistoryService$learningHistoryService
ilSetting | null$certificateSettings
ilCertificateMigrationValidator | null$migrationValidator
ilErrorHandling | null$errorHandler
ilLog | null$logger

Definition at line 56 of file class.ilCertificateMigrationGUI.php.

References $access, $backgroundTasks, $ctrl, $DIC, $errorHandler, $learningHistoryService, $lng, $logger, $migrationValidator, $user, and user().

67  {
68  global $DIC;
69 
70  if (null === $ctrl) {
71  $ctrl = $DIC->ctrl();
72  }
73  if (null === $lng) {
74  $lng = $DIC->language();
75  }
76  if (null === $access) {
77  $access = $DIC->access();
78  }
79  if (null === $backgroundTasks) {
80  $backgroundTasks = $DIC->backgroundTasks();
81  }
82  if (null === $user) {
83  $user = $DIC->user();
84  }
85  if (null === $learningHistoryService) {
86  $learningHistoryService = $DIC->learningHistory();
87  }
88 
89  if (null === $certificateSettings) {
90  $certificateSettings = new \ilSetting('certificate');
91  }
92 
93  if (null === $migrationValidator) {
94  $migrationValidator = new \ilCertificateMigrationValidator($certificateSettings);
95  }
96  $this->migrationValidator = $migrationValidator;
97 
98  if (null === $errorHandler) {
99  $errorHandler = $DIC['ilErr'];
100  }
101  $this->errorHandler = $errorHandler;
102 
103  if (null === $logger) {
104  $logger = $DIC->logger()->cert();
105  }
106  $this->logger = $logger;
107 
108  $this->ctrl = $ctrl;
109  $lng->loadLanguageModule('cert');
110  $this->lng = $lng;
111  $this->access = $access;
112  $this->user = $user;
113  $this->backgroundTasks = $backgroundTasks;
114  $this->learningHistoryService = $learningHistoryService;
115  }
global $DIC
Definition: saml.php:7
user()
Definition: user.php:4
+ Here is the call graph for this function:

Member Function Documentation

◆ executeCommand()

ilCertificateMigrationGUI::executeCommand ( )

execute command

Returns
mixed

Definition at line 121 of file class.ilCertificateMigrationGUI.php.

References $ret, and getCommand().

122  {
123  $cmd = $this->ctrl->getCmd();
124  $next_class = $this->ctrl->getNextClass($this);
125 
126  $cmd = $this->getCommand($cmd);
127  switch ($next_class) {
128  default:
129  $ret = $this->$cmd();
130  break;
131  }
132 
133  return $ret;
134  }
$ret
Definition: parser.php:6
getCommand(string $cmd)
Retrieves the ilCtrl command.
+ Here is the call graph for this function:

◆ getCommand()

ilCertificateMigrationGUI::getCommand ( string  $cmd)

Retrieves the ilCtrl command.

Parameters
string$cmd
Returns
mixed

Definition at line 141 of file class.ilCertificateMigrationGUI.php.

Referenced by executeCommand().

141  : string
142  {
143  return $cmd;
144  }
+ Here is the caller graph for this function:

◆ startMigrationAndReturnMessage()

ilCertificateMigrationGUI::startMigrationAndReturnMessage ( )
Returns
string
Exceptions

Definition at line 150 of file class.ilCertificateMigrationGUI.php.

References $factory, and user().

150  : string
151  {
152  $isMigrationAvailable = $this->migrationValidator->isMigrationAvailable(
153  $this->user,
154  new \ilCertificateMigration($this->user->getId())
155  );
156  if (false === $isMigrationAvailable) {
157  $this->logger->error('Tried to execute user certificate migration, but the migration has already been executed');
158  return '';
159  }
160 
161  $factory = $this->backgroundTasks->taskFactory();
162  $taskManager = $this->backgroundTasks->taskManager();
163 
164  $bucket = new \ILIAS\BackgroundTasks\Implementation\Bucket\BasicBucket();
165  $bucket->setUserId($this->user->getId());
166 
167  $task = $factory->createTask(\ilCertificateMigrationJob::class, [(int) $this->user->getId()]);
168 
169  $interaction = \ilCertificateMigrationInteraction::class;
170  if (!$this->learningHistoryService->isActive()) {
171  $interaction = \ilCertificateMigrationReducedInteraction::class;
172  }
173  $certificates_interaction = $factory->createTask($interaction, [
174  $task,
175  (int) $this->user->getId()
176  ]);
177 
178  $bucket->setTask($certificates_interaction);
179  $bucket->setTitle('Certificate Migration');
180  $bucket->setDescription('Migrates certificates for active user');
181 
182  $taskManager->run($bucket);
183 
184  return $this->lng->txt('certificate_migration_confirm_started');
185  }
$factory
Definition: metadata.php:43
user()
Definition: user.php:4
Class ilCertificateMigration.
+ Here is the call graph for this function:

Field Documentation

◆ $access

ilCertificateMigrationGUI::$access
protected

Definition at line 23 of file class.ilCertificateMigrationGUI.php.

Referenced by __construct().

◆ $backgroundTasks

ilCertificateMigrationGUI::$backgroundTasks
protected

Definition at line 32 of file class.ilCertificateMigrationGUI.php.

Referenced by __construct().

◆ $ctrl

ilCertificateMigrationGUI::$ctrl
protected

Definition at line 17 of file class.ilCertificateMigrationGUI.php.

Referenced by __construct().

◆ $errorHandler

ilCertificateMigrationGUI::$errorHandler
private

Definition at line 41 of file class.ilCertificateMigrationGUI.php.

Referenced by __construct().

◆ $learningHistoryService

ilCertificateMigrationGUI::$learningHistoryService
protected

Definition at line 35 of file class.ilCertificateMigrationGUI.php.

Referenced by __construct().

◆ $lng

ilCertificateMigrationGUI::$lng
protected

Definition at line 20 of file class.ilCertificateMigrationGUI.php.

Referenced by __construct().

◆ $logger

ilCertificateMigrationGUI::$logger
private

Definition at line 14 of file class.ilCertificateMigrationGUI.php.

Referenced by __construct().

◆ $migrationValidator

ilCertificateMigrationGUI::$migrationValidator
private

Definition at line 38 of file class.ilCertificateMigrationGUI.php.

Referenced by __construct().

◆ $tpl

ilCertificateMigrationGUI::$tpl
protected

Definition at line 26 of file class.ilCertificateMigrationGUI.php.

◆ $user

ilCertificateMigrationGUI::$user
protected

Definition at line 29 of file class.ilCertificateMigrationGUI.php.

Referenced by __construct().


The documentation for this class was generated from the following file: