ILIAS  trunk Revision v11.0_alpha-2658-ge2404539063
ILIAS\Component\Activities\StaticRepository Class Reference
+ Inheritance diagram for ILIAS\Component\Activities\StaticRepository:
+ Collaboration diagram for ILIAS\Component\Activities\StaticRepository:

Public Member Functions

 __construct (array $activities)
 
 getActivitiesByName (string $name_matcher, ?ActivityType $type=null, ?Range $range=null)
 Get all activities where the name matches the provided regexp. More...
 

Protected Attributes

array $activities = []
 

Detailed Description

Definition at line 23 of file StaticRepository.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Component\Activities\StaticRepository::__construct ( array  $activities)
Parameters
array<Activity>$ativities

Definition at line 30 of file StaticRepository.php.

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  }

Member Function Documentation

◆ getActivitiesByName()

ILIAS\Component\Activities\StaticRepository::getActivitiesByName ( string  $name_matcher,
?ActivityType  $type = null,
?Range  $range = null 
)

Get all activities where the name matches the provided regexp.

Parameters
string$name_matcheras preg_match can understand
Returns
Iterator<string, Activity> where keys are the name

Implements ILIAS\Component\Activities\Repository.

Definition at line 43 of file StaticRepository.php.

43  : \Iterator
44  {
45  foreach ($this->activities as $name => $activity) {
46  if (preg_match($name_matcher, $name)) {
47  yield $name => $activity;
48  }
49  }
50  }

Field Documentation

◆ $activities

array ILIAS\Component\Activities\StaticRepository::$activities = []
protected

Definition at line 25 of file StaticRepository.php.


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