当前位置: 首页>>代码示例>>PHP>>正文


PHP UserInterface::getId方法代码示例

本文整理汇总了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;
 }
开发者ID:KnpLabs,项目名称:KnpBundles,代码行数:11,代码来源:UserProvider.php

示例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;
 }
开发者ID:kvitozev,项目名称:api-key-bundle,代码行数:13,代码来源:UserProvider.php

示例3: equals

 public function equals(UserInterface $user)
 {
     if ($user instanceof MagentoUser) {
         return $user->getId() === $user->id;
     }
     return $user->getUsername() === $this->email;
 }
开发者ID:Giant-Peach-Design,项目名称:LiipMagentoBundle,代码行数:7,代码来源:MagentoUser.php

示例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;
 }
开发者ID:tuimedia,项目名称:forum,代码行数:10,代码来源:OnDemandUserProvider.php

示例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;
 }
开发者ID:oesteve,项目名称:grupeta,代码行数:41,代码来源:ClubVoter.php

示例6: isEqualTo

 /**
  * {@inheritDoc}
  */
 public function isEqualTo(UserInterface $user)
 {
     if ($user instanceof FacebookUser && $user->getId() === $this->getId()) {
         return true;
     }
     return false;
 }
开发者ID:otobank,项目名称:facebook-bundle,代码行数:10,代码来源:FacebookUser.php

示例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();
     }
 }
开发者ID:QuangDang212,项目名称:roadiz,代码行数:22,代码来源:UserProvider.php

示例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;
 }
开发者ID:wizzbitnl,项目名称:CCDNForumForumBundle,代码行数:16,代码来源:RegistryModel.php

示例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();
 }
开发者ID:Raphy,项目名称:AfterEpi,代码行数:15,代码来源:AuthenticationProvider.php

示例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;
 }
开发者ID:kyrozetera,项目名称:Silex-Blog,代码行数:16,代码来源:BlogUser.php

示例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;
 }
开发者ID:dasklney,项目名称:kreta,代码行数:23,代码来源:WorkflowVoter.php

示例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);
 }
开发者ID:redelivre,项目名称:login-cidadao,代码行数:27,代码来源:FOSUBUserProvider.php

示例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();
 }
开发者ID:leoza,项目名称:api-client-bundle,代码行数:11,代码来源:User.php

示例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());
 }
开发者ID:hkmshb,项目名称:OpitHrm,代码行数:10,代码来源:LeaveAccessVoter.php

示例15: isEqualTo

 public function isEqualTo(UserInterface $user)
 {
     return $this->id === $user->getId();
 }
开发者ID:Quiss,项目名称:Evrika,代码行数:4,代码来源:User.php


注:本文中的Symfony\Component\Security\Core\User\UserInterface::getId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。