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


PHP ObjectRepository::find方法代码示例

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


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

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

示例2: get

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

示例3: findById

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

示例4: getLastOrder

 /**
  * @return Order
  */
 public function getLastOrder()
 {
     if ($this->orderSession->orderId !== null) {
         return $this->repository->find($this->orderSession->orderId);
     }
     return null;
 }
开发者ID:shophp,项目名称:shophp,代码行数:10,代码来源:OrderService.php

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

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

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

示例8: refreshUser

 /**
  * @param UserInterface $user
  *
  * @return object
  */
 public function refreshUser(UserInterface $user)
 {
     $class = get_class($user);
     if (!$this->supportsClass($class)) {
         throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', $class));
     }
     return $this->userRepository->find($user->getId());
 }
开发者ID:remy-theroux,项目名称:garbage-reducer-api,代码行数:13,代码来源:UserProvider.php

示例9: buildEntity

 public function buildEntity($value)
 {
     if ($value[0] === 'ISO 639-3') {
         throw new SkipImportException("Language file header is not commented out");
     }
     /* @var $language \Giosh94mhz\GeonamesBundle\Entity\Language */
     $language = $this->repository->find($value[0]) ?: new Language($value[0]);
     $language->setIso639p2($value[1])->setIso639p1($value[2])->setName($value[3]);
     return $language;
 }
开发者ID:mhlavac,项目名称:GeonamesBundle,代码行数:10,代码来源:LanguageImportStepBuilder.php

示例10: hydrate

 /**
  * @param  int|null $value
  * @return object|null
  * @throws RuntimeException
  */
 public function hydrate($value)
 {
     if (empty($value)) {
         return null;
     }
     $entity = $this->objectRepository->find($value);
     if ($entity === null) {
         throw new RuntimeException(sprintf('Entity with ID "%s" not found', $value));
     }
     return $entity;
 }
开发者ID:DavidHavl,项目名称:Ajasta,代码行数:16,代码来源:EntityStrategy.php

示例11: buildEntity

 public function buildEntity($value)
 {
     if (mb_strtolower($value[0]) === 'null') {
         throw new SkipImportException("Well-known null feature");
     }
     list($class, $code) = explode('.', $value[0], 2);
     /* @var $feature \Giosh94mhz\GeonamesBundle\Entity\Feature */
     $feature = $this->repository->find(array('code' => $code, 'class' => $class)) ?: new Feature($class, $code);
     $feature->setName($value[1])->setDescription($value[2]);
     return $feature;
 }
开发者ID:mhlavac,项目名称:GeonamesBundle,代码行数:11,代码来源:FeatureImportStepBuilder.php

示例12: buildEntity

 public function buildEntity($value)
 {
     /* @var $continent \Giosh94mhz\GeonamesBundle\Entity\Continent */
     $continent = $this->repository->find($value[2]);
     if (!$continent) {
         /* @var $toponym \Giosh94mhz\GeonamesBundle\Entity\Toponym */
         $toponym = $this->toponymRepository->find($value[2]) ?: $this->createFallbackToponym($value[0], $value[1], $value[2]);
         $continent = new Continent($toponym);
     }
     $continent->setCode($value[0])->setName($value[1]);
     return $continent;
 }
开发者ID:mhlavac,项目名称:GeonamesBundle,代码行数:12,代码来源:ContinentImportStepBuilder.php

示例13: buildEntity

 public function buildEntity($value)
 {
     /* @var $toponym \Giosh94mhz\GeonamesBundle\Entity\Toponym */
     $toponym = $this->toponymRepository->find($value[1]);
     if (!$toponym) {
         throw new SkipImportException("Toponym doesn't exists");
     }
     /* @var $alternateName \Giosh94mhz\GeonamesBundle\Entity\AlternateName */
     $alternateName = $this->repository->find($value[0]) ?: new AlternateName($value[0]);
     $alternateName->setToponym($toponym)->setLanguage($value[2])->setName($value[3])->setIsPreferredName(!empty($value[4]))->setIsShortName(!empty($value[5]))->setIsColloquial(!empty($value[6]))->setIsHistoric(!empty($value[6]));
     return $alternateName;
 }
开发者ID:mhlavac,项目名称:GeonamesBundle,代码行数:12,代码来源:AlternateNameImportStepBuilder.php

示例14: getById

 /**
  * @return ShipmentOption
  */
 public function getById(ShipmentType $type, $id)
 {
     if ($type->isPersonal()) {
         return $this->personalPointRepository->find($id);
     } elseif ($type->isByTransportCompany()) {
         return $this->transportCompanyRepository->find($id);
     } elseif ($type->isToCollectionPoint()) {
         return $this->collectionPointRepository->find($id);
     } else {
         throw new \LogicException();
     }
 }
开发者ID:shophp,项目名称:shophp,代码行数:15,代码来源:ShipmentService.php

示例15: preSubmit

 /**
  * Removes or adds a province field based on the country set on submitted form.
  *
  * @param FormEvent $event
  */
 public function preSubmit(FormEvent $event)
 {
     $data = $event->getData();
     if (!is_array($data) || !array_key_exists('country', $data)) {
         return;
     }
     $country = $this->countryRepository->find($data['country']);
     if (null === $country) {
         return;
     }
     if ($country->hasProvinces()) {
         $event->getForm()->add($this->factory->createNamed('province', 'sylius_province_choice', null, array('country' => $country, 'auto_initialize' => false)));
     }
 }
开发者ID:lingoda,项目名称:Sylius,代码行数:19,代码来源:BuildAddressFormSubscriber.php


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