ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ObjectSelectionManager.php
Go to the documentation of this file.
1 <?php declare(strict_types=1);
2 
17 
21 
26 {
27  protected int $pool_id;
28  protected \ILIAS\BookingManager\Objects\ObjectsManager $object_manager;
32 
33  public function __construct(
34  InternalDataService $data,
35  InternalRepoService $repo,
36  InternalDomainService $domain,
37  int $pool_id
38  ) {
39  $this->data = $data;
40  $this->repo = $repo;
41  $this->domain = $domain;
42  $this->object_manager = $domain->objects($pool_id);
43  $this->pool_id = $pool_id;
44  }
45 
46  public function getSelectedObjects(int $user_id = 0) : array
47  {
48  if ($user_id === 0) {
49  $user_id = $this->domain->user()->getId();
50  }
51  $valid_obj_ids = $this->object_manager->getObjectIds();
52  return array_filter(
53  $this->repo->objectSelection()->getSelectedObjects($this->pool_id, $user_id),
54  static function ($id) use ($valid_obj_ids) {
55  return in_array($id, $valid_obj_ids, true);
56  }
57  );
58  }
59 
60  public function setSelectedObjects(array $obj_ids, int $user_id = 0) : void
61  {
62  if ($user_id === 0) {
63  $user_id = $this->domain->user()->getId();
64  }
65  $valid_obj_ids = $this->object_manager->getObjectIds();
66  $obj_ids = array_filter(
67  $obj_ids,
68  static function ($id) use ($valid_obj_ids) {
69  return in_array($id, $valid_obj_ids, true);
70  }
71  );
72  $this->repo->objectSelection()->setSelectedObjects(
73  $this->pool_id,
74  $user_id,
75  $obj_ids
76  );
77  }
78 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(InternalDataService $data, InternalRepoService $repo, InternalDomainService $domain, int $pool_id)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23