plugin/blog/Manager/BlogManager.php
public function replaceMemberAuthor(User $from, User $to)
    {
        $fromIsMember = false;
        $froms = $this->memberRepo->findByUser($from);
        if (count($froms) > 0) {
            $fromIsMember = true;
        }

        $toIsMember = false;
        $tos = $this->memberRepo->findByUser($to);
        if (count($tos) > 0) {
            $toIsMember = true;
        }

        if ($toIsMember && $fromIsMember) {
            //user kept already have its member entry, delete the old one
            foreach ($froms as $member) {
                $this->objectManager->remove($member);
            }
            $this->objectManager->flush();
        } elseif (!$toIsMember && $fromIsMember) {
            //update entry for kept user
            foreach ($froms as $member) {
                $member->setUser($to);
            }
            $this->objectManager->flush();
        }
    }
public function replaceMemberAuthor(User $from, User $to)
    {
        $fromIsMember = false;
        $froms = $this->memberRepo->findByUser($from);
        if (count($froms) > 0) {
            $fromIsMember = true;
        }

        $toIsMember = false;
        $tos = $this->memberRepo->findByUser($to);
        if (count($tos) > 0) {
            $toIsMember = true;
        }

        if ($toIsMember && $fromIsMember) {
            //user kept already have its member entry, delete the old one
            foreach ($froms as $member) {
                $this->objectManager->remove($member);
            }
            $this->objectManager->flush();
        } elseif (!$toIsMember && $fromIsMember) {
            //update entry for kept user
            foreach ($froms as $member) {
                $member->setUser($to);
            }
            $this->objectManager->flush();
        }
    }
public function replaceMemberAuthor ( User $ from , User $ to ) { $ fromIsMember = false ; $ froms = $ this -> memberRepo -> findByUser ( $ from ) ; if ( count ( $ froms ) > 0 ) { $ fromIsMember = true ; } $ toIsMember = false ; $ tos = $ this -> memberRepo -> findByUser ( $ to ) ; if ( count ( $ tos ) > 0 ) { $ toIsMember = true ; } if ( $ toIsMember && $ fromIsMember ) { //user kept already have its member entry, delete the old one foreach ( $ froms as $ member ) { $ this -> objectManager -> remove ( $ member ) ; } $ this -> objectManager -> flush ( ) ; } elseif ( ! $ toIsMember && $ fromIsMember ) { //update entry for kept user foreach ( $ froms as $ member ) { $ member -> setUser ( $ to ) ; } $ this -> objectManager -> flush ( ) ; } }
Find all member for a given user and the replace him by another.

@param User $from
@param User $to
Find all member for a given user and the replace him by another .