/** * @param PersonDto $person * @param string $dateOfBirth * @throws UpdateNodeException * @throws \Exception * * @return string */ public function updateAction(PersonDto $person, $dateOfBirth = '') { $profile = $this->profileService->getCurrentPartyProfile(); $referenceNode = $person->getReferenceNode(); if ($profile->getIdentifier() !== $referenceNode->getIdentifier()) { throw new UpdateNodeException('You can only update your own node', 125172979); } foreach ($person->getObjectVars() as $propertyName => $propertyValue) { if ($propertyName !== NULL && $propertyName !== 'referenceNode' && $propertyName !== 'image') { $properties[$propertyName] = $propertyValue; } } if ($dateOfBirth !== '') { $timestamp = strtotime($dateOfBirth); $dateOfBirth = new \DateTime(); $dateOfBirth->setTimestamp($timestamp); $properties['dateOfBirth'] = $dateOfBirth; } if (isset($properties)) { $this->nodeWriteRepository->updateNode($referenceNode, $properties); } $locale = new Locale('nl'); $this->response->setHeader('Notification', $this->translator->translateById('profile.update.success', [], NULL, $locale, 'Main', 'BuJitsuDo.Authentication')); return ''; }
/** * @param NodeInterface $event * @param NodeInterface $person */ public function removeAttendeeFromEvent(NodeInterface $event, NodeInterface $person) { $personAndEventData = $this->getEventsAndPersonData($event, $person); $this->removeEventFromUser($person, $personAndEventData, 'attendeeIdentifiers', 'attendees', 'User is not set in attendees'); $this->removeEventFromUser($event, $personAndEventData, 'personEventsIdentifiers', 'personEvents', 'Event is not registered for user'); $this->nodeWriteRepository->updateNode($person, ['events' => $personAndEventData['personEvents']]); $this->nodeWriteRepository->updateNode($event, ['attendees' => $personAndEventData['attendees']]); $this->persistenceManager->persistAll(); $this->emitAttendeeRemoved($event, $person); }