public function addMember(OrganizationInterface $organization, User $user, array $roles)
    {
        if ($organization->getOwner() === null) {
            $organization->setOwner($user);
        }

        $user->addOrganization($organization);
        $organization->addUser($user);

        $role = new Role();
        $role->setOrganization($organization);
        $role->setUser($user);
        $role->setRoles($roles);

        $this->dm->persist($user);
        $this->dm->persist($organization);
        $this->dm->persist($role);
        $this->dm->flush();
    }
public function addMember(OrganizationInterface $organization, User $user, array $roles)
    {
        if ($organization->getOwner() === null) {
            $organization->setOwner($user);
        }

        $user->addOrganization($organization);
        $organization->addUser($user);

        $role = new Role();
        $role->setOrganization($organization);
        $role->setUser($user);
        $role->setRoles($roles);

        $this->dm->persist($user);
        $this->dm->persist($organization);
        $this->dm->persist($role);
        $this->dm->flush();
    }
public function addMember ( OrganizationInterface $ organization , User $ user , array $ roles ) { if ( $ organization -> getOwner ( ) === null ) { $ organization -> setOwner ( $ user ) ; } $ user -> addOrganization ( $ organization ) ; $ organization -> addUser ( $ user ) ; $ role = new Role ( ) ; $ role -> setOrganization ( $ organization ) ; $ role -> setUser ( $ user ) ; $ role -> setRoles ( $ roles ) ; $ this -> dm -> persist ( $ user ) ; $ this -> dm -> persist ( $ organization ) ; $ this -> dm -> persist ( $ role ) ; $ this -> dm -> flush ( ) ; }
Add member to an organization with specifics roles

@param OrganizationInterface $organization
@param User         $user
@param array        $roles
Add member to an organization with specifics roles