ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilDidacticTemplateUtils.php
Go to the documentation of this file.
1<?php
2
19declare(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 getActionsByTemplateId(int $a_tpl_id)
Get actions of one template.
Utilities for didactic templates.
static switchTemplate(int $a_ref_id, int $a_new_tpl_id)
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
Class ilObject Basic functions for all objects.
global $DIC
Definition: shib_login.php:26