ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
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...
 
 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 25 of file StaticRepository.php.

Constructor & Destructor Documentation

◆ __construct()

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

Definition at line 32 of file StaticRepository.php.

34 {
35 foreach ($activities as $activity) {
36 if (!($activity instanceof Activity)) {
37 throw new \InvalidArgumentException(
38 "Expected `Activity`, got: " . get_class($activity)
39 );
40 }
41 $this->activities[(string) $activity->getName()] = $activity;
42 }
43 }

References ILIAS\Component\Activities\StaticRepository\$activities.

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 45 of file StaticRepository.php.

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

Field Documentation

◆ $activities

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

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