當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。