ILIAS  trunk Revision v11.0_alpha-1866-gfa368f7776e
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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 (private CollectionRepository $collection_repository, private Subject $events, private CollectionIdentificationGenerator $id_generator=new UniqueIDCollectionIdentificationGenerator(), private ?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)
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

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

Definition at line 45 of file CollectionBuilder.php.

46  {
47  }

Member Function Documentation

◆ delete()

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

Definition at line 127 of file CollectionBuilder.php.

127  : bool
128  {
129  $this->collection_repository->delete($identification);
130  return true;
131  }

◆ get()

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

Definition at line 87 of file CollectionBuilder.php.

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

87  : ResourceCollection
88  {
89  $this->validate($identification);
90  $existing = $this->collection_repository->existing($identification);
91  if ($existing->hasSpecificOwner()
92  && $existing->getOwner() !== $owner
93  ) {
94  // The original plan was that collections could be explicitly assigned to a user as an option.
95  // Such collections can then only be read by that user. However, the concept was never described
96  // and the check has therefore now been deactivated.
97  // See, for example, https://mantis.ilias.de/view.php?id=42127#c112463
98  // throw new \InvalidArgumentException('Invalid owner of collection');
99 
100  }
101  return $existing;
102  }
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 65 of file CollectionBuilder.php.

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

65  : \Generator
66  {
67  foreach ($this->getResourceIdStrings($identification) as $string) {
68  yield new ResourceIdentification($string);
69  }
70  }
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 57 of file CollectionBuilder.php.

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

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

57  : \Generator
58  {
59  yield from $this->collection_repository->getResourceIdStrings($identification);
60  }
+ 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 49 of file CollectionBuilder.php.

49  : bool
50  {
51  return $this->collection_repository->has($identification);
52  }

◆ new()

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

Definition at line 79 of file CollectionBuilder.php.

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

79  : ResourceCollection
80  {
81  return $this->collection_repository->blank(
82  $this->id_generator->getUniqueResourceCollectionIdentification(),
84  );
85  }

◆ notififyResourceDeletion()

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

Definition at line 133 of file CollectionBuilder.php.

133  : void
134  {
135  $this->collection_repository->removeResourceFromAllCollections($identification);
136  }

◆ store()

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

Definition at line 104 of file CollectionBuilder.php.

References null.

104  : bool
105  {
106  $event_data_container = new DataContainer();
107  if ($this->lock_handler !== null) {
108  $result = $this->lock_handler->lockTables(
109  $this->collection_repository->getNamesForLocking(),
110  function () use ($collection, $event_data_container): void {
111  $this->collection_repository->update($collection, $event_data_container);
112  }
113  );
114  $result->runAndUnlock();
115  } else {
116  $this->collection_repository->update($collection, $event_data_container);
117  }
118 
119  // notify about the change. we must do this after the lock is released
120  foreach ($event_data_container->get() as $event_data) {
121  $this->events->notify(Event::COLLECTION_RESOURCE_ADDED, $event_data);
122  }
123 
124  return true;
125  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null

◆ validate()

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

Definition at line 72 of file CollectionBuilder.php.

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

72  : void
73  {
74  if (!$this->id_generator->validateScheme($identification->serialize())) {
75  throw new \InvalidArgumentException('Invalid identification scheme');
76  }
77  }
+ Here is the caller graph for this function:

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