本文整理汇总了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();
}
示例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();
}
示例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());
}
示例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');
}
示例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;
}
示例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();
}
示例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);
}
}
示例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;
}
示例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();
}
示例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();
}
示例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;
}
示例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());
}
示例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());
}
示例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;
}
示例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');
}