ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
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 "de"
55 ));
56 return $tour_obj->getId();
57 }
58
62 public function getAll(): \Generator
63 {
64 foreach (\ilObject::_getObjectsByType("gdtr") as $tour) {
65 yield \ilObjectFactory::getInstanceByObjId($tour["obj_id"]);
66 }
67 }
68
69 public function anyActive(): bool
70 {
71 if (!is_null($this->any_active)) {
72 return $this->any_active;
73 }
74 foreach ($this->getAll() as $tour) {
75 $settings = $this->sm->getByObjId($tour->getId());
76 if ($settings?->isActive()) {
77 $this->any_active = true;
78 return true;
79 }
80 }
81 $this->any_active = false;
82 return false;
83 }
84
85 public function getByObjId(int $obj_id): ?ilObjGuidedTour
86 {
87 return \ilObjectFactory::getInstanceByObjId($obj_id);
88 }
89
90 public function deleteTour(
91 int $obj_id
92 ): void {
93 $tour_obj = new ilObjGuidedTour($obj_id);
94 $tour_obj->delete();
95 }
96
97}
__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)