ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
ILIAS\Export\ImportHandler\Parser\NodeInfo\Collection\CollectionBuilder Class Reference

Class CollectionBuilder. More...

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

Public Member Functions

 __construct (Repository\CollectionRepository $collection_repository, private Subject $events, ?CollectionIdentificationGenerator $id_generator=null, ?\ILIAS\ResourceStorage\Lock\LockHandler $lock_handler=null)
 
 has (ResourceCollectionIdentification $identification)
 
 getResourceIdStrings (ResourceCollectionIdentification $identification)
 
 getResourceIds (ResourceCollectionIdentification $identification)
 
 new (?int $owner=null)
 
 get (ResourceCollectionIdentification $identification, ?int $owner=null)
 
 store (ResourceCollection $collection)
 
 delete (ResourceCollectionIdentification $identification)
 
 notififyResourceDeletion (ResourceIdentification $identification)
 

Private Member Functions

 validate (ResourceCollectionIdentification $identification)
 

Private Attributes

Repository CollectionRepository $collection_repository
 
CollectionIdentificationGenerator $id_generator = null
 
ILIAS ResourceStorage Lock LockHandler $lock_handler = null
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Export\ImportHandler\Parser\NodeInfo\Collection\CollectionBuilder::__construct ( Repository\CollectionRepository  $collection_repository,
private Subject  $events,
?CollectionIdentificationGenerator  $id_generator = null,
?\ILIAS\ResourceStorage\Lock\LockHandler  $lock_handler = null 
)

Definition at line 47 of file CollectionBuilder.php.

References ILIAS\Export\ImportHandler\Parser\NodeInfo\Collection\CollectionBuilder\$collection_repository, and ILIAS\Export\ImportHandler\Parser\NodeInfo\Collection\CollectionBuilder\$lock_handler.

52  {
53  $this->collection_repository = $collection_repository;
54  $this->lock_handler = $lock_handler;
55  $this->id_generator = $id_generator ?? new UniqueIDCollectionIdentificationGenerator();
56  }

Member Function Documentation

◆ delete()

ILIAS\Export\ImportHandler\Parser\NodeInfo\Collection\CollectionBuilder::delete ( ResourceCollectionIdentification  $identification)

Definition at line 136 of file CollectionBuilder.php.

136  : bool
137  {
138  $this->collection_repository->delete($identification);
139  return true;
140  }

◆ get()

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

Definition at line 96 of file CollectionBuilder.php.

References ILIAS\Export\ImportHandler\Parser\NodeInfo\Collection\CollectionBuilder\validate().

96  : ResourceCollection
97  {
98  $this->validate($identification);
99  $existing = $this->collection_repository->existing($identification);
100  if ($existing->hasSpecificOwner()
101  && $existing->getOwner() !== $owner
102  ) {
103  // The original plan was that collections could be explicitly assigned to a user as an option.
104  // Such collections can then only be read by that user. However, the concept was never described
105  // and the check has therefore now been deactivated.
106  // See, for example, https://mantis.ilias.de/view.php?id=42127#c112463
107  // throw new \InvalidArgumentException('Invalid owner of collection');
108 
109  }
110  return $existing;
111  }
validate(ResourceCollectionIdentification $identification)
+ Here is the call graph for this function:

◆ getResourceIds()

ILIAS\Export\ImportHandler\Parser\NodeInfo\Collection\CollectionBuilder::getResourceIds ( ResourceCollectionIdentification  $identification)
Returns
|ResourceIdentification[]

Definition at line 74 of file CollectionBuilder.php.

References ILIAS\Export\ImportHandler\Parser\NodeInfo\Collection\CollectionBuilder\getResourceIdStrings().

74  : \Generator
75  {
76  foreach ($this->getResourceIdStrings($identification) as $string) {
77  yield new ResourceIdentification($string);
78  }
79  }
getResourceIdStrings(ResourceCollectionIdentification $identification)
+ Here is the call graph for this function:

◆ getResourceIdStrings()

ILIAS\Export\ImportHandler\Parser\NodeInfo\Collection\CollectionBuilder::getResourceIdStrings ( ResourceCollectionIdentification  $identification)
Returns
|string[]

Definition at line 66 of file CollectionBuilder.php.

References ILIAS\ResourceStorage\Flavour\Machine\DefaultMachines\from().

Referenced by ILIAS\Export\ImportHandler\Parser\NodeInfo\Collection\CollectionBuilder\getResourceIds().

66  : \Generator
67  {
68  yield from $this->collection_repository->getResourceIdStrings($identification);
69  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ has()

ILIAS\Export\ImportHandler\Parser\NodeInfo\Collection\CollectionBuilder::has ( ResourceCollectionIdentification  $identification)

Definition at line 58 of file CollectionBuilder.php.

58  : bool
59  {
60  return $this->collection_repository->has($identification);
61  }

◆ new()

ILIAS\Export\ImportHandler\Parser\NodeInfo\Collection\CollectionBuilder::new ( ?int  $owner = null)

Definition at line 88 of file CollectionBuilder.php.

References ILIAS\Export\ImportHandler\Parser\NodeInfo\Collection\ResourceCollection\NO_SPECIFIC_OWNER.

88  : ResourceCollection
89  {
90  return $this->collection_repository->blank(
91  $this->id_generator->getUniqueResourceCollectionIdentification(),
93  );
94  }

◆ notififyResourceDeletion()

ILIAS\Export\ImportHandler\Parser\NodeInfo\Collection\CollectionBuilder::notififyResourceDeletion ( ResourceIdentification  $identification)

Definition at line 142 of file CollectionBuilder.php.

142  : void
143  {
144  $this->collection_repository->removeResourceFromAllCollections($identification);
145  }

◆ store()

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

Definition at line 113 of file CollectionBuilder.php.

113  : bool
114  {
115  $event_data_container = new DataContainer();
116  if ($this->lock_handler !== null) {
117  $result = $this->lock_handler->lockTables(
118  $this->collection_repository->getNamesForLocking(),
119  function () use ($collection, $event_data_container): void {
120  $this->collection_repository->update($collection, $event_data_container);
121  }
122  );
123  $result->runAndUnlock();
124  } else {
125  $this->collection_repository->update($collection, $event_data_container);
126  }
127 
128  // notify about the change. we must do this after the lock is released
129  foreach ($event_data_container->get() as $event_data) {
130  $this->events->notify(Event::COLLECTION_RESOURCE_ADDED, $event_data);
131  }
132 
133  return true;
134  }

◆ validate()

ILIAS\Export\ImportHandler\Parser\NodeInfo\Collection\CollectionBuilder::validate ( ResourceCollectionIdentification  $identification)
private

Definition at line 81 of file CollectionBuilder.php.

Referenced by ILIAS\Export\ImportHandler\Parser\NodeInfo\Collection\CollectionBuilder\get().

81  : void
82  {
83  if (!$this->id_generator->validateScheme($identification->serialize())) {
84  throw new \InvalidArgumentException('Invalid identification scheme');
85  }
86  }
+ Here is the caller graph for this function:

Field Documentation

◆ $collection_repository

Repository CollectionRepository ILIAS\Export\ImportHandler\Parser\NodeInfo\Collection\CollectionBuilder::$collection_repository
private

◆ $id_generator

CollectionIdentificationGenerator ILIAS\Export\ImportHandler\Parser\NodeInfo\Collection\CollectionBuilder::$id_generator = null
private

Definition at line 43 of file CollectionBuilder.php.

◆ $lock_handler

ILIAS ResourceStorage Lock LockHandler ILIAS\Export\ImportHandler\Parser\NodeInfo\Collection\CollectionBuilder::$lock_handler = null
private

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