ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ObjectSelectionManager.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
26
31{
32 protected int $pool_id;
33 protected \ILIAS\BookingManager\Objects\ObjectsManager $object_manager;
37
38 public function __construct(
42 int $pool_id
43 ) {
44 $this->data = $data;
45 $this->repo = $repo;
46 $this->domain = $domain;
47 $this->object_manager = $domain->objects($pool_id);
48 $this->pool_id = $pool_id;
49 }
50
51 public function getSelectedObjects(int $user_id = 0): array
52 {
53 if ($user_id === 0) {
54 $user_id = $this->domain->user()->getId();
55 }
56 $valid_obj_ids = $this->object_manager->getObjectIds();
57 return array_filter(
58 $this->repo->objectSelection()->getSelectedObjects($this->pool_id, $user_id),
59 static function ($id) use ($valid_obj_ids) {
60 return in_array($id, $valid_obj_ids, true);
61 }
62 );
63 }
64
65 public function setSelectedObjects(array $obj_ids, int $user_id = 0): void
66 {
67 if ($user_id === 0) {
68 $user_id = $this->domain->user()->getId();
69 }
70 $valid_obj_ids = $this->object_manager->getObjectIds();
71 $obj_ids = array_filter(
72 $obj_ids,
73 static function ($id) use ($valid_obj_ids) {
74 return in_array($id, $valid_obj_ids, true);
75 }
76 );
77 $this->repo->objectSelection()->setSelectedObjects(
78 $this->pool_id,
80 $obj_ids
81 );
82 }
83}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
__construct(InternalDataService $data, InternalRepoService $repo, InternalDomainService $domain, int $pool_id)
Author: Alexander Killing killing@leifos.de
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...