當前位置: 首頁>>代碼示例>>PHP>>正文


PHP User::getId方法代碼示例

本文整理匯總了PHP中AppBundle\Entity\User::getId方法的典型用法代碼示例。如果您正苦於以下問題:PHP User::getId方法的具體用法?PHP User::getId怎麽用?PHP User::getId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在AppBundle\Entity\User的用法示例。


在下文中一共展示了User::getId方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getNotifications

 /**
  * @param User $user
  * @return array
  */
 public function getNotifications(User $user)
 {
     $qb = $this->createQueryBuilder('n');
     $qb->select('n.id, a.articleId, a.heading as article_heading, a.createdAt, u.username, img.path, v.heading as video_heading, v.videoId, l.linkId, l.heading as link_heading');
     $qb->leftJoin('n.article', 'a')->leftJoin('n.user', 'u')->leftJoin('u.profileImg', 'img')->leftJoin('n.video', 'v')->leftJoin('n.link', 'l')->where('a.userId = ' . $user->getId())->orWhere('v.userId = ' . $user->getId())->orWhere('l.userId = ' . $user->getId())->andWhere('n.seen = 0');
     return $qb->getQuery()->getResult();
 }
開發者ID:ugra92,項目名稱:knowledgems,代碼行數:11,代碼來源:NotificationRepository.php

示例2: createToken

 /**
  * @param User $user
  * @return Token
  */
 public function createToken(User $user) : Token
 {
     $issued = Carbon::now();
     $expire = Carbon::now()->addSeconds((int) $this->config['expire']);
     $notBefore = Carbon::now()->addSeconds((int) $this->config['notbefore']);
     return $this->tokenBuilder->setIssuer($this->config['issuer'])->setAudience($this->config['audience'])->setId($this->config['appid'], true)->setIssuedAt($issued->getTimestamp())->setNotBefore($notBefore->getTimestamp())->setExpiration($expire->getTimestamp())->set('data', ["uid" => $user->getId(), "uidentifier" => $user->getUsername()])->sign($this->signer, $this->secret)->getToken();
 }
開發者ID:Algatux,項目名稱:symfony3.0,代碼行數:11,代碼來源:TokenGenerator.php

示例3: commit

 /**
  * @param User $user
  * @param PageAnimal $pageAnimal
  * @throws HistoryException
  * @throws ValidationException
  */
 public function commit(User $user, PageAnimal $pageAnimal)
 {
     /** @var PageAnimalBranch $pageAnimalBranch */
     $pageAnimalBranch = $this->pageAnimalBranchRepository->find($pageAnimal->getId());
     if ($pageAnimalBranch == null) {
         throw new HistoryException(HistoryException::BRANCHE_INCONNUE);
     }
     if ($user->getId() !== $pageAnimalBranch->getOwner()->getId()) {
         throw new HistoryException(HistoryException::DROIT_REFUSE);
     }
     /** @var PageAnimalCommit $clientHead */
     $clientHead = $this->pageAnimalCommitRepository->find($pageAnimal->getHead());
     if ($clientHead->getId() !== $pageAnimalBranch->getCommit()->getId()) {
         throw new HistoryException(HistoryException::NON_FAST_FORWARD);
     }
     if (empty($pageAnimal->getNom())) {
         throw new ValidationException(ValidationException::EMPTY_NOM);
     }
     if (empty($pageAnimal->getDateNaissance())) {
         throw new ValidationException(ValidationException::EMPTY_DATE_NAISSANCE);
     }
     $commit = new PageAnimalCommit($clientHead, $pageAnimal->getNom(), $pageAnimal->getDateNaissance(), $pageAnimal->getDescription(), $pageAnimal->getStatut(), $pageAnimal->getSexe(), $pageAnimal->getPhotos());
     $this->doctrine->persist($commit);
     $pageAnimalBranch->setCommit($commit);
     $this->doctrine->flush([$commit, $pageAnimalBranch]);
     $pageAnimal->setHead($commit->getId());
 }
開發者ID:apflieger,項目名稱:zigotoo,代碼行數:33,代碼來源:PageAnimalService.php

示例4: getRecentFrequent

 protected function getRecentFrequent(User $user, array $criteria = null, $limit = 10)
 {
     $sql = '
         SELECT text, MAX(createdAt) AS recency, COUNT(*) AS frequency
         FROM stress_log_factors
         JOIN stress_logs ON stress_log_id = stress_logs.id
         WHERE user_id = ?
     ';
     $params = array($user->getId());
     if (is_array($criteria)) {
         foreach ($criteria as $key => $val) {
             $op = '=';
             if (is_array($val)) {
                 reset($val);
                 $op = key($val);
                 $val = current($val);
             }
             $sql .= 'AND `' . $key . '` ' . $op . ' ? ';
             $params[] = $val;
         }
     }
     $sql .= 'GROUP BY text ';
     $sql .= 'ORDER BY recency DESC, frequency DESC ';
     $sql .= 'LIMIT ' . (int) $limit;
     $result = $this->conn->fetchAll($sql, $params);
     return array_column($result, 'text');
 }
開發者ID:jasongrimes,項目名稱:stressmonkey,代碼行數:27,代碼來源:TagManager.php

示例5: getQueryBuilderFindTodoBy

 public function getQueryBuilderFindTodoBy(User $user)
 {
     $sub = $this->_em->createQueryBuilder();
     $sub->select('identity(v.proposal)')->from('AppBundle:Vote', 'v')->where($sub->expr()->eq('v.user', $user->getId()));
     $qb = $this->_em->createQueryBuilder();
     $proposals = $qb->select('p')->from('AppBundle:Proposal', 'p')->where($qb->expr()->notIn('p', $sub->getDQL()));
     return $proposals;
 }
開發者ID:bpaulin,項目名稱:up2you,代碼行數:8,代碼來源:ProposalRepository.php

示例6: delete

 /**
  * @return int
  */
 public function delete(User $user, Post $post)
 {
     $conn = $this->_em->getConnection();
     $statement = $conn->prepare('DELETE FROM post_vote WHERE user_id = :user_id AND post_id = :post_id');
     $statement->bindValue('user_id', $user->getId());
     $statement->bindValue('post_id', $post->getId());
     return $statement->execute();
 }
開發者ID:matheusgontijo,項目名稱:MageBrazuca,代碼行數:11,代碼來源:PostVoteRepository.php

示例7: stopActiveLogEntriesByUser

 protected function stopActiveLogEntriesByUser(User $user)
 {
     $activeLogEntries = $this->logEntryRepository->getNonCompletedLogEntriesByUser($user->getId());
     foreach ($activeLogEntries as $activeEntry) {
         $activeEntry->setTo(new \DateTime());
         $this->logEntryRepository->save($activeEntry);
     }
 }
開發者ID:klinki,項目名稱:timer,代碼行數:8,代碼來源:LogEntryService.php

示例8: getUserLiveGames

 public function getUserLiveGames(User $user)
 {
     $query = $this->getEntityManager()->createQuery('SELECT g FROM AppBundle:Game g JOIN g.players p JOIN p.user u WHERE u.id =:userId AND g.gameState =:state');
     $query->setParameter('userId', $user->getId());
     $query->setParameter('state', Game::STATE_HAS_PLAYERS_BUT_NOT_READY);
     $result = $query->getResult();
     return $result;
 }
開發者ID:richardlawson,項目名稱:coinflip,代碼行數:8,代碼來源:GameRepository.php

示例9: setTaskAsDefault

 /**
  * Sets task as users default task
  *
  * @param Task $task
  * @param User $user
  */
 public function setTaskAsDefault(Task $task, User $user)
 {
     $this->em->beginTransaction();
     $defaultTask = $this->taskRepository->findUserDefaultTask($user->getId());
     $defaultTask->setDefault(false);
     $task->setDefault(true);
     $this->taskRepository->update($task);
     $this->em->flush();
     $this->em->commit();
 }
開發者ID:klinki,項目名稱:timer,代碼行數:16,代碼來源:TaskService.php

示例10: getConversation

 public function getConversation(User $mainUser, User $secendaryUser, $order = 'DESC')
 {
     $queryBuilder = $this->createQueryBuilder('m');
     $queryBuilder->where($queryBuilder->expr()->andX($queryBuilder->expr()->eq('m.sender', ':mainUser'), $queryBuilder->expr()->eq('m.receiver', ':secendaryUser')))->orWhere($queryBuilder->expr()->andX($queryBuilder->expr()->eq('m.sender', ':secendaryUser'), $queryBuilder->expr()->eq('m.receiver', ':mainUser')))->setParameter('mainUser', $mainUser->getId())->setParameter('secendaryUser', $secendaryUser->getId());
     if (!in_array(strtoupper($order), array('ASC', 'DESC'))) {
         $order = 'DESC';
     }
     $queryBuilder->orderBy('m.createdAt', $order);
     return $queryBuilder->getQuery()->getResult();
 }
開發者ID:karion,項目名稱:wf-api,代碼行數:10,代碼來源:MessageRepository.php

示例11: addCustomer

 /**
  * @param User $user
  * @param $request
  * @throws
  * @return User
  */
 public function addCustomer(User $user, $request)
 {
     $result = BraintreeCustomer::create(['id' => 'userid-' . $user->getId(), 'email' => $user->getEmail(), "creditCard" => ["number" => $request->request->get("number"), "cvv" => $request->request->get("cvv"), "expirationMonth" => $request->request->get("month"), "expirationYear" => $request->request->get("year")]]);
     if ($result->success === true) {
         $user->setBraintreeCustomerId($result->customer->id);
     } else {
         throw new Exception("Braintree create customer failed");
     }
     return $result->success;
 }
開發者ID:jducro,項目名稱:music-school,代碼行數:16,代碼來源:BraintreePaymentGateway.php

示例12: testEmptyUser

 /**
  * Test an empty User entity
  */
 public function testEmptyUser()
 {
     $user = new User();
     $this->assertEquals('New User', $user->__toString());
     $this->assertNull($user->getId());
     $this->assertNull($user->getFullName());
     $this->assertNull($user->getFacebookAccessToken());
     $this->assertNull($user->getFacebookId());
     $this->assertEquals(0, $user->getItems()->count());
 }
開發者ID:stfalcon-studio,項目名稱:lost-and-found,代碼行數:13,代碼來源:UserTest.php

示例13: testCreateNewEntity

 /**
  * Test creation of new entity
  */
 public function testCreateNewEntity()
 {
     $user = new User();
     $this->assertNull($user->getId());
     $this->assertFalse($user->isEnabled());
     $this->assertNull($user->getCreatedAt());
     $this->assertNull($user->getUpdatedAt());
     $this->assertNull($user->getFullName());
     $this->assertNull($user->getPhone());
 }
開發者ID:stfalcon-studio,項目名稱:rock-events,代碼行數:13,代碼來源:UserTest.php

示例14: addCustomer

 /**
  * @param User $user
  * @param $request
  * @throws Exception
  * @return User
  */
 public function addCustomer(User $user, $request)
 {
     $stripeToken = $request->request->get('token');
     //register stripe customer if necessary
     $customer = StripeCustomer::create(["description" => sprintf("UserId %s email %s", $user->getId(), $user->getEmail()), "source" => $stripeToken, "email" => $user->getEmail()]);
     if (!$customer->id) {
         throw new Exception("stripe create customer failed");
     }
     $user->setStripeCustomerId($customer->id);
     return true;
 }
開發者ID:jducro,項目名稱:music-school,代碼行數:17,代碼來源:StripePaymentGateway.php

示例15: deleteAction

 /**
  * Deletes a User entity.
  *
  * @Route("/{id}", name="user_delete")
  * @Method("DELETE")
  */
 public function deleteAction(Request $request, User $user)
 {
     $form = $this->createFormDelete($user->getId());
     $form->handleRequest($request);
     if ($form->isSubmitted() && $form->isValid()) {
         $em = $this->getDoctrine()->getManager();
         $em->remove($user);
         $em->flush();
     }
     return $this->redirectToRoute('user_show');
 }
開發者ID:Wolframcheg,項目名稱:symfotest,代碼行數:17,代碼來源:UserController.php


注:本文中的AppBundle\Entity\User::getId方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。