ILIAS  trunk Revision v11.0_alpha-2658-ge2404539063
StaticRepository.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
23 class StaticRepository implements Repository
24 {
25  protected array $activities = [];
26 
30  public function __construct(
31  array $activities
32  ) {
33  foreach ($activities as $activity) {
34  if (!($activity instanceof Activity)) {
35  throw new \InvalidArgumentException(
36  "Expected `Activity`, got: " . get_class($activity)
37  );
38  }
39  $this->activities[(string) $activity->getName()] = $activity;
40  }
41  }
42 
43  public function getActivitiesByName(string $name_matcher, ?ActivityType $type = null, ?Range $range = null): \Iterator
44  {
45  foreach ($this->activities as $name => $activity) {
46  if (preg_match($name_matcher, $name)) {
47  yield $name => $activity;
48  }
49  }
50  }
51 }
getActivitiesByName(string $name_matcher, ?ActivityType $type=null, ?Range $range=null)
Get all activities where the name matches the provided regexp.
An Activity is an action on the domain layer action of a component.
Definition: Activity.php:38
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
A simple class to express a naive range of whole positive numbers.
Definition: Range.php:28