ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
StaticRepository.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
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.
A simple class to express a naive range of whole positive numbers.
Definition: Range.php:29
An Activity is an action on the domain layer action of a component.
Definition: Activity.php:39