private function getInvitations($object)
    {
        // This must be an event with a full company call.
        if (!$object instanceof Event
            || !$object->getFullCompany()) {
            return [];
        }

        // Index existing invites so that we don't duplicate any.
        $existing = [];
        foreach ($object->getInvitations() as $existing_invitation) {
            $existing[] = $existing_invitation->getInvitee();
        }

        // Create and persist invitations for all active members of groups.
        $invitations = [];
        foreach ($object->getGroups() as $group) {
            foreach ($this->membership_provider->loadActiveMembershipsByProduction($group) as $membership) {
                // We can only act on our users.
                if (!$membership->getMember() instanceof UserInterface) {
                    continue;
                }

                // If this membership is active, has not expired and is not
                // already invited create new invitation.
                if ($membership->isActive()
                    && !$membership->isExpired()
                    && !in_array($membership->getMember()->getUsername(), $existing)
                ) {
                    // Create new invitation to this event for this member.
                    $invite = new Invitation();
                    $invite->setEvent($object);
                    $invite->setInvitee($membership->getMember()->getUsername());
                    $invite->setOptional(false);
                    $invitations[] = $invite;
                }
            }
        }

        // Return the new invitations for this event.
        return $invitations;
    }
private function getInvitations($object)
    {
        // This must be an event with a full company call.
        if (!$object instanceof Event
            || !$object->getFullCompany()) {
            return [];
        }

        // Index existing invites so that we don't duplicate any.
        $existing = [];
        foreach ($object->getInvitations() as $existing_invitation) {
            $existing[] = $existing_invitation->getInvitee();
        }

        // Create and persist invitations for all active members of groups.
        $invitations = [];
        foreach ($object->getGroups() as $group) {
            foreach ($this->membership_provider->loadActiveMembershipsByProduction($group) as $membership) {
                // We can only act on our users.
                if (!$membership->getMember() instanceof UserInterface) {
                    continue;
                }

                // If this membership is active, has not expired and is not
                // already invited create new invitation.
                if ($membership->isActive()
                    && !$membership->isExpired()
                    && !in_array($membership->getMember()->getUsername(), $existing)
                ) {
                    // Create new invitation to this event for this member.
                    $invite = new Invitation();
                    $invite->setEvent($object);
                    $invite->setInvitee($membership->getMember()->getUsername());
                    $invite->setOptional(false);
                    $invitations[] = $invite;
                }
            }
        }

        // Return the new invitations for this event.
        return $invitations;
    }
private function getInvitations ( $ object ) { // This must be an event with a full company call. if ( ! $ object instanceof Event || ! $ object -> getFullCompany ( ) ) { return [ ] ; } // Index existing invites so that we don't duplicate any. $ existing = [ ] ; foreach ( $ object -> getInvitations ( ) as $ existing_invitation ) { $ existing [ ] = $ existing_invitation -> getInvitee ( ) ; } // Create and persist invitations for all active members of groups. $ invitations = [ ] ; foreach ( $ object -> getGroups ( ) as $ group ) { foreach ( $ this -> membership_provider -> loadActiveMembershipsByProduction ( $ group ) as $ membership ) { // We can only act on our users. if ( ! $ membership -> getMember ( ) instanceof UserInterface ) { continue ; } // If this membership is active, has not expired and is not // already invited create new invitation. if ( $ membership -> isActive ( ) && ! $ membership -> isExpired ( ) && ! in_array ( $ membership -> getMember ( ) -> getUsername ( ) , $ existing ) ) { // Create new invitation to this event for this member. $ invite = new Invitation ( ) ; $ invite -> setEvent ( $ object ) ; $ invite -> setInvitee ( $ membership -> getMember ( ) -> getUsername ( ) ) ; $ invite -> setOptional ( false ) ; $ invitations [ ] = $ invite ; } } } // Return the new invitations for this event. return $ invitations ; }
Helper function that generates new invitations as needed.

@param mixed $object The entity being acted on.

@return Invitation[] The new invitations needed for this event.
Helper function that generates new invitations as needed .