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