ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
ILIAS\Export\ImportHandler\Parser\NodeInfo\Collection\Collections Class Reference

Class Collections. More...

+ Collaboration diagram for ILIAS\Export\ImportHandler\Parser\NodeInfo\Collection\Collections:

Public Member Functions

 __construct (private ResourceBuilder $resource_builder, private CollectionBuilder $collection_builder, private RepositoryPreloader $preloader, private Subject $events)
 Consumers constructor. More...
 
 id (?string $collection_identification=null, ?int $owner=null)
 
 exists (string $collection_identification)
 
 idOrNull (?string $collection_identification=null, ?int $owner=null)
 
 get (ResourceCollectionIdentification $identification, ?int $owner=null)
 
 store (ResourceCollection $collection)
 
 clone (ResourceCollectionIdentification $source_collection_id)
 
 remove (ResourceCollectionIdentification $collection_id, ResourceStakeholder $stakeholder, bool $delete_resources_as_well=false)
 
 rangeAsArray (ResourceCollection $collection, int $from, int $amout)
 
 rangeAsGenerator (ResourceCollection $collection, int $from, int $to)
 
 sort (ResourceCollection $collection)
 

Private Attributes

array $cache = []
 
array $rid_cache = []
 

Detailed Description

Class Collections.

Author
Fabian Schmid fabia.nosp@m.n@sr.nosp@m..solu.nosp@m.tion.nosp@m.s

Definition at line 37 of file Collections.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Export\ImportHandler\Parser\NodeInfo\Collection\Collections::__construct ( private ResourceBuilder  $resource_builder,
private CollectionBuilder  $collection_builder,
private RepositoryPreloader  $preloader,
private Subject  $events 
)

Consumers constructor.

Definition at line 45 of file Collections.php.

46  {
47  }

Member Function Documentation

◆ clone()

ILIAS\Export\ImportHandler\Parser\NodeInfo\Collection\Collections::clone ( ResourceCollectionIdentification  $source_collection_id)

Definition at line 126 of file Collections.php.

References ILIAS\Export\ImportHandler\Parser\NodeInfo\Collection\Collections\id(), and ILIAS\Export\ImportHandler\Parser\NodeInfo\Collection\Collections\store().

126  : ResourceCollectionIdentification
127  {
128  $target_collection_id = $this->id();
129  $target_collection = $this->get($target_collection_id);
130  $source_collection = $this->get($source_collection_id);
131 
132  foreach ($source_collection->getResourceIdentifications() as $identification) {
133  $resource = $this->resource_builder->get($identification);
134  $cloned_resource = $this->resource_builder->clone($resource);
135  $target_collection->add($cloned_resource->getIdentification());
136  }
137  $this->store($target_collection);
138 
139  return $target_collection_id;
140  }
id(?string $collection_identification=null, ?int $owner=null)
Definition: Collections.php:53
+ Here is the call graph for this function:

◆ exists()

ILIAS\Export\ImportHandler\Parser\NodeInfo\Collection\Collections::exists ( string  $collection_identification)

Definition at line 71 of file Collections.php.

Referenced by ILIAS\Export\ImportHandler\Parser\NodeInfo\Collection\Collections\idOrNull().

71  : bool
72  {
73  return $this->collection_builder->has(new ResourceCollectionIdentification($collection_identification));
74  }
+ Here is the caller graph for this function:

◆ get()

ILIAS\Export\ImportHandler\Parser\NodeInfo\Collection\Collections::get ( ResourceCollectionIdentification  $identification,
?int  $owner = null 
)

Definition at line 86 of file Collections.php.

References ILIAS\Export\ImportHandler\Parser\NodeInfo\Collection\ResourceCollection\getResourceIdentifications().

89  : ResourceCollection {
90  $rcid = $identification->serialize();
91 
92  $collection = $this->cache[$rcid] ?? $this->collection_builder->get(
93  $identification,
94  $owner
95  );
96 
97  $preload = [];
98 
99  $rids = isset($this->cache[$rcid])
100  ? $this->cache[$rcid]->getResourceIdentifications()
101  : $this->rid_cache[$rcid]
102  ?? iterator_to_array($this->collection_builder->getResourceIds($identification));
103 
104  $this->rid_cache[$rcid] = []; // reset cache for identification, rebuild it now
105  $collection->clear();
106 
107  foreach ($rids as $resource_identification) {
108  if ($this->resource_builder->has($resource_identification)) {
109  $collection->add($resource_identification);
110  $preload[] = $resource_identification;
111  }
112  $this->rid_cache[$rcid][] = $resource_identification;
113  }
114  $this->preloader->preload($preload);
115 
116  return $this->cache[$rcid] = $collection;
117  }
+ Here is the call graph for this function:

◆ id()

ILIAS\Export\ImportHandler\Parser\NodeInfo\Collection\Collections::id ( ?string  $collection_identification = null,
?int  $owner = null 
)
Parameters
string | null$collection_identificationan existing collection identification or null for a new
int | null$ownerif this colletion is owned by a users, you must prvide it's owner ID

Definition at line 53 of file Collections.php.

References null.

Referenced by ILIAS\Export\ImportHandler\Parser\NodeInfo\Collection\Collections\clone(), and ILIAS\Export\ImportHandler\Parser\NodeInfo\Collection\Collections\idOrNull().

56  : ResourceCollectionIdentification {
57  if ($collection_identification === null
58  || $collection_identification === ''
59  || !$this->collection_builder->has(new ResourceCollectionIdentification($collection_identification))
60  ) {
61  $collection = $this->collection_builder->new($owner);
62  $identification = $collection->getIdentification();
63  $this->cache[$identification->serialize()] = $collection;
64 
65  return $identification;
66  }
67 
68  return new ResourceCollectionIdentification($collection_identification);
69  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the caller graph for this function:

◆ idOrNull()

ILIAS\Export\ImportHandler\Parser\NodeInfo\Collection\Collections::idOrNull ( ?string  $collection_identification = null,
?int  $owner = null 
)

Definition at line 76 of file Collections.php.

References ILIAS\Export\ImportHandler\Parser\NodeInfo\Collection\Collections\exists(), ILIAS\Export\ImportHandler\Parser\NodeInfo\Collection\Collections\id(), and null.

79  : ?ResourceCollectionIdentification {
80  if ($this->exists($collection_identification)) {
81  return $this->id($collection_identification, $owner);
82  }
83  return null;
84  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
id(?string $collection_identification=null, ?int $owner=null)
Definition: Collections.php:53
+ Here is the call graph for this function:

◆ rangeAsArray()

ILIAS\Export\ImportHandler\Parser\NodeInfo\Collection\Collections::rangeAsArray ( ResourceCollection  $collection,
int  $from,
int  $amout 
)
Returns
ResourceIdentification[]

Definition at line 162 of file Collections.php.

References ILIAS\Export\ImportHandler\Parser\NodeInfo\Collection\ResourceCollection\getResourceIdentifications().

162  : array
163  {
164  $return = [];
165  foreach ($collection->getResourceIdentifications() as $position => $identification) {
166  if ($position >= $from && $position < $from + $amout) {
167  $return[] = $identification;
168  }
169  }
170  return $return;
171  }
+ Here is the call graph for this function:

◆ rangeAsGenerator()

ILIAS\Export\ImportHandler\Parser\NodeInfo\Collection\Collections::rangeAsGenerator ( ResourceCollection  $collection,
int  $from,
int  $to 
)
Returns
|ResourceIdentification[]

Definition at line 176 of file Collections.php.

References ILIAS\Export\ImportHandler\Parser\NodeInfo\Collection\ResourceCollection\getResourceIdentifications().

176  : \Generator
177  {
178  foreach ($collection->getResourceIdentifications() as $position => $identification) {
179  if ($position >= $from && $position <= $to) {
180  yield $identification;
181  }
182  }
183  }
+ Here is the call graph for this function:

◆ remove()

ILIAS\Export\ImportHandler\Parser\NodeInfo\Collection\Collections::remove ( ResourceCollectionIdentification  $collection_id,
ResourceStakeholder  $stakeholder,
bool  $delete_resources_as_well = false 
)

Definition at line 142 of file Collections.php.

146  : bool {
147  $collection = $this->get($collection_id);
148  if ($delete_resources_as_well) {
149  foreach ($collection->getResourceIdentifications() as $resource_identification) {
150  $resource = $this->resource_builder->get($resource_identification);
151  $this->resource_builder->remove($resource, $stakeholder);
152  }
153  }
154  unset($this->cache[$collection_id->serialize()]);
155 
156  return $this->collection_builder->delete($collection_id);
157  }

◆ sort()

ILIAS\Export\ImportHandler\Parser\NodeInfo\Collection\Collections::sort ( ResourceCollection  $collection)

Definition at line 185 of file Collections.php.

185  : Sorter
186  {
187  return new Sorter(
188  $this->resource_builder,
189  $this->collection_builder,
190  $collection
191  );
192  }

◆ store()

ILIAS\Export\ImportHandler\Parser\NodeInfo\Collection\Collections::store ( ResourceCollection  $collection)

Definition at line 119 of file Collections.php.

References ILIAS\Export\ImportHandler\Parser\NodeInfo\Collection\ResourceCollection\getIdentification().

Referenced by ILIAS\Export\ImportHandler\Parser\NodeInfo\Collection\Collections\clone().

119  : bool
120  {
121  $this->cache[$collection->getIdentification()->serialize()] = $collection;
122 
123  return $this->collection_builder->store($collection);
124  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $cache

array ILIAS\Export\ImportHandler\Parser\NodeInfo\Collection\Collections::$cache = []
private

Definition at line 39 of file Collections.php.

◆ $rid_cache

array ILIAS\Export\ImportHandler\Parser\NodeInfo\Collection\Collections::$rid_cache = []
private

Definition at line 40 of file Collections.php.


The documentation for this class was generated from the following file: