本文整理汇总了PHP中FOS\UserBundle\Model\UserInterface::getId方法的典型用法代码示例。如果您正苦于以下问题:PHP UserInterface::getId方法的具体用法?PHP UserInterface::getId怎么用?PHP UserInterface::getId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FOS\UserBundle\Model\UserInterface
的用法示例。
在下文中一共展示了UserInterface::getId方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getPrincipalArray
/**
* get Array with Principal-Data from User-Object.
*
* @param UserInterface|GroupInterface $principalObject
* @param bool $show_id
*
* @return array
*
* @throws Exception
*/
private function getPrincipalArray($principalObject, $show_id = false)
{
if (!$principalObject instanceof UserInterface && !$principalObject instanceof GroupInterface) {
throw new Exception('$principalObject must be of type UserInterface of GroupInterface');
}
$principal = array();
if ($show_id) {
$principal['id'] = $principalObject->getId();
}
if ($principalObject instanceof UserInterface) {
$principal['uri'] = 'principals/' . $principalObject->getUsername();
} else {
$principal['uri'] = 'principals/' . $principalObject->getName();
}
// get all fields from $this->fieldMap, additional to 'uri' and 'id'
foreach ($this->fieldMap as $key => $value) {
if (!method_exists($principalObject, $value['getter'])) {
continue;
}
$valueGetter = call_user_func(array($principalObject, $value['getter']));
if ($valueGetter) {
$principal[$key] = $valueGetter;
}
}
return $principal;
}
示例2: withEntity
/**
* @param UserInterface $user
* @return UserDTO
*/
public static function withEntity(UserInterface $user)
{
$dto = new UserDTO();
$dto->setId($user->getId());
$dto->setEmail($user->getEmail());
$dto->setApiKey($user->getApiKey());
return $dto;
}
示例3: createRecoveryToken
/**
* @param UserInterface $user
* @return bool|HttpToken
*/
public function createRecoveryToken(UserInterface $user)
{
$currentDateTime = new \DateTime('now');
$expiresAt = clone $currentDateTime;
$expiresAt->add(new \DateInterval('PT' . self::LIFE_TIME_RECOVERY . 'S'));
$refreshTo = clone $currentDateTime;
$refreshTo->add(new \DateInterval('PT' . self::LIFE_TIME_RECOVERY . 'S'));
$token = new HttpToken();
$token->setUserId($user->getId())->setRefreshTo($refreshTo)->setExpiresAt($expiresAt)->setRecovery(true);
$this->entityManager->persist($token);
try {
$this->entityManager->flush();
} catch (ConstraintViolationException $e) {
error_log($e->getMessage());
return false;
}
return $token;
}
示例4: getQueryPagination
public function getQueryPagination(UserInterface $entity, $sort, $direction)
{
$queryBuilder = $this->createQueryBuilder('u');
$data = ['id' => $entity->getId(), 'username' => $entity->getUsername(), 'email' => $entity->getEmail(), 'enabled' => $entity->isEnabled()];
if (!empty($data['id'])) {
$queryBuilder->andWhere($queryBuilder->expr()->eq('u.id', ':id'))->setParameter('id', $data['id']);
}
if (!empty($data['username'])) {
$queryBuilder->andWhere($queryBuilder->expr()->like('u.username', ':username'))->setParameter('username', "%{$data['username']}%");
}
if (!empty($data['email'])) {
$queryBuilder->andWhere($queryBuilder->expr()->like('u.email', ':email'))->setParameter('email', "%{$data['email']}%");
}
if (!empty($data['enabled'])) {
$queryBuilder->andWhere($queryBuilder->expr()->eq('u.enabled', ':enabled'))->setParameter('enabled', $data['enabled']);
}
$queryBuilder->orderBy('u.' . $sort, $direction);
return $queryBuilder->getQuery();
}
示例5: isUser
/**
* Tells if the the given user is this user.
*
* Useful when not hydrating all fields.
*
* @param UserInterface $user
* @return Boolean
*/
public function isUser(UserInterface $user = null)
{
return null !== $user && $this->getId() === $user->getId();
}
示例6: reloadUser
/**
* {@inheritdoc}
*/
public function reloadUser(UserInterface $user)
{
return $this->findUserBy(['id' => $user->getId()]);
}
示例7: isMarked
public function isMarked(UserInterface $user, Package $package)
{
return null !== $this->redis->zrank('usr:' . $user->getId() . ':fav', $package->getId());
}
示例8: isOwner
/**
* @param UserInterface $user
* @param BlameableEntityInterface $object
*
* @return bool
*/
protected function isOwner(UserInterface $user, BlameableEntityInterface $object)
{
$creator = $object->getCreatedBy();
return $creator instanceof UserInterface && $user->getId() === $creator->getId();
}
示例9: isUser
/**
* Tells if the the given user is this user.
*
* Useful when not hydrating all fields.
*
* @param UserInterface $user
* @return Boolean
*/
public function isUser(FOSUserInterface $user = null)
{
return $user instanceof self && $user->getId() == $this->getId();
}
示例10: reloadUser
function reloadUser(UserInterface $user)
{
$document = $this->documentHandler->get($this->collection, $user->getId());
$this->fromDocument($user, $document);
}
示例11: addUserToPerimeter
/**
* Add a user to a perimeter
*
* @param UserInterface $user
* @param BusinessPerimeterInterface $perimeter
*/
public function addUserToPerimeter(UserInterface $user, BusinessPerimeterInterface $perimeter)
{
$this->perimeterManager->addUserToPerimeter($user->getId(), $perimeter->getId());
}
示例12: getRedirectionUrl
protected function getRedirectionUrl(UserInterface $user)
{
return $this->container->get('router')->generate('user_profile', array('id' => $user->getId()));
}
示例13: getRedirectionUrl
/**
* Generate the redirection url when the resetting is completed.
*
* @param \FOS\UserBundle\Model\UserInterface $user
*
* @return string
*/
protected function getRedirectionUrl(UserInterface $user)
{
return $this->container->get('router')->generate('fos_user_profile_show', array("id" => $user->getId()));
}