当前位置: 首页>>代码示例>>PHP>>正文


PHP EntityRepository::findBy方法代码示例

本文整理汇总了PHP中Doctrine\ORM\EntityRepository::findBy方法的典型用法代码示例。如果您正苦于以下问题:PHP EntityRepository::findBy方法的具体用法?PHP EntityRepository::findBy怎么用?PHP EntityRepository::findBy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Doctrine\ORM\EntityRepository的用法示例。


在下文中一共展示了EntityRepository::findBy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getSimilarArticlesByCategory

 /**
  * Return a similar articles by category
  * @param Article $article
  * @return Article array
  */
 public function getSimilarArticlesByCategory(Article $article)
 {
     $category = $article->getCategory();
     $similarArticles = $this->articleRepository->findBy(array('category' => $category), array('date' => 'ASC'), 3);
     unset($similarArticles[array_search($article, $similarArticles)]);
     return $similarArticles;
 }
开发者ID:baptistelinel,项目名称:Administrable-Blog,代码行数:12,代码来源:ArticleService.php

示例2: uniqueAppKey

 private function uniqueAppKey()
 {
     do {
         $appKey = str_shuffle("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ");
         $application = $this->userRepository->findBy(array('appKey' => $appKey));
     } while ($application);
     return $appKey;
 }
开发者ID:tarnawski,项目名称:JSONMock-backend,代码行数:8,代码来源:ApplicationFactory.php

示例3: buildMainMenu

 public function buildMainMenu(Request $request, ItemInterface $root)
 {
     $root->addChild('Messages', ['route' => 'pjax_message_index'])->getParent()->addChild('New message', ['route' => 'pjax_message_new'])->getParent();
     $latests = $root->addChild('latests', ['dropdown' => true]);
     /** @var Message $message */
     foreach ($this->messageRepository->findBy([], array(), 4) as $message) {
         $latests->addChild($message->getId(), ['route' => 'pjax_message_show', 'routeParameters' => ['id' => $message->getId()], 'label' => 'message ' . $message->getId()]);
     }
     return $root;
 }
开发者ID:hyperunknown,项目名称:PjaxDemo,代码行数:10,代码来源:MenuBuilder.php

示例4: findBy

 /**
  * Find objects by criteria
  *
  * @param array $criteria
  * @param array $options
  *
  * @return array
  */
 public function findBy($criteria = array(), $options = array())
 {
     $limit = $options["limit"] ? $options["limit"] : null;
     $offset = $options["offset"] ? $options["offset"] : null;
     $orderBy = array();
     if ($options["sort"]) {
         $orderBy = array($options["sort"], $options["order"]);
     }
     return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
 }
开发者ID:Vandeth,项目名称:Erp,代码行数:18,代码来源:AbstractManager.php

示例5: post

 /**
  * @return ResourceViewModel
  *
  * @throws ForbiddenException
  * @throws NotFoundException
  */
 public function post()
 {
     if (!$this->isGranted(UserMessagePermissions::START_CONVERSATION)) {
         throw new ForbiddenException('User must be logged on to start a conversation');
     }
     $values = $this->validateIncomingData(ConversationInputFilter::class);
     /* @var MessageUserInterface[] $user */
     $users = $this->userRepository->findBy(['id' => $values['participants']]);
     $conversation = new GroupConversationEntity($users);
     $this->conversationService->create($conversation);
     return new ResourceViewModel(['conversation' => $conversation], ['template' => 'conversations/conversation']);
 }
开发者ID:interactive-solutions,项目名称:zf-user-message,代码行数:18,代码来源:ConversationCollectionController.php

示例6: accountDeleteAction

 public function accountDeleteAction()
 {
     /**@var $campaign VkCampaigns*/
     /**@var $vkAd VkAds*/
     /**@var $vkAccount VkAccounts*/
     /**@var $cabinet Cabinets*/
     $vkAccountId = (int) $this->params()->fromRoute('vk_account_id', 0);
     if (!$vkAccountId) {
         return false;
     }
     $vkAccount = $this->vkAccountsRepository->findBy(['id' => $vkAccountId]);
     $vkAccount = reset($vkAccount);
     $this->getObjectManager()->remove($vkAccount);
     $allCabinets = $this->cabinetsRepository->findBy(['vk_account_id' => $vkAccountId]);
     $allClients = $this->getObjectManager()->getRepository('\\Socnet\\Entity\\VkClients')->findBy(['bidder_account_id' => $vkAccountId]);
     $campaigns = $this->campaignsRepository->findBy(['vk_account_id' => $vkAccountId]);
     foreach ($campaigns as $campaign) {
         $vkAds = $this->vkAdsRepository->findBy(['campaign_id' => $campaign->getId()]);
         foreach ($vkAds as $vkAd) {
             $this->getObjectManager()->remove($vkAd);
         }
         $this->getObjectManager()->remove($campaign);
     }
     foreach ($allClients as $allClient) {
         $this->getObjectManager()->remove($allClient);
     }
     foreach ($allCabinets as $allCabinet) {
         $this->getObjectManager()->remove($allCabinet);
     }
     $this->getObjectManager()->flush();
     return $this->redirect()->toRoute('home');
 }
开发者ID:OnlineBidder,项目名称:onlineBidder,代码行数:32,代码来源:VkController.php

示例7: findByUids

 public function findByUids($uids)
 {
     if (!is_array($uids)) {
         $uids = [$uids];
     }
     return parent::findBy(['uid' => $uids]);
 }
开发者ID:Silwereth,项目名称:core,代码行数:7,代码来源:UserRepository.php

示例8: onKernelRequest

 /**
  * Filter the `kernel.request` event to catch redirect addresses
  *
  * @param GetResponseEvent $event
  *
  * @return void
  */
 public function onKernelRequest(GetResponseEvent $event)
 {
     if (!$event->isMasterRequest()) {
         // don't do anything if it's not the master request
         return;
     }
     $request = $event->getRequest();
     $redirects = $this->redirectRepository->findBy(array('enabled' => true), array('position' => 'ASC'));
     /** @var Redirect $redirect */
     foreach ($redirects as $redirect) {
         if ($destinationUrl = $this->redirectMatchesRequest($redirect, $request)) {
             $event->setResponse(new RedirectResponse($destinationUrl, $redirect->getType()));
             return;
         }
     }
     return;
 }
开发者ID:symbio,项目名称:orangegate4-page-bundle,代码行数:24,代码来源:RedirectListener.php

示例9: findBy

 public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
 {
     if ($this->criteriaRequiresDql($criteria) === FALSE && $this->criteriaRequiresDql((array) $orderBy) === FALSE) {
         return parent::findBy($criteria, $orderBy, $limit, $offset);
     }
     $qb = $this->createQueryBuilder('e')->whereCriteria($criteria)->autoJoinOrderBy((array) $orderBy);
     return $qb->getQuery()->setMaxResults($limit)->setFirstResult($offset)->getResult();
 }
开发者ID:Richmond77,项目名称:learning-nette,代码行数:8,代码来源:EntityRepository.php

示例10: findBy

 public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
 {
     if (!isset($criteria['enabled'])) {
         $criteria['enabled'] = true;
     }
     return parent::findBy($criteria, $orderBy, $limit, $offset);
     // TODO: Change the autogenerated stub
 }
开发者ID:bhdm,项目名称:bbehterev,代码行数:8,代码来源:PublicationRepository.php

示例11: getVotesForImage

 public function getVotesForImage(Img $image)
 {
     $votes = $this->voteRepository->findBy(array("img" => $image));
     $votesSum = 0;
     foreach ($votes as $vote) {
         /** @var \Vendor\GalleryBundle\Entity\ImgVote $vote */
         $votesSum += $vote->getValue();
     }
     return $votesSum;
 }
开发者ID:wieloming,项目名称:PictureGallery,代码行数:10,代码来源:Image.php

示例12: findBy

 /**
  * Finds entities by a set of criteria with automatic join on section if need due to retro-compatibility.
  *
  * @param  array                $criteria           An array of criteria ( field => value ).
  * @param  array|null           $orderBy            Optional, an array of ordering criteria ( [field => direction] ).
  * @param  integer|null         $limit              Optional, the max number of results.
  * @param  integer|null         $offset             Optional, The starting index of results.
  *
  * @return Page[]                                   An array of matching pages.
  */
 public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
 {
     if (false === PageQueryBuilder::hasJoinCriteria($criteria) && false === PageQueryBuilder::hasJoinCriteria($orderBy)) {
         return parent::findBy($criteria, $orderBy, $limit, $offset);
     }
     $query = $this->createQueryBuilder('p')->addSearchCriteria($criteria);
     if (false === empty($orderBy)) {
         $query->addMultipleOrderBy($orderBy);
     }
     return $query->setMaxResults($limit)->setFirstResult($offset)->getQuery()->getResult();
 }
开发者ID:gobjila,项目名称:BackBee,代码行数:21,代码来源:PageRepository.php

示例13: getAll

 /**
  * {@inheritdoc}
  */
 public function getAll($mediaId)
 {
     $media = $this->mediaManager->getEntityById($mediaId);
     $fileVersion = $this->getFileVersionForMedia($media);
     $formatOptions = $this->formatOptionsRepository->findBy(['fileVersion' => $fileVersion]);
     $formatOptionsArray = [];
     /** @var FormatOptions $formatOptionEntity */
     foreach ($formatOptions as $formatOptionEntity) {
         $formatOptionsArray[$formatOptionEntity->getFormatKey()] = $this->entityToArray($formatOptionEntity);
     }
     return $formatOptionsArray;
 }
开发者ID:sulu,项目名称:sulu,代码行数:15,代码来源:FormatOptionsManager.php

示例14: findBy

 /**
  * {@inheritdoc}
  *
  * @throws EntityNotFoundException
  */
 public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
 {
     if (!array_key_exists('deletedAt', $criteria)) {
         $criteria['deletedAt'] = null;
     } elseif ($criteria['deletedAt'] === static::IGNORE_DELETE_AT) {
         unset($criteria['deletedAt']);
     }
     $result = parent::findBy($criteria, $orderBy, $limit, $offset);
     if (empty($result)) {
         throw new EntityNotFoundException();
     }
     return $result;
 }
开发者ID:staspiv,项目名称:rest-bundle,代码行数:18,代码来源:EntityRepository.php

示例15: getAllAsArray

 /**
  *
  * @return array
  */
 public function getAllAsArray($criteria = null)
 {
     $list = array();
     if ($criteria === null) {
         $list = parent::findAll();
     } else {
         if ($criteria instanceof Criteria) {
             $list = parent::matching($criteria);
         } else {
             $list = parent::findBy($criteria);
         }
     }
     $res = array();
     foreach ($list as $element) {
         $res[$element->getId()] = $element->getName();
     }
     return $res;
 }
开发者ID:LeCoyote,项目名称:epeires2,代码行数:22,代码来源:ExtendedRepository.php


注:本文中的Doctrine\ORM\EntityRepository::findBy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。