ILIAS  trunk Revision v11.0_alpha-1731-gff9cd7e2bd3
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilDidacticTemplateUtils.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
26 {
27  public static function switchTemplate(int $a_ref_id, int $a_new_tpl_id): bool
28  {
29  global $DIC;
30 
31  $logger = $DIC->logger()->otpl();
33  $a_ref_id
34  );
35  $logger->debug('Current template id: ' . $current_tpl_id);
36  // Revert current template
37  if ($current_tpl_id) {
38  $logger->debug('Reverting template with id: ' . $current_tpl_id);
39  foreach (ilDidacticTemplateActionFactory::getActionsByTemplateId($current_tpl_id) as $action) {
40  $action->setRefId($a_ref_id);
41  $action->revert();
42  }
43  }
44 
45  $obj = ilObjectFactory::getInstanceByRefId($a_ref_id, false);
46  if ($obj instanceof ilObject) {
47  $obj->applyDidacticTemplate($a_new_tpl_id);
48  }
49 
50  return true;
51  }
52 }
static switchTemplate(int $a_ref_id, int $a_new_tpl_id)
Utilities for didactic templates.
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
global $DIC
Definition: shib_login.php:22
static getActionsByTemplateId(int $a_tpl_id)
Get actions of one template.