public function testGetProperties() { $user = new LdapUserProvider('ldapId', 'bob', 'Bob', '', Role::APP_USER, array()); $expected = array('username' => 'bob', 'name' => 'Bob', 'role' => Role::APP_USER, 'is_ldap_user' => 1); $this->assertEquals($expected, UserProperty::getProperties($user)); $user = new LdapUserProvider('ldapId', 'bob', '', '', '', array()); $expected = array('username' => 'bob', 'is_ldap_user' => 1); $this->assertEquals($expected, UserProperty::getProperties($user)); }
/** * Synchronize user profile * * @access public * @param UserProviderInterface $user * @return array */ public function synchronize(UserProviderInterface $user) { $profile = $this->user->getByExternalId($user->getExternalIdColumn(), $user->getExternalId()); $properties = UserProperty::getProperties($user); if (!empty($profile)) { $profile = $this->updateUser($profile, $properties); } elseif ($user->isUserCreationAllowed()) { $profile = $this->createUser($user, $properties); } return $profile; }
/** * Assign provider data to the local user * * @access public * @param integer $userId * @param UserProviderInterface $user * @return boolean */ public function assign($userId, UserProviderInterface $user) { $profile = $this->user->getById($userId); $values = UserProperty::filterProperties($profile, UserProperty::getProperties($user)); $values['id'] = $userId; if ($this->user->update($values)) { $profile = array_merge($profile, $values); $this->userSession->initialize($profile); return true; } return false; }