当前位置: 首页>>代码示例>>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;未经允许,请勿转载。