• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Persistence\ObjectRepository类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: Place

    function it_converts_node_to_street_entry_with_updating_existing_one(ObjectManager $om, ObjectRepository $or, Street $street)
    {
        $xml = <<<EOT
<row>
    <col name="WOJ">02</col>
    <col name="POW">23</col>
    <col name="GMI">09</col>
    <col name="RODZ_GMI">2</col>
    <col name="SYM">0884849</col>
    <col name="SYM_UL">10268</col>
    <col name="CECHA">ul.</col>
    <col name="NAZWA_1">Księżycowa </col>
    <col name="NAZWA_2"/>
    <col name="STAN_NA">2013-10-10</col>
</row>
EOT;
        $place = new Place(884849);
        $place->setName('City');
        $or->findOneBy(array('id' => '0884849'))->shouldBeCalled()->willReturn($place);
        $or->findOneBy(array('id' => '10268', 'place' => $place))->shouldBeCalled()->willReturn($street);
        $street->setName('Księżycowa')->shouldBeCalled()->willReturn($street);
        $street->setAdditionalName('')->shouldBeCalled()->willReturn($street);
        $street->setType('ul.')->shouldBeCalled()->willReturn($street);
        $this->beConstructedWith(new \SimpleXMLElement($xml), $om);
        $this->convertToEntity()->shouldBeLike($street->getWrappedObject());
    }
开发者ID:jacdobro,项目名称:teryt-database-bundle,代码行数:26,代码来源:StreetsNodeConverterSpec.php


示例2: 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


示例3: Isbn

 function it_searches_book_by_isbn_number(BookInterface $book, ObjectRepository $doctrineRepository)
 {
     $isbn = new Isbn('978-1-56619-909-4');
     $doctrineRepository->findOneBy(array('isbn.number' => $isbn))->willReturn($book);
     $this->searchByIsbn($isbn)->shouldBeLike(SearchResults::fromArrayOfBooks(array($book->getWrappedObject())));
     $doctrineRepository->findOneBy(array('isbn.number' => $isbn))->willReturn(null);
     $this->searchByIsbn($isbn)->shouldBeLike(SearchResults::asEmpty());
 }
开发者ID:pjedrzejewski,项目名称:phpbenelux-2016-modelling-by-example,代码行数:8,代码来源:DoctrineLibrarySpec.php


示例4:

 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


示例5:

 function it_fetches_the_object_from_the_in_memory_cache_the_second_time(ObjectManager $manager, ObjectRepository $repository, \stdClass $object)
 {
     $repository->implement('Pim\\Bundle\\CatalogBundle\\Repository\\ReferableEntityRepositoryInterface');
     $manager->getRepository('Object\\Class')->willReturn($repository);
     $repository->findByReference('foo')->shouldBeCalledTimes(1)->willReturn($object);
     $this->find('Object\\Class', 'foo')->shouldReturn($object);
     $this->find('Object\\Class', 'foo')->shouldReturn($object);
     $this->find('Object\\Class', 'foo')->shouldReturn($object);
 }
开发者ID:javiersantos,项目名称:pim-community-dev,代码行数:9,代码来源:DoctrineCacheSpec.php


示例6:

 function it_fetches_the_object_from_the_in_memory_cache_the_second_time(ObjectManager $manager, ObjectRepository $repository, \stdClass $object)
 {
     $repository->implement('Akeneo\\Component\\StorageUtils\\Repository\\IdentifiableObjectRepositoryInterface');
     $manager->getRepository('Object\\Class')->willReturn($repository);
     $repository->findOneByIdentifier('foo')->shouldBeCalledTimes(1)->willReturn($object);
     $this->find('Object\\Class', 'foo')->shouldReturn($object);
     $this->find('Object\\Class', 'foo')->shouldReturn($object);
     $this->find('Object\\Class', 'foo')->shouldReturn($object);
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:9,代码来源:DoctrineCacheSpec.php


示例7: resolveOne

 /**
  * @param ObjectRepository $repository
  * @param string           $referenceDataName
  * @param string           $code
  *
  * @throws \LogicException
  *
  * @return int
  */
 protected function resolveOne(ObjectRepository $repository, $referenceDataName, $code)
 {
     //TODO: do not hydrate them, use a scalar result
     $referenceData = $repository->findOneBy(['code' => $code]);
     if (null === $referenceData) {
         throw new \LogicException(sprintf('No reference data "%s" with code "%s" has been found', $referenceDataName, $code));
     }
     return $referenceData->getId();
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:18,代码来源:ReferenceDataIdResolver.php


示例8:

 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


示例9: createAddress

 /**
  * @param $data
  * @return AbstractDefaultTypedAddress
  */
 protected function createAddress($data)
 {
     /** @var Country $country */
     $country = $this->countryRepository->findOneBy(['iso2Code' => $data['country']]);
     if (!$country) {
         throw new \RuntimeException('Can\'t find country with ISO ' . $data['country']);
     }
     /** @var Region $region */
     $region = $this->regionRepository->findOneBy(['country' => $country, 'code' => $data['state']]);
     if (!$region) {
         throw new \RuntimeException(printf('Can\'t find region with country ISO %s and code %s', $data['country'], $data['state']));
     }
     $types = [];
     $typesFromData = explode(',', $data['types']);
     foreach ($typesFromData as $type) {
         $types[] = $this->addressTypeRepository->find($type);
     }
     $defaultTypes = [];
     $defaultTypesFromData = explode(',', $data['defaultTypes']);
     foreach ($defaultTypesFromData as $defaultType) {
         $defaultTypes[] = $this->addressTypeRepository->find($defaultType);
     }
     $address = $this->getNewAddressEntity();
     $address->setTypes(new ArrayCollection($types));
     $address->setDefaults(new ArrayCollection($defaultTypes))->setPrimary(true)->setLabel('Primary address')->setCountry($country)->setStreet($data['street'])->setCity($data['city'])->setRegion($region)->setPostalCode($data['zipCode']);
     return $address;
 }
开发者ID:adam-paterson,项目名称:orocommerce,代码行数:31,代码来源:AbstractLoadAddressDemoData.php


示例10: getRoles

 /**
  * {@inheritDoc}
  */
 public function getRoles()
 {
     $result = $this->objectRepository->findAll();
     $roles = array();
     // Pass One: Build each object
     foreach ($result as $role) {
         if (!$role instanceof RoleInterface) {
             continue;
         }
         $roleId = $role->getRoleId();
         $parent = null;
         if ($role instanceof HierarchicalRoleInterface && ($parent = $role->getParent())) {
             $parent = $parent->getRoleId();
         }
         $roles[$roleId] = new Role($roleId, $parent);
     }
     // Pass Two: Re-inject parent objects to preserve hierarchy
     /* @var $roleObj \BjyAuthorize\Acl\Role */
     foreach ($roles as $roleObj) {
         $parentRoleObj = $roleObj->getParent();
         if ($parentRoleObj && $parentRoleObj->getRoleId()) {
             $roleObj->setParent($roles[$parentRoleObj->getRoleId()]);
         }
     }
     return array_values($roles);
 }
开发者ID:pbrilius,项目名称:BjyAuthorize,代码行数:29,代码来源:ObjectRepositoryProvider.php


示例11: getRules

 /**
  * Here we read rules from DB and put them into a form that BjyAuthorize's Controller.php understands
  */
 public function getRules()
 {
     $rules = array();
     // initialize the rules array
     //
     // get the doctrine shemaManager
     $schemaManager = $this->objectManager->getConnection()->getSchemaManager();
     // check if the roles table exists, if it does not, do not bother querying
     if ($schemaManager->tablesExist(array('roles')) === true) {
         //read from object store a set of (role, controller, action)
         $result = $this->objectRepository->findAll();
         // if a result set exists
         if (count($result)) {
             //transform to object BjyAuthorize will understand
             foreach ($result as $key => $role) {
                 $roleId = $role->getRoleId();
                 // check if any resource access has been defined before
                 // if it has, continue with normal operations
                 // else, allow access to this first user
                 if (!$role->getResources()) {
                     continue;
                 }
                 foreach ($role->getResources() as $rle) {
                     $this->defaultRules['allow'][] = [[$roleId], $rle->getControllerId(), []];
                 }
             }
         }
     }
     return $this->defaultRules;
 }
开发者ID:AwoyoToyin,项目名称:ZfMuscle,代码行数:33,代码来源:DoctrineRuleProvider.php


示例12: buildAdminEntity

 protected function buildAdminEntity($value, Toponym $toponym)
 {
     /* @var $admin \Giosh94mhz\GeonamesBundle\Entity\Admin1 */
     $admin = $this->repository->find($toponym) ?: new Admin1($toponym);
     $admin->setCode($value[5])->setCountryCode($value[4])->setName($value[1])->setAsciiName($value[2]);
     return $admin;
 }
开发者ID:mhlavac,项目名称:GeonamesBundle,代码行数:7,代码来源:Admin1ImportStepBuilder.php


示例13: checkDuplicity

 private function checkDuplicity(Category $category)
 {
     $duplicate = $this->repository->findOneBy(['path' => $category->getPath()]);
     if ($duplicate !== null) {
         throw new EntityDuplicateException(sprintf('Category with path %s already exists.', $category->getPath()));
     }
 }
开发者ID:shophp,项目名称:shophp,代码行数:7,代码来源:CategoryService.php


示例14: loadChoiceList

 /**
  * {@inheritdoc}
  */
 public function loadChoiceList($value = null)
 {
     if ($this->choiceList) {
         return $this->choiceList;
     }
     return $this->choiceList = $this->factory->createListFromChoices($this->repository->findAll(), $value);
 }
开发者ID:integratedfordevelopers,项目名称:integrated-channel-bundle,代码行数:10,代码来源:ChannelChoiceLoader.php


示例15: testFindSchedules

 public function testFindSchedules()
 {
     $limit = 2;
     $offset = 1;
     $this->repository->expects($this->once())->method('findBy')->with(array(), array(), $limit, $offset);
     $this->subject->findSchedules($limit, $offset);
 }
开发者ID:aboutcoders,项目名称:scheduler-bundle,代码行数:7,代码来源:ScheduleManagerTest.php


示例16: buildEntity

 public function buildEntity($value)
 {
     $parent = null;
     $child = null;
     try {
         /* @var $parent \Giosh94mhz\GeonamesBundle\Entity\Toponym */
         $parent = $this->toponymRepository->find($value[0]);
         /* @var $child \Giosh94mhz\GeonamesBundle\Entity\Toponym */
         $child = $this->toponymRepository->find($value[1]);
         if (!$parent || !$child) {
             throw new MissingToponymException("HierarchyLink not imported due to missing toponym '{$value['0']}=>{$value['1']}'");
         }
         /* @var $link \Giosh94mhz\GeonamesBundle\Entity\HierarchyLink */
         $link = $this->repository->find(array('parent' => $parent->getId(), 'child' => $child->getId())) ?: new HierarchyLink($parent, $child);
         $link->setType($value[2]);
         return $link;
     } catch (\Exception $e) {
         if ($parent !== null) {
             $this->om->detach($parent);
         }
         if ($child !== null) {
             $this->om->detach($child);
         }
         throw $e;
     }
 }
开发者ID:mhlavac,项目名称:GeonamesBundle,代码行数:26,代码来源:HierarchyImportStepBuilder.php


示例17: testFindWithInvalidObject

 /**
  * @expectedException \Liip\ImagineBundle\Exception\Binary\Loader\NotLoadableException
  */
 public function testFindWithInvalidObject()
 {
     $this->loader->expects($this->atLeastOnce())->method('mapPathToId')->with('/foo/bar')->will($this->returnValue(1337));
     $this->loader->expects($this->never())->method('getStreamFromImage');
     $this->om->expects($this->atLeastOnce())->method('find')->with(null, 1337)->will($this->returnValue(null));
     $this->loader->find('/foo/bar');
 }
开发者ID:raphydev,项目名称:onep,代码行数:10,代码来源:AbstractDoctrineLoaderTest.php


示例18: get

 /**
  * @param string $paymentMethod
  *
  * @return array
  */
 public function get($paymentMethod)
 {
     if (!isset($this->settings[$paymentMethod])) {
         $this->settings[$paymentMethod] = $this->repository->getSettingsForMethodArray($paymentMethod);
     }
     return $this->settings[$paymentMethod];
 }
开发者ID:csbill,项目名称:csbill,代码行数:12,代码来源:PaymentSettingsManager.php


示例19: get

 /**
  * @{inheritdoc}
  */
 public function get($id = null)
 {
     if (null !== $id) {
         return $this->repository->find($id);
     }
     return $this->repository->findAll();
 }
开发者ID:KmeCnin,项目名称:fumble-mania-rest-backend,代码行数:10,代码来源:AbstractManager.php


示例20: tryGetMRByCode

 /**
  * Try to get from local property if exist or load from database afterwards
  *
  * @param string $code
  *
  * @return Region|Null
  */
 protected function tryGetMRByCode($code)
 {
     if (!isset($this->MRIdentityMap[$code]) && !array_key_exists($code, $this->MRIdentityMap)) {
         $this->MRIdentityMap[$code] = $this->repository->findOneBy(['combinedCode' => $code]);
     }
     return $this->MRIdentityMap[$code];
 }
开发者ID:dairdr,项目名称:crm,代码行数:14,代码来源:RegionConverter.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Event\LifecycleEventArgs类代码示例发布时间:2022-05-23
下一篇:
PHP Persistence\ObjectManager类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap