main/core/Manager/ContactManager.php
public function createContacts(User $currentUser, array $users)
    {
        $this->om->startFlushSuite();
        $createdContacts = [];

        foreach ($users as $user) {
            $contact = $this->contactRepo->findOneBy(['user' => $currentUser, 'contact' => $user]);

            if (is_null($contact)) {
                $contact = new Contact();
                $contact->setUser($currentUser);
                $contact->setContact($user);
                $this->om->persist($contact);
                $createdContacts[] = $contact;
            }
        }
        $this->om->endFlushSuite();

        return $createdContacts;
    }
public function createContacts(User $currentUser, array $users)
    {
        $this->om->startFlushSuite();
        $createdContacts = [];

        foreach ($users as $user) {
            $contact = $this->contactRepo->findOneBy(['user' => $currentUser, 'contact' => $user]);

            if (is_null($contact)) {
                $contact = new Contact();
                $contact->setUser($currentUser);
                $contact->setContact($user);
                $this->om->persist($contact);
                $createdContacts[] = $contact;
            }
        }
        $this->om->endFlushSuite();

        return $createdContacts;
    }
public function createContacts ( User $ currentUser , array $ users ) { $ this -> om -> startFlushSuite ( ) ; $ createdContacts = [ ] ; foreach ( $ users as $ user ) { $ contact = $ this -> contactRepo -> findOneBy ( [ 'user' => $ currentUser , 'contact' => $ user ] ) ; if ( is_null ( $ contact ) ) { $ contact = new Contact ( ) ; $ contact -> setUser ( $ currentUser ) ; $ contact -> setContact ( $ user ) ; $ this -> om -> persist ( $ contact ) ; $ createdContacts [ ] = $ contact ; } } $ this -> om -> endFlushSuite ( ) ; return $ createdContacts ; }
Creates contacts from a list of user.

@param User   $currentUser
@param User[] $users

@return Contact[]
Creates contacts from a list of user .