This topic contains 2 replies, has 1 voice, and was last updated by zhex900 6 years, 10 months ago.
- Topic
Hi,
I want to duplicate the relationship between Calendar event attendees and Calendar event context/Activities. I have created an association between Calendar Events and Oro User.
For example, if I have added user (admin) to the an event (lunch @ noon). I want automatically, add a matching association between admin and lunch@noon. The reason is I want user admin see this event (lunch @ noon) in its activity display.
Of course, if an attendee is deleted from the event, I want the association be deleted too.
This is what I have done so far. Please tell me is there is a better way of doing it. Should I use EventListener instead? But how do I know the changes to the attendee list?
12345678910111213141516171819202122232425262728293031// Oro\Bundle\CalendarBundle\Manager\CalendarEvent\UpdateAttendeeManager/*** Actualize attendees state after the event was created/updated** @param CalendarEvent $calendarEvent* @param Organization $organization*/public function onEventUpdate(CalendarEvent $calendarEvent, Organization $organization){$this->attendeeRelationManager->bindAttendees($calendarEvent->getAttendees(), $organization);$calendarEvent->setRelatedAttendee($calendarEvent->findRelatedAttendee());$this->setDefaultAttendeeStatus($calendarEvent->getAttendees());$this->setAttendeesType($calendarEvent);$this->updateAttendeeDisplayNames($calendarEvent->getAttendees());/* @var Collection|Attendee[] */$attendees = $calendarEvent->getAttendees();foreach ($attendees as $attendee) {if ($attendee->getUser()!== null){$calendarEvent->addActivityTarget($attendee->getUser());}elseif($attendees->getContact()!==null){$calendarEvent->addActivityTarget($attendee->getContact());}}}
The forum ‘OroCRM – Programming Questions’ is closed to new topics and replies.