本文整理汇总了PHP中Symfony\Component\Security\Core\User\UserInterface::getId方法的典型用法代码示例。如果您正苦于以下问题:PHP UserInterface::getId方法的具体用法?PHP UserInterface::getId怎么用?PHP UserInterface::getId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Security\Core\User\UserInterface
的用法示例。
在下文中一共展示了UserInterface::getId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: refreshUser
/**
* {@inheritdoc}
*/
public function refreshUser(UserInterface $user)
{
$refreshedUser = $this->ownerManager->findDeveloperBy(array('id' => $user->getId()));
if (null === $refreshedUser) {
throw new UsernameNotFoundException(sprintf('User with ID "%d" could not be reloaded.', $user->getId()));
}
return $refreshedUser;
}
示例2: refreshUser
public function refreshUser(UserInterface $user)
{
/**
* @var \FOS\UserBundle\Entity\User $user
*/
if ($this->isStateless()) {
throw new UnsupportedUserException();
}
if (null === ($reloadedUser = $this->getUserManager()->findUserBy(array('id' => $user->getId())))) {
throw new UsernameNotFoundException(sprintf('User with ID "%d" could not be reloaded.', $user->getId()));
}
return $reloadedUser;
}
示例3: equals
public function equals(UserInterface $user)
{
if ($user instanceof MagentoUser) {
return $user->getId() === $user->id;
}
return $user->getUsername() === $this->email;
}
示例4: refreshUser
/**
* {@inheritDoc}
*/
public function refreshUser(UserInterface $user)
{
if (null === ($refreshedUser = $this->repository->findOneByUsername($user->getUsername()))) {
throw new UsernameNotFoundException(sprintf('User with id %s not found', json_encode($user->getId())));
}
return $refreshedUser;
}
示例5: isGranted
/**
*
* @param string $attribute
* @param Club $club
* @param UserInterface $user
* @return boolean
*/
protected function isGranted($attribute, $club, $user = null)
{
switch ($attribute) {
case self::VIEW:
if (!$club->isPrivate()) {
return true;
}
// make sure there is a user object (i.e. that the user is logged in)
if (!$user instanceof UserInterface) {
return false;
}
if (in_array('ROLE_ADMIN', $user->getRoles())) {
return true;
}
break;
case self::EDIT:
// make sure there is a user object (i.e. that the user is logged in)
if (!$user instanceof UserInterface) {
return false;
}
foreach ($club->getAdministrators() as $administrator) {
if ($administrator->getId() == $user->getId()) {
return true;
}
}
if (in_array('ROLE_ADMIN', $user->getRoles())) {
return true;
}
return false;
case self::CREATE:
break;
}
return false;
}
示例6: isEqualTo
/**
* {@inheritDoc}
*/
public function isEqualTo(UserInterface $user)
{
if ($user instanceof FacebookUser && $user->getId() === $this->getId()) {
return true;
}
return false;
}
示例7: refreshUser
/**
* Refreshes the user for the account interface.
*
* It is up to the implementation to decide if the user data should be
* totally reloaded (e.g. from the database), or if the RZ\Roadiz\Core\Entities\User
* object can just be merged into some internal array of users / identity
* map.
*
* @param RZ\Roadiz\Core\Entities\User $user
*
* @return RZ\Roadiz\Core\Entities\User
* @throws Symfony\Component\Security\Core\Exception\UnsupportedUserException if the account is not supported
*/
public function refreshUser(UserInterface $user)
{
$refreshUser = $this->em->find('RZ\\Roadiz\\Core\\Entities\\User', (int) $user->getId());
if ($refreshUser !== null) {
return $refreshUser;
} else {
throw new UnsupportedUserException();
}
}
示例8: findOrCreateOneRegistryForUser
/**
*
* @access public
* @param \Symfony\Component\Security\Core\User\UserInterface $user
* @return \CCDNForum\ForumBundle\Entity\Registry
*/
public function findOrCreateOneRegistryForUser(UserInterface $user)
{
$registry = $this->findOneRegistryForUserById($user->getId());
if (!$registry) {
$registry = $this->createRegistry();
$registry->setOwnedBy($user);
$this->saveRegistry($registry);
}
return $registry;
}
示例9: checkAuthentication
public function checkAuthentication(UserInterface $user, UsernamePasswordToken $token)
{
$connector = new Connector($user->getUsername(), $token->getCredentials());
if (!$connector->isSignedIn()) {
throw new BadCredentialsException();
}
$student = $connector->getStudent();
$user->fromStudent($student);
$user->setLastConnectionAt(new \DateTime());
if ($user->getId() == null || $user->getAccount() == null) {
$user->setAccount(new Account());
}
$this->em->persist($user);
$this->em->flush();
}
示例10: isEqualTo
public function isEqualTo(UserInterface $user)
{
if (!$user instanceof WebserviceUser) {
return false;
}
if ($this->id !== $user->getId()) {
return false;
}
if ($this->password !== $user->getPassword()) {
return false;
}
if ($this->username !== $user->getUsername()) {
return false;
}
return true;
}
示例11: checkAttribute
/**
* {@inheritdoc}
*/
protected function checkAttribute(UserInterface $user, $workflow, $attribute)
{
switch ($attribute) {
case self::EDIT:
case self::MANAGE_STATUS:
if ($workflow->getCreator()->getId() === $user->getId()) {
return VoterInterface::ACCESS_GRANTED;
}
break;
case self::VIEW:
if ($projects = $workflow->getProjects()) {
foreach ($projects as $project) {
if ($project->getUserRole($user) !== null) {
return VoterInterface::ACCESS_GRANTED;
}
}
}
}
return VoterInterface::ACCESS_DENIED;
}
示例12: connect
/**
* {@inheritDoc}
*/
public function connect(UserInterface $user, UserResponseInterface $response)
{
$username = $response->getUsername();
$service = $response->getResourceOwner()->getName();
$setter = 'set' . ucfirst($service);
$setter_id = $setter . 'Id';
$setter_token = $setter . 'AccessToken';
$setter_username = $setter . 'Username';
$existingUser = $this->userManager->findUserBy(array("{$service}Id" => $username));
if ($existingUser instanceof UserInterface && $existingUser->getId() != $user->getId()) {
throw new AlreadyLinkedAccount();
$previousUser->{$setter_id}(null);
$previousUser->{$setter_token}(null);
$this->userManager->updateUser($previousUser);
}
$screenName = $response->getNickname();
$user->{$setter_id}($username);
$user->{$setter_token}($response->getAccessToken());
$user->{$setter_username}($screenName);
if ($service === 'facebook') {
$this->setFacebookData($user, $response->getResponse());
}
$this->userManager->updateUser($user);
}
示例13: isEqualTo
public function isEqualTo(UserInterface $user)
{
if (!$this->isAuthenticated()) {
return false;
}
/* @var $user User */
if (!$user->isAuthenticated()) {
return false;
}
return $this->getId() == $user->getId();
}
示例14: getUserGroups
/**
* Method to find all groups of a user
*
* @param \Symfony\Component\Security\Core\User\UserInterface $user
* @return type
*/
protected function getUserGroups(UserInterface $user)
{
return $this->entityManager->getRepository('OpitOpitHrmUserBundle:Groups')->findUserGroupsArray($user->getId());
}
示例15: isEqualTo
public function isEqualTo(UserInterface $user)
{
return $this->id === $user->getId();
}