Themen entfern- und hinzufügbar gemacht

This commit is contained in:
Matthias Grief
2024-12-09 12:37:47 +01:00
committed by Eric Blommel
parent ff92b4c875
commit 45010810f7

View File

@@ -167,6 +167,36 @@ class SubjectData
return true;
}
/**
* Fügt ein neues Thema zum Fach hinzu
* @param TopicData $topic Das neue Thema
* @return bool true, wenn erfolgreich, sonst false
*/
public function addTopic(TopicData $topic): bool
{
if(isset($this->topics[$topic->getId()])) {
return false;
}
$this->topics[] = $topic;
return true;
}
/**
* Entfernt ein Thema vom Fach
* @param TopicData $topic Das zu entfernende Thema
* @return bool true, wenn erfolgreich, sonst false
*/
public function removeTopic(TopicData $topic): bool
{
if(!isset($this->topics[$topic->getId()])) {
return false;
}
$this->topics = array_diff($this->topics, [$topic]);
return true;
}
public function getId(): string
{
return $this->id;