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


PHP EntityManager::find方法代碼示例

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


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

示例1: verifyBrands

 private function verifyBrands()
 {
     for ($i = 1; $i <= 10; ++$i) {
         /* @var $brand \Hautelook\AliceBundle\Tests\SymfonyApp\TestBundle\Entity\Brand */
         $this->entityManager->find('Hautelook\\AliceBundle\\Tests\\SymfonyApp\\TestBundle\\Entity\\Brand', $i);
     }
 }
開發者ID:ronanguilloux,項目名稱:AliceBundle,代碼行數:7,代碼來源:DoctrineORMFixturesTest.php

示例2: storeLocation

 /**
  * @param $location_id
  * @param array $resources
  * @return \Symfony\Component\HttpFoundation\JsonResponse
  */
 public function storeLocation($location_id, array $resources)
 {
     $location = $this->em->find('riki34GameBundle:Location', $location_id);
     $this->jsonLoader->storeFile($location->getFile(), $resources);
     $message = "Location saved";
     return $this->response->generateSuccessResponse(array($message));
 }
開發者ID:riki343,項目名稱:game1,代碼行數:12,代碼來源:LocationLoader.php

示例3: getMainAdvs

 public function getMainAdvs()
 {
     $advs = ['trade' => [], 'find' => [], 'gift' => []];
     $qb = $this->em->createQueryBuilder();
     $trade = $qb->select('a')->from('NaidusvoeBundle:Advertisment', 'a')->where($qb->expr()->andX($qb->expr()->isNotNull('a.onMainUntill'), $qb->expr()->eq('a.typeID', Advertisment::TRADE)))->getQuery()->getResult();
     $type = $this->em->find('NaidusvoeBundle:AdvertismentType', Advertisment::TRADE);
     $advsCount = count($trade);
     $advs['trade'] = $this->getRandom($trade, AdvertisementService::MAIN_ADV_COUNT);
     if ($advsCount < 5) {
         $advs['trade'] = array_merge($advs['trade'], $this->generateDummyAdvs(AdvertisementService::MAIN_ADV_COUNT - $advsCount, $type));
     }
     $qb = $this->em->createQueryBuilder();
     $find = $qb->select('a')->from('NaidusvoeBundle:Advertisment', 'a')->where($qb->expr()->andX($qb->expr()->isNotNull('a.onMainUntill'), $qb->expr()->eq('a.typeID', Advertisment::FIND)))->getQuery()->getResult();
     $type = $this->em->find('NaidusvoeBundle:AdvertismentType', Advertisment::FIND);
     $advsCount = count($find);
     $advs['find'] = $this->getRandom($find, AdvertisementService::MAIN_ADV_COUNT);
     if ($advsCount < 5) {
         $advs['find'] = array_merge($advs['find'], $this->generateDummyAdvs(AdvertisementService::MAIN_ADV_COUNT - $advsCount, $type));
     }
     $qb = $this->em->createQueryBuilder();
     $gift = $qb->select('a')->from('NaidusvoeBundle:Advertisment', 'a')->where($qb->expr()->andX($qb->expr()->isNotNull('a.onMainUntill'), $qb->expr()->eq('a.typeID', Advertisment::GIFT)))->getQuery()->getResult();
     $type = $this->em->find('NaidusvoeBundle:AdvertismentType', Advertisment::GIFT);
     $advsCount = count($gift);
     $advs['gift'] = $this->getRandom($gift, AdvertisementService::MAIN_ADV_COUNT);
     if ($advsCount < 5) {
         $advs['gift'] = array_merge($advs['gift'], $this->generateDummyAdvs(AdvertisementService::MAIN_ADV_COUNT - $advsCount, $type));
     }
     return $advs;
 }
開發者ID:riki343,項目名稱:naidusvoe,代碼行數:29,代碼來源:AdvertisementService.php

示例4: postVoteAction

 public function postVoteAction(Request $request)
 {
     $data = $request->getContent();
     $voteData = json_decode($data, true);
     $vote = new Vote();
     if (isset($voteData['user_id']) && ($userId = $voteData['user_id'])) {
         $user = $this->em->find('\\HackdayProject\\Entity\\User', $userId);
         if (!$user) {
             throw new NotFound('User cannot be found');
         }
         $vote->setUser($user);
     }
     if (isset($voteData['entry_id']) && ($entryId = $voteData['entry_id'])) {
         $entry = $this->em->find('\\HackdayProject\\Entity\\Entry', $entryId);
         if (!$entry) {
             throw new NotFound('User cannot be found');
         }
         $vote->setEntry($entry);
     } else {
         throw new BadRequestHttpException();
     }
     $vote->setValue($voteData['value']);
     $this->em->persist($vote);
     $this->em->flush($vote);
     return new JsonResponse($vote->toArray(), 201);
 }
開發者ID:pdziok,項目名稱:hackday-project,代碼行數:26,代碼來源:VoteController.php

示例5: insertUpdateProcessing

 public function insertUpdateProcessing(EntityManager $em, $data, $id = null)
 {
     $update = !is_null($id);
     try {
         $em->beginTransaction();
         if ($update) {
             $language = $em->find('Model\\Language', $id);
         } else {
             $language = new Language();
         }
         $language->setCode($data['code']);
         $language->setDescription($data['description']);
         $language->setFlagImageURL($data['flagimageurl']);
         $menu = $em->find('Model\\Menu', $data['menuid']);
         $language->setMenu($menu);
         if ($update) {
             $em->merge($language);
         } else {
             $em->persist($language);
         }
         $em->flush();
         $em->commit();
     } catch (\Exception $e) {
         $em->rollback();
         throw $e;
     }
     return $language->getId();
 }
開發者ID:francescocambi,項目名稱:FCMS2,代碼行數:28,代碼來源:EditorController.php

示例6: testInsertStoresCorrectValue

 public function testInsertStoresCorrectValue()
 {
     $id = $this->driver->insert('Stuff', array('name' => 'stupid'));
     $entity_name = 'DerpTest\\Machinist\\Store\\TestEntity\\Doctrine\\Stuff';
     $stuff = $this->em->find($entity_name, $id);
     $this->assertEquals('stupid', $stuff->getName());
 }
開發者ID:derptest,項目名稱:phpmachinist,代碼行數:7,代碼來源:DoctrineTest.php

示例7: getIfExist

 /**
  * 
  * @param type $id
  * @return \Sticks\Model\Stick
  * @throws Exceptions\EntityNotFound
  */
 public function getIfExist($id)
 {
     if ($row = $this->_em->find(static::$_stickClass, $id)) {
         return $row;
     }
     throw new Exceptions\EntityNotFound($id);
 }
開發者ID:ram600,項目名稱:vasabi,代碼行數:13,代碼來源:Bean.php

示例8: getObject

 private function getObject($object)
 {
     /** @var ObjectViews $object */
     $entity = $this->objects[$object->getEntity()];
     $object = $this->em->find($entity, $object->getObjectId());
     return $object;
 }
開發者ID:necatikartal,項目名稱:ojs,代碼行數:7,代碼來源:UpdateCommand.php

示例9: onBuildAfter

 /**
  * Add required filters
  *
  * @param BuildAfter $event
  */
 public function onBuildAfter(BuildAfter $event)
 {
     $datagrid = $event->getDatagrid();
     /** @var OrmDatasource $ormDataSource */
     $ormDataSource = $datagrid->getDatasource();
     $queryBuilder = $ormDataSource->getQueryBuilder();
     $parameters = $datagrid->getParameters();
     if ($parameters->has('userId')) {
         $user = $this->entityManager->find('OroUserBundle:User', $parameters->get('userId'));
         $queryBuilder->andWhere('call.owner = :user')->setParameter('user', $user);
     }
     if ($parameters->has('contactId')) {
         $contact = $this->entityManager->find('OroCRMContactBundle:Contact', $parameters->get('contactId'));
         $queryBuilder->andWhere('call.relatedContact = :contact')->setParameter('contact', $contact);
     }
     if ($parameters->has('accountId')) {
         $account = $this->entityManager->find('OroCRMAccountBundle:Account', $parameters->get('accountId'));
         $queryBuilder->andWhere('(call.relatedAccount = :account OR :account MEMBER OF contact.accounts)')->setParameter('account', $account);
     }
     if ($parameters->has('callIds')) {
         $callIds = $parameters->get('callIds');
         if (!is_array($callIds)) {
             $callIds = explode(',', $callIds);
         }
         $queryBuilder->andWhere($queryBuilder->expr()->in('call.id', $callIds));
     }
 }
開發者ID:dairdr,項目名稱:crm,代碼行數:32,代碼來源:CallListener.php

示例10: addNotification

 public function addNotification($users, $notificationType, $notificationDetails)
 {
     /** @var User $user */
     foreach ($users as $user) {
         $initiator = null;
         $notification = new Notification($notificationType, $user);
         $notification->setUserId($user->getId());
         if ($notificationType === Notification::SIMPLE_NOTIFICATION) {
             $notification->setContent($notificationDetails['content']);
             $initiator = "Naidusvoe";
         }
         if ($notificationType === Notification::CONVERSATION_NOTIFICATION) {
             $notification->setConversationId($notificationDetails['conversationId']);
             $notification->setMessageId($notificationDetails['messageId']);
             $notification->setContent("Ви отримали особисте повідомлення");
             $userInitiatorId = $notificationDetails['userInitiatorId'];
             $initiator = $this->em->find('NaidusvoeBundle:User', $userInitiatorId)->getUsername();
             $notification->setInitiatorId($userInitiatorId);
         }
         $this->em->persist($notification);
         $this->em->flush();
         if ($user->getSettings()->getNotificationsEmail()) {
             /** @var \Swift_Message $message */
             $message = $this->mailer->createMessage()->setSubject('You have some new notification')->setFrom('send@example.com')->setTo($user->getEmail())->setBody($this->templating->render('@Naidusvoe/mail.html.twig', ['content' => $notification->getContent(), 'Initiator' => $initiator]), 'text/html');
             $this->mailer->send($message);
         }
     }
 }
開發者ID:riki343,項目名稱:naidusvoe,代碼行數:28,代碼來源:Notifier.php

示例11: find

 /**
  * @param string $id Site UUID.
  *
  * @return Site|null
  */
 public function find($id)
 {
     if (!\Undine\Functions\valid_uuid($id)) {
         return null;
     }
     return $this->em->find(Site::class, (string) $id);
 }
開發者ID:Briareos,項目名稱:Undine,代碼行數:12,代碼來源:SiteRepository.php

示例12: getImageAction

 public function getImageAction($id)
 {
     $image = $this->em->find('HackdayProject\\Entity\\Image', $id);
     if (!$image) {
         throw new NotFound('Image cannot be found');
     }
     return new JsonResponse($image->toArray());
 }
開發者ID:pdziok,項目名稱:hackday-project,代碼行數:8,代碼來源:ImageController.php

示例13: findById

 /**
  * @param int $id
  * @return User
  * @throws Exception
  */
 public function findById($id)
 {
     $user = $this->entityManager->find('Janus\\ServiceRegistry\\Entity\\User', $id);
     if (!$user instanceof User) {
         throw new Exception("User '{$id}' not found");
     }
     return $user;
 }
開發者ID:baszoetekouw,項目名稱:janus,代碼行數:13,代碼來源:UserService.php

示例14: find

 public function find($id)
 {
     $author = $this->entityManager->find('Doctrine\\Bundle\\LicenseManagerBundle\\Entity\\Author', $id);
     if (!$author) {
         throw new AuthorNotFoundException($id);
     }
     return $author;
 }
開發者ID:royalwang,項目名稱:license-manager-1,代碼行數:8,代碼來源:AuthorOrmRepository.php

示例15: loginAction

 public function loginAction()
 {
     $this->authSession->Login = null;
     $id = $this->getRequest()->getParam("Id");
     $login = $this->em->find("eCamp\\Entity\\Login", $id);
     $this->authSession->Login = $login;
     $this->view->LoginPMod = new eCamp\PMod\LoginPMod($login);
 }
開發者ID:jo-m,項目名稱:ecamp3,代碼行數:8,代碼來源:LoginController.php


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