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


PHP ObjectRepository::findBy方法代码示例

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


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

示例1: findAll

 public function findAll()
 {
     if (false === $this->authorizationService->isGranted('user.admin')) {
         throw new UnauthorizedException('Insufficient Permissions');
     }
     return $this->objectRepository->findBy([], ['email' => 'ASC']);
 }
开发者ID:Indigo1337,项目名称:c4d,代码行数:7,代码来源:User.php

示例2: getSupportedMethods

 /**
  * {@inheritdoc}
  */
 public function getSupportedMethods(ShippingSubjectInterface $subject)
 {
     $methods = [];
     foreach ($this->shippingMethodRepository->findBy(['enabled' => true]) as $shippingMethod) {
         if ($this->eligibilityChecker->isEligible($subject, $shippingMethod)) {
             $methods[] = $shippingMethod;
         }
     }
     return $methods;
 }
开发者ID:okwinza,项目名称:Sylius,代码行数:13,代码来源:MethodsResolver.php

示例3: findAll

 /**
  * @return array
  * @throws UnauthorizedException
  */
 public function findAll()
 {
     if ($this->authorizationService->isGranted('recipe.admin')) {
         return $this->objectRepository->findBy([], ['dateUpdated' => 'DESC']);
     }
     if ($this->authorizationService->isGranted('recipe.manage')) {
         return $this->objectRepository->findBy(['author' => $this->authorizationService->getIdentity()], ['dateUpdated' => 'DESC']);
     }
     throw new UnauthorizedException('Insufficient Permission');
 }
开发者ID:Indigo1337,项目名称:c4d,代码行数:14,代码来源:ReadService.php

示例4: onArchetypeUpdate

 /**
  * @param GenericEvent $event
  */
 public function onArchetypeUpdate(GenericEvent $event)
 {
     $archetype = $event->getSubject();
     if (!$archetype instanceof ArchetypeInterface) {
         throw new UnexpectedTypeException($archetype, ArchetypeInterface::class);
     }
     $products = $this->productRepository->findBy(array('archetype' => $archetype));
     foreach ($products as $product) {
         $this->builder->build($product);
         $this->productManager->persist($product);
     }
 }
开发者ID:Silwereth,项目名称:Sylius,代码行数:15,代码来源:ArchetypeUpdateListener.php

示例5: fillBackorders

 /**
  * {@inheritdoc}
  */
 public function fillBackorders(StockableInterface $stockable)
 {
     $onHand = $stockable->getOnHand();
     if ($onHand <= 0) {
         return;
     }
     $units = $this->repository->findBy(array('stockable' => $stockable, 'inventoryState' => InventoryUnitInterface::STATE_BACKORDERED), array('createdAt' => 'ASC'));
     foreach ($units as $unit) {
         $unit->setInventoryState(InventoryUnitInterface::STATE_SOLD);
         if (--$onHand === 0) {
             break;
         }
     }
     $stockable->setOnHand($onHand);
 }
开发者ID:aleherse,项目名称:Sylius,代码行数:18,代码来源:BackordersHandler.php

示例6: getZones

 /**
  * Gets all zones
  *
  * @param string|null $scope
  *
  * @return array $zones
  */
 protected function getZones($scope = null)
 {
     if (null === $scope) {
         return $this->repository->findAll();
     }
     return $this->repository->findBy(array('scope' => $scope));
 }
开发者ID:bcremer,项目名称:Sylius,代码行数:14,代码来源:ZoneMatcher.php

示例7:

 function it_should_index_entity(ManagerRegistry $registry, EntityManager $em, ObjectRepository $repo)
 {
     $repo->findBy([], ['id' => 'DESC'], 1, 2)->willReturn([1, 2, 3]);
     $em->getRepository('foo')->willReturn($repo);
     $registry->getManager(null)->willReturn($em);
     $this->setRegistry($registry);
     $this->index(1, 2, 'id', 'DESC')->shouldBe([1, 2, 3]);
 }
开发者ID:Im0rtality,项目名称:rest-api-bundle,代码行数:8,代码来源:DoctrineOrmSourceSpec.php

示例8: getNonAppliedAutomaticCoupons

 /**
  * Get current cart automatic coupons.
  *
  * @param CartInterface $cart Cart
  *
  * @returns CouponInterface[] Array of non applied coupons
  */
 private function getNonAppliedAutomaticCoupons(CartInterface $cart)
 {
     $automaticCoupons = $this->couponRepository->findBy(['enforcement' => ElcodiCouponTypes::ENFORCEMENT_AUTOMATIC]);
     $loadedAutomaticCoupons = $this->cartCouponManager->getCoupons($cart);
     return array_udiff($automaticCoupons, $loadedAutomaticCoupons, function (CouponInterface $a, CouponInterface $b) {
         return $a->getId() != $b->getId();
     });
 }
开发者ID:pramoddas,项目名称:elcodi,代码行数:15,代码来源:AutomaticCouponApplicator.php

示例9: array

 function it_does_reverse_transform_identifiers_to_array_of_entities(ObjectRepository $repository, FakeEntity $entityOne, FakeEntity $entityTwo)
 {
     $value = array(1, 2);
     $entityOne->getId()->willReturn(1);
     $entityTwo->getId()->willReturn(2);
     $repository->findBy(array('id' => $value))->shouldBeCalled()->willReturn(array($entityOne, $entityTwo));
     $this->reverseTransform($value)->shouldReturn(array($entityOne, $entityTwo));
 }
开发者ID:Avazanga1,项目名称:Sylius,代码行数:8,代码来源:ObjectCollectionToIdentifiersTransformerSpec.php

示例10: tryAutomaticCoupons

 /**
  * Method subscribed to PreCartLoad event
  *
  * Iterate over all automatic Coupons and check if they apply.
  * If any applies, it will be added to the Cart
  *
  * @param CartOnLoadEvent $event Event
  *
  * @return null
  */
 public function tryAutomaticCoupons(CartOnLoadEvent $event)
 {
     $cart = $event->getCart();
     if ($cart->getCartLines()->isEmpty()) {
         return null;
     }
     /**
      * @var CouponInterface[] $automaticCoupons
      */
     $automaticCoupons = $this->couponRepository->findBy(['enforcement' => ElcodiCouponTypes::ENFORCEMENT_AUTOMATIC]);
     foreach ($automaticCoupons as $coupon) {
         try {
             $this->cartCouponManager->addCoupon($cart, $coupon);
         } catch (AbstractCouponException $e) {
             // Silently tries next coupon on controlled exception
         }
     }
 }
开发者ID:raizeta,项目名称:elcodi,代码行数:28,代码来源:AutomaticCouponApplicatorEventListener.php

示例11:

 function it_returns_all_methods_eligible_for_given_subject(ObjectRepository $methodRepository, ShippingMethodEligibilityCheckerInterface $eligibilityChecker, ShippingSubjectInterface $subject, ShippingMethodInterface $method1, ShippingMethodInterface $method2, ShippingMethodInterface $method3)
 {
     $methods = [$method1, $method2, $method3];
     $methodRepository->findBy(['enabled' => true])->shouldBeCalled()->willReturn($methods);
     $eligibilityChecker->isEligible($subject, $method1)->shouldBeCalled()->willReturn(true);
     $eligibilityChecker->isEligible($subject, $method2)->shouldBeCalled()->willReturn(true);
     $eligibilityChecker->isEligible($subject, $method3)->shouldBeCalled()->willReturn(false);
     $this->getSupportedMethods($subject)->shouldReturn([$method1, $method2]);
 }
开发者ID:loic425,项目名称:Sylius,代码行数:9,代码来源:ShippingMethodsResolverSpec.php

示例12:

 function it_partially_fills_backordered_units_and_updates_stock_accordingly(StockableInterface $stockable, InventoryUnitInterface $inventoryUnit1, InventoryUnitInterface $inventoryUnit2, ObjectRepository $repository)
 {
     $stockable->getOnHand()->shouldBeCalled()->willReturn(5);
     $stockable->setOnHand(3)->shouldBeCalled();
     $inventoryUnit1->setInventoryState(InventoryUnitInterface::STATE_SOLD)->shouldBeCalled();
     $inventoryUnit2->setInventoryState(InventoryUnitInterface::STATE_SOLD)->shouldBeCalled();
     $repository->findBy(['stockable' => $stockable, 'inventoryState' => InventoryUnitInterface::STATE_BACKORDERED], ['createdAt' => 'ASC'])->willReturn([$inventoryUnit1, $inventoryUnit2]);
     $this->fillBackorders($stockable);
 }
开发者ID:ahmadrabie,项目名称:Sylius,代码行数:9,代码来源:BackordersHandlerSpec.php

示例13:

 function it_schedules_owning_document_for_update_when_setting_element_by_key_in_the_collection(MongoDBODMUnitOfWork $uow, DocumentStub $document, ObjectRepository $repository, ClassMetadata $classMetadata, EntityStub $entity4, EntityStub $entity8, EntityStub $entity15, EntityStub $newEntity)
 {
     $classMetadata->getIdentifier()->willReturn(['id']);
     $repository->findBy(['id' => [4, 8, 15]])->willReturn([$entity4, $entity8, $entity15]);
     $uow->getDocumentState($document)->willReturn(MongoDBODMUnitOfWork::STATE_MANAGED);
     $uow->isScheduledForUpdate($document)->willReturn(false);
     $uow->scheduleForUpdate($document)->shouldBeCalled();
     $this->setOwner($document);
     $this->set(2, $newEntity);
 }
开发者ID:javiersantos,项目名称:pim-community-dev,代码行数:10,代码来源:ReferencedCollectionSpec.php

示例14: getRoles

 /**
  * {@inheritDoc}
  */
 public function getRoles(array $roleNames)
 {
     $key = implode($roleNames);
     if (isset($this->roleCache[$key])) {
         return $this->roleCache[$key];
     }
     $roles = $this->objectRepository->findBy([$this->roleNameProperty => $roleNames]);
     // We allow more roles to be loaded than asked (although this should not happen because
     // role name should have a UNIQUE constraint in database... but just in case ;))
     if (count($roles) >= count($roleNames)) {
         $this->roleCache[$key] = $roles;
         return $roles;
     }
     // We have roles that were asked but couldn't be found in database... problem!
     foreach ($roles as &$role) {
         $role = $role->getName();
     }
     throw new RoleNotFoundException(sprintf('Some roles were asked but could not be loaded from database: %s', implode(', ', array_diff($roleNames, $roles))));
 }
开发者ID:zf-commons,项目名称:zfc-rbac,代码行数:22,代码来源:ObjectRepositoryRoleProvider.php

示例15:

 function it_updates_products_with_newer_attributes_added_to_their_archetypes(GenericEvent $event, ArchetypeInterface $archetype, ArchetypeBuilderInterface $builder, ObjectRepository $productRepository, ObjectManager $productManager, ProductInterface $productA, ProductInterface $productB)
 {
     $event->getSubject()->willReturn($archetype);
     $productRepository->findBy(array('archetype' => $archetype))->willReturn(array($productA, $productB));
     $builder->build($productA)->shouldBeCalled();
     $builder->build($productB)->shouldBeCalled();
     $productManager->persist($productA)->shouldBeCalled();
     $productManager->persist($productB)->shouldBeCalled();
     $this->onArchetypeUpdate($event);
 }
开发者ID:aleherse,项目名称:Sylius,代码行数:10,代码来源:ArchetypeUpdateListenerSpec.php


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