Skip to content

Commit

Permalink
[TASK] Add types for pressMedia and scientificResearch to enable upda…
Browse files Browse the repository at this point in the history
…ting profile information in profile
  • Loading branch information
toniwv committed Feb 15, 2024
1 parent 5cb7e41 commit de37edf
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Classes/Controller/ProfileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,10 @@ public function addProfileInformationAction(Profile $profile, string $type): Res
$profileInformation->setType($type);

switch ($type) {
case 'scientific_research':
$profile->getScientificResearch()->attach($profileInformation);
$this->persistenceManager->update($profile);
break;
case 'curriculum_vitae':
$profile->getVita()->attach($profileInformation);
$this->persistenceManager->update($profile);
Expand All @@ -413,6 +417,10 @@ public function addProfileInformationAction(Profile $profile, string $type): Res
$profile->getLectures()->attach($profileInformation);
$this->persistenceManager->update($profile);
break;
case 'press_media':
$profile->getPressMedia()->attach($profileInformation);
$this->persistenceManager->update($profile);
break;
default:
$addProfileInformationEvent = new AddProfileInformationEvent($profile, $profileInformation);
$this->eventDispatcher->dispatch($addProfileInformationEvent);
Expand All @@ -434,6 +442,10 @@ public function removeProfileInformationAction(Profile $profile, ProfileInformat
}

switch ($profileInformation->getType()) {
case 'scientific_research':
$profile->getScientificResearch()->detach($profileInformation);
$this->persistenceManager->update($profile);
break;
case 'curriculum_vitae':
$profile->getVita()->detach($profileInformation);
$this->persistenceManager->update($profile);
Expand All @@ -454,6 +466,10 @@ public function removeProfileInformationAction(Profile $profile, ProfileInformat
$profile->getLectures()->detach($profileInformation);
$this->persistenceManager->update($profile);
break;
case 'press_media':
$profile->getPressMedia()->detach($profileInformation);
$this->persistenceManager->update($profile);
break;
default:
$removeProfileInformationEvent = new RemoveProfileInformationEvent($profile, $profileInformation);
$this->eventDispatcher->dispatch($removeProfileInformationEvent);
Expand Down
26 changes: 26 additions & 0 deletions Classes/Domain/Model/Profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,32 @@ public function setLectures(ObjectStorage $lectures): void
parent::setLectures($lectures);
}

/**
* @param ObjectStorage<ProfileInformation> $pressMedia
*/
public function setPressMedia(ObjectStorage $pressMedia): void
{
foreach ($pressMedia as $press) {
$press->setTitle($this->getHtmlSanitizer()->sanitize($press->getTitle()));
$press->setBodytext($this->getHtmlSanitizer()->sanitize($press->getBodytext()));
$press->setLink($this->getHtmlSanitizer()->sanitize($press->getLink()));
}
parent::setPressMedia($pressMedia);
}

/**
* @param ObjectStorage<ProfileInformation> $scientificResearch
*/
public function setScientificResearch(ObjectStorage $scientificResearch): void
{
foreach ($scientificResearch as $research) {
$research->setTitle($this->getHtmlSanitizer()->sanitize($research->getTitle()));
$research->setBodytext($this->getHtmlSanitizer()->sanitize($research->getBodytext()));
$research->setLink($this->getHtmlSanitizer()->sanitize($research->getLink()));
}
parent::setScientificResearch($scientificResearch);
}

public function getLanguageUid(): int
{
return $this->_languageUid;
Expand Down

0 comments on commit de37edf

Please sign in to comment.