ILIAS  trunk Revision v12.0_alpha-16-g3e876e53c80
TourManager.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
28
30{
31 protected ?bool $any_active = null;
32 private \ILIAS\Help\GuidedTour\Settings\SettingsManager $sm;
33
34 public function __construct(
35 protected InternalDataService $data,
36 protected InternalDomainService $domain
37 ) {
38 $this->sm = $domain->tourSettings();
39 }
40
41 public function createTour(
42 string $title,
43 string $description
44 ): int {
45 $tour_obj = new ilObjGuidedTour();
46 $tour_obj->setTitle($title);
47 $tour_obj->setDescription($description);
48 $tour_obj->create();
49 $this->sm->save($this->data->settings(
50 $tour_obj->getId(),
51 false,
52 "",
53 PermissionType::None
54 ));
55 return $tour_obj->getId();
56 }
57
61 public function getAll(): \Generator
62 {
63 foreach (\ilObject::_getObjectsByType("gdtr") as $tour) {
64 yield \ilObjectFactory::getInstanceByObjId($tour["obj_id"]);
65 }
66 }
67
68 public function anyActive(): bool
69 {
70 if (!is_null($this->any_active)) {
71 return $this->any_active;
72 }
73 foreach ($this->getAll() as $tour) {
74 $settings = $this->sm->getByObjId($tour->getId());
75 if ($settings?->isActive()) {
76 $this->any_active = true;
77 return true;
78 }
79 }
80 $this->any_active = false;
81 return false;
82 }
83
84 public function getByObjId(int $obj_id): ?ilObjGuidedTour
85 {
86 return \ilObjectFactory::getInstanceByObjId($obj_id);
87 }
88
89 public function deleteTour(
90 int $obj_id
91 ): void {
92 $tour_obj = new ilObjGuidedTour($obj_id);
93 $tour_obj->delete();
94 }
95
96}
__construct(protected InternalDataService $data, protected InternalDomainService $domain)
Definition: TourManager.php:34
createTour(string $title, string $description)
Definition: TourManager.php:41
ILIAS Help GuidedTour Settings SettingsManager $sm
Definition: TourManager.php:32
Class ilObjectFactory This class offers methods to get instances of the type-specific object classes ...
delete()
delete object or referenced object (in the case of a referenced object, object data is only deleted i...
setTitle(string $title)
static _getObjectsByType(string $obj_type="", ?int $owner=null)