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


PHP RegistryInterface::getRepository方法代码示例

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


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

示例1: finishView

 /**
  * @inheritdoc
  */
 public function finishView(FormView $view, FormInterface $form, array $options)
 {
     /** @var ChoiceView $choice */
     foreach ($view->vars['choices'] as $choice) {
         if ($options['select2_template_result']) {
             $object = $choice->value;
             if ($this->doctrine && $options['class']) {
                 $object = $this->doctrine->getRepository($options['class'])->find($object);
             }
             if (is_string($options['select2_template_result'])) {
                 $choice->attr['data-template-result'] = $this->templating->render($options['select2_template_result'], ['choice' => $choice, 'object' => $object]);
             } else {
                 $choice->attr['data-template-result'] = call_user_func_array($options['select2_template_result'], [$choice, $object]);
             }
         }
         if ($options['select2_template_selection']) {
             $object = $choice->value;
             if ($this->doctrine && $options['class']) {
                 $object = $this->doctrine->getRepository($options['class'])->find($object);
             }
             if (is_string($options['select2_template_selection'])) {
                 $choice->attr['data-template-selection'] = $this->templating->render($options['select2_template_selection'], ['choice' => $choice, 'object' => $object]);
             } else {
                 $choice->attr['data-template-selection'] = call_user_func_array($options['select2_template_selection'], [$choice, $object]);
             }
         }
     }
     if ($options['select2'] === true) {
         $options['select2_options'] = array_merge($this->select2DefaultOptions, $options['select2_options']);
         $view->vars['select2_options'] = json_encode($options['select2_options']);
     }
 }
开发者ID:rafrsr,项目名称:form-extra-bundle,代码行数:35,代码来源:Select2Extension.php

示例2: getIntegrationFromContext

 /**
  * @param array $context
  *
  * @return Integration
  * @throws \LogicException
  */
 public function getIntegrationFromContext(array $context)
 {
     if (!isset($context['channel'])) {
         throw new \LogicException('Context should contain reference to channel');
     }
     return $this->registry->getRepository('OroIntegrationBundle:Channel')->getOrLoadById($context['channel']);
 }
开发者ID:dairdr,项目名称:crm,代码行数:13,代码来源:ImportHelper.php

示例3: listAction

 /**
  * Returns a JSON response containing options
  *
  * @param Request $request
  *
  * @return JsonResponse
  */
 public function listAction(Request $request)
 {
     $query = $request->query;
     $search = $query->get('search');
     $referenceDataName = $query->get('referenceDataName');
     $class = $query->get('class');
     if (null !== $referenceDataName) {
         $class = $this->registry->get($referenceDataName)->getClass();
     }
     $repository = $this->doctrine->getRepository($class);
     if ($repository instanceof OptionRepositoryInterface) {
         $choices = $repository->getOptions($query->get('dataLocale'), $query->get('collectionId'), $search, $query->get('options', []));
     } elseif ($repository instanceof ReferenceDataRepositoryInterface) {
         $choices['results'] = $repository->findBySearch($search, $query->get('options', []));
     } elseif ($repository instanceof SearchableRepositoryInterface) {
         $choices['results'] = $repository->findBySearch($search, $query->get('options', []));
     } elseif (method_exists($repository, 'getOptions')) {
         $choices = $repository->getOptions($query->get('dataLocale'), $query->get('collectionId'), $search, $query->get('options', []));
     } else {
         throw new \LogicException(sprintf('The repository of the class "%s" can not retrieve options via Ajax.', $query->get('class')));
     }
     if ($query->get('isCreatable') && 0 === count($choices['results'])) {
         $choices['results'] = [['id' => $search, 'text' => $search]];
     }
     return new JsonResponse($choices);
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:33,代码来源:AjaxOptionController.php

示例4: packageExistsTest

 public function packageExistsTest($package)
 {
     if (!preg_match('/^[A-Za-z0-9_.-]+\\/[A-Za-z0-9_.-]+$/', $package)) {
         return false;
     }
     return $this->doctrine->getRepository('PackagistWebBundle:Package')->packageExists($package);
 }
开发者ID:rdohms,项目名称:packagist,代码行数:7,代码来源:PackagistExtension.php

示例5: findPattern

 protected function findPattern(FormBuilderInterface $builder)
 {
     $pattern = $this->registry->getRepository('ClasticAliasBundle:AliasPattern')->findOneBy(array('moduleIdentifier' => $builder->getData()->getNode()->getType()));
     if ($pattern) {
         return $pattern->getPattern();
     }
     return '{title}';
 }
开发者ID:clastic,项目名称:clastic,代码行数:8,代码来源:NodeTypeExtension.php

示例6: getPeriod

 /**
  * @param array  $dateRange
  * @param string $entity
  * @param string $field
  *
  * @return \DateTime[]
  */
 public function getPeriod($dateRange, $entity, $field)
 {
     $start = $dateRange['start'];
     $end = $dateRange['end'];
     if ($dateRange['type'] === AbstractDateFilterType::TYPE_LESS_THAN) {
         $qb = $this->doctrine->getRepository($entity)->createQueryBuilder('e')->select(sprintf('MIN(e.%s) as val', $field));
         $start = $this->aclHelper->apply($qb)->getSingleScalarResult();
         $start = new \DateTime($start, new \DateTimeZone('UTC'));
     }
     return [$start, $end];
 }
开发者ID:Maksold,项目名称:platform,代码行数:18,代码来源:BigNumberDateHelper.php

示例7: trainContainer

 protected function trainContainer()
 {
     $this->request->getSession()->willReturn($this->session);
     $this->request->getLocale()->willReturn('fr_FR');
     $this->doctrine->getManager()->willReturn($this->manager);
     $this->doctrine->getManager()->willReturn($this->manager);
     $this->doctrine->getRepository('DonateCoreBundle:Intent')->willReturn($this->intentRepository);
     $this->container->has('doctrine')->willReturn(true);
     $this->container->get('doctrine')->willReturn($this->doctrine);
     $this->container->get('request')->willReturn($this->request);
     $this->container->get('donate_core.payment_method_discovery')->willReturn($this->discovery);
     $this->container->get('event_dispatcher')->willReturn($this->dispatcher);
     $this->container->get('logger')->willReturn($this->logger);
 }
开发者ID:bco-trey,项目名称:edonate,代码行数:14,代码来源:DefaultIntentManagerSpec.php

示例8: rotate

 /**
  * Rotates imported feeds
  *
  * @param Feed    $feed The feed to rotate imports for
  * @param integer $max  The number of imports to keep
  */
 public function rotate(Feed $feed, $max = 4)
 {
     /** @var ImportRepository $repo */
     $repo = $this->doctrine->getRepository('FMIoBundle:Import');
     $imports = $repo->findCompletedByFeed($feed);
     if (sizeof($imports) <= $max) {
         return;
     }
     $manager = $this->doctrine->getManager();
     foreach (array_slice($imports, $max) as $import) {
         $this->eventDispatcher->dispatch(IoEvents::IMPORT_ROTATE, new ImportEvent($import));
         $manager->remove($import);
         $manager->flush();
     }
 }
开发者ID:mvanduijker,项目名称:FMIoBundle,代码行数:21,代码来源:ImportRotator.php

示例9: getAttributes

 /**
  * Sets the attributes and identifierAttributes properties
  *
  * @param array $columnsInfo
  *
  * @return array|null
  */
 public function getAttributes($columnsInfo)
 {
     if (!count($columnsInfo)) {
         return array();
     }
     $codes = array_unique(array_map(function ($columnInfo) {
         return $columnInfo->getName();
     }, $columnsInfo));
     $attributes = $this->doctrine->getRepository($this->attributeClass)->findBy(array('code' => $codes));
     $attributeMap = array();
     foreach ($attributes as $attribute) {
         $attributeMap[$attribute->getCode()] = $attribute;
     }
     return $attributeMap;
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:22,代码来源:AttributeCache.php

示例10: listAction

 /**
  * Returns a JSON response containing options
  *
  * @param Request $request
  *
  * @return JsonResponse
  */
 public function listAction(Request $request)
 {
     $query = $request->query;
     $repository = $this->doctrine->getRepository($query->get('class'));
     if ($repository instanceof OptionRepositoryInterface) {
         $choices = $repository->getOptions($query->get('dataLocale'), $query->get('collectionId'), $query->get('search'), $query->get('options', []));
     } elseif ($repository instanceof ReferenceDataRepositoryInterface) {
         $choices['results'] = $repository->findBySearch($query->get('search'), $query->get('options', []));
     } elseif (method_exists($repository, 'getOptions')) {
         $choices = $repository->getOptions($query->get('dataLocale'), $query->get('collectionId'), $query->get('search'), $query->get('options', []));
     } else {
         throw new \LogicException(sprintf('The repository of the class "%s" can not retrieve options via Ajax.', $query->get('class')));
     }
     return new JsonResponse($choices);
 }
开发者ID:jacko972,项目名称:pim-community-dev,代码行数:22,代码来源:AjaxOptionController.php

示例11: isManaged

 /**
  * Returns true of the implementation manages this type of object.
  *
  * @param mixed $object
  *
  * @return bool
  */
 public function isManaged($object)
 {
     if (!is_object($object)) {
         return false;
     }
     $className = get_class($object);
     if (isset($this->resolvedCache[$className])) {
         return $this->resolvedCache[$className];
     }
     try {
         $this->registry->getRepository($className);
     } catch (MappingException $e) {
         return $this->resolvedCache[$className] = false;
     }
     return $this->resolvedCache[$className] = true;
 }
开发者ID:iltar,项目名称:http-bundle,代码行数:23,代码来源:EntityIdDescriptor.php

示例12: getOrCreateAccessToken

 /**
  * @param TokenInterface $token
  */
 protected function getOrCreateAccessToken(TokenInterface $token)
 {
     $user = $token->getUser();
     $tokenManager = new TokenManager($this->doctrine->getEntityManager(), 'Acme\\SPA\\ApiBundle\\Entity\\OAuth\\AccessToken');
     $oauthToken = $tokenManager->findTokenBy(array('user' => $token->getUser()));
     if (!$oauthToken instanceof AccessToken) {
         // id 1 is our chaplin client
         $chaplinClient = $this->doctrine->getRepository('AcmeSPAApiBundle:Oauth\\Client')->find(1);
         $oauthToken = $tokenManager->createToken();
         // TODO: create a more sophisticated access token
         $oauthToken->setToken(uniqid());
         $oauthToken->setClient($chaplinClient);
         $oauthToken->setUser($user);
         $oauthToken->updateToken($token);
     }
     return $oauthToken;
 }
开发者ID:ketu,项目名称:symfony-chaplin-demo,代码行数:20,代码来源:AuthenticationSuccessHandler.php

示例13: prePersist

 /**
  * @param LifecycleEventArgs
  */
 public function prePersist(LifecycleEventArgs $args)
 {
     $build = $args->getEntity();
     if (!$build instanceof Build || $build->isPullRequest()) {
         return;
     }
     $em = $this->doctrine->getManager();
     $branch = $this->doctrine->getRepository('Model:Branch')->findOneByProjectAndName($build->getProject(), $build->getRef());
     if (!$branch) {
         $this->logger->info('creating non-existing branch', ['project' => $build->getProject()->getId(), 'branch' => $build->getRef()]);
         $branch = new Branch();
         $branch->setName($build->getRef());
         $branch->setProject($build->getProject());
         $em->persist($branch);
     }
     $build->setBranch($branch);
 }
开发者ID:blazarecki,项目名称:stage1,代码行数:20,代码来源:BuildBranchRelationSubscriber.php

示例14: prePersist

 /**
  * @param LifecycleEventArgs
  */
 public function prePersist(LifecycleEventArgs $args)
 {
     $build = $args->getEntity();
     if (!$this->supports($build)) {
         return;
     }
     $em = $this->doctrine->getManager();
     $pr = $this->doctrine->getRepository('Model:PullRequest')->findOneBy(['project' => $build->getProject()->getId(), 'ref' => $build->getRef()]);
     if (!$pr) {
         $this->logger->info('creating non-existing pr', ['project' => $build->getProject()->getId(), 'ref' => $build->getRef()]);
         $project = $build->getProject();
         if (null === $project) {
             $this->logger->info('could not find a project for build', ['build_id' => $build->getId()]);
         }
         $provider = $this->providerFactory->getProvider($project);
         $pr = $provider->createPullRequestFromPayload($project, $build->getRawPayload());
         $em->persist($pr);
     }
     $build->setPullRequest($pr);
 }
开发者ID:blazarecki,项目名称:stage1,代码行数:23,代码来源:BuildPullRequestRelationSubscriber.php

示例15: getCustomerConversionValues

 /**
  * @param array $dateRange
  * @return int
  */
 public function getCustomerConversionValues($dateRange)
 {
     $result = 0;
     list($start, $end) = $this->dateHelper->getPeriod($dateRange, 'OroCRMMagentoBundle:Customer', 'createdAt');
     $customers = $this->doctrine->getRepository('OroCRMMagentoBundle:Customer')->getNewCustomersNumberWhoMadeOrderByPeriod($start, $end, $this->aclHelper);
     $visits = $this->doctrine->getRepository('OroCRMChannelBundle:Channel')->getVisitsCountByPeriodForChannelType($start, $end, $this->aclHelper, ChannelType::TYPE);
     if ($visits !== 0) {
         $result = $customers / $visits;
     }
     return $result;
 }
开发者ID:antrampa,项目名称:crm,代码行数:15,代码来源:MagentoBigNumberProvider.php


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