ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilObjectPropertiesAgregator.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 use ILIAS\Object\Properties\ObjectTypeSpecificProperties\Factory as ObjectTypeSpecificPropertiesFactory;
22 
29 {
30  public function __construct(
31  private ilObjectCorePropertiesRepository $core_properties_repository,
32  private ilObjectAdditionalPropertiesRepository $additional_properties_repository,
33  private ObjectTypeSpecificPropertiesFactory $object_type_specific_properties_factory
34  ) {
35  }
36 
37  public function getFor(int $object_id, string $type = null): ilObjectProperties
38  {
39  $core_properties = $this->core_properties_repository->getFor($object_id, $type);
40 
41  return new ilObjectProperties(
42  $core_properties,
43  $this->core_properties_repository,
44  $this->additional_properties_repository->getFor($object_id),
45  $this->additional_properties_repository,
46  new ilMD($object_id, 0, $core_properties->getType() ?? '')
47  );
48  }
49 
50  public function preload(array $object_ids): void
51  {
52  $this->core_properties_repository->preload($object_ids);
53  $objects_by_type = [];
54  foreach ($object_ids as $obj_id) {
55  $type = ilObject::_lookupType($obj_id);
56 
57  if (!array_key_exists($type, $objects_by_type)) {
58  $objects_by_type[$type] = [];
59  }
60  $objects_by_type[$type][] = $obj_id;
61  }
62 
63  foreach ($objects_by_type as $type => $obj_ids) {
64  $this->object_type_specific_properties_factory->getForObjectTypeString($type)?->preload($obj_ids);
65  }
66  }
67 }
__construct(private ilObjectCorePropertiesRepository $core_properties_repository, private ilObjectAdditionalPropertiesRepository $additional_properties_repository, private ObjectTypeSpecificPropertiesFactory $object_type_specific_properties_factory)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getFor(int $object_id, string $type=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupType(int $id, bool $reference=false)