ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
class.ObjectSelectionManager.php
Go to the documentation of this file.
1 <?php
2 
19 declare(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(
39  InternalDataService $data,
40  InternalRepoService $repo,
41  InternalDomainService $domain,
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,
79  $user_id,
80  $obj_ids
81  );
82  }
83 }
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:23