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


PHP DoctrineHelper::getEntityRepository方法代码示例

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


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

示例1: discoverSimilar

 /**
  * @param object $entity
  * @return object|null
  */
 public function discoverSimilar($entity)
 {
     if (!$this->configuration) {
         return null;
     }
     $idName = $this->doctrineHelper->getSingleEntityIdentifierFieldName($this->discoveryEntityClass);
     $idFieldName = self::ROOT_ALIAS . '.' . $idName;
     /** @var EntityRepository $repository */
     $repository = $this->doctrineHelper->getEntityRepository($this->discoveryEntityClass);
     $qb = $repository->createQueryBuilder(self::ROOT_ALIAS)->select(self::ROOT_ALIAS);
     // Apply search strategies
     $this->applyStrategies($qb, $entity);
     // Apply matcher strategy
     if ($this->configuration[Configuration::DISCOVERY_OPTIONS_KEY][Configuration::DISCOVERY_MATCH_KEY] === Configuration::DISCOVERY_MATCH_LATEST) {
         $qb->orderBy($idFieldName, Criteria::DESC);
     }
     // Skip current entity
     $id = $this->doctrineHelper->getSingleEntityIdentifier($entity);
     if (!empty($id)) {
         $idParameter = ':' . $idName;
         $qb->andWhere($qb->expr()->neq($idFieldName, $idParameter))->setParameter($idParameter, $id);
     }
     // Add organization limits
     $organizationField = $this->ownershipMetadata->getMetadata(ClassUtils::getClass($entity))->getOrganizationFieldName();
     if ($organizationField) {
         $propertyAccessor = PropertyAccess::createPropertyAccessor();
         $organization = $propertyAccessor->getValue($entity, $organizationField);
         $qb->andWhere(sprintf('%s.%s = :organization', self::ROOT_ALIAS, $organizationField))->setParameter('organization', $organization);
     }
     // Get only 1 match
     $qb->setMaxResults(1);
     return $qb->getQuery()->getOneOrNullResult();
 }
开发者ID:antrampa,项目名称:crm,代码行数:37,代码来源:AutomaticDiscovery.php

示例2: merge

 /**
  * {@inheritdoc}
  */
 public function merge(FieldData $fieldData)
 {
     $entityData = $fieldData->getEntityData();
     $masterEntity = $entityData->getMasterEntity();
     $sourceEntity = $fieldData->getSourceEntity();
     if ($masterEntity->getId() !== $sourceEntity->getId()) {
         $queryBuilder = $this->doctrineHelper->getEntityRepository('OroNoteBundle:Note')->getBaseAssociatedNotesQB(ClassUtils::getRealClass($masterEntity), $masterEntity->getId());
         $notes = $queryBuilder->getQuery()->getResult();
         if (!empty($notes)) {
             $entityManager = $this->doctrineHelper->getEntityManager(current($notes));
             foreach ($notes as $note) {
                 $entityManager->remove($note);
             }
         }
         $queryBuilder = $this->doctrineHelper->getEntityRepository('OroNoteBundle:Note')->getBaseAssociatedNotesQB(ClassUtils::getRealClass($masterEntity), $sourceEntity->getId());
         $notes = $queryBuilder->getQuery()->getResult();
         if (!empty($notes)) {
             foreach ($notes as $note) {
                 $note->setTarget($masterEntity);
             }
         }
         $fieldMetadata = $fieldData->getMetadata();
         $activityClass = $fieldMetadata->get('type');
         $entityClass = ClassUtils::getRealClass($sourceEntity);
         $queryBuilder = $this->doctrineHelper->getEntityRepository(ActivityList::ENTITY_NAME)->getActivityListQueryBuilderByActivityClass($entityClass, $sourceEntity->getId(), $activityClass);
         $activityListItems = $queryBuilder->getQuery()->getResult();
         $activityIds = ArrayUtils::arrayColumn($activityListItems, 'id');
         $this->activityListManager->replaceActivityTargetWithPlainQuery($activityIds, $entityClass, $sourceEntity->getId(), $masterEntity->getId());
     }
 }
开发者ID:Maksold,项目名称:platform,代码行数:33,代码来源:ReplaceStrategy.php

示例3: findOneBy

 /**
  * @param string $entityName
  * @param array $criteria
  * @return object|null
  */
 public function findOneBy($entityName, array $criteria)
 {
     $serializationCriteria = [];
     $where = [];
     foreach ($criteria as $field => $value) {
         if (is_object($value)) {
             $serializationCriteria[$field] = $this->getIdentifier($value);
         } else {
             $serializationCriteria[$field] = $value;
         }
         $where[] = sprintf('e.%s = :%s', $field, $field);
     }
     $storageKey = $this->getStorageKey($serializationCriteria);
     if (empty($this->entities[$entityName]) || empty($this->entities[$entityName][$storageKey])) {
         /** @var EntityRepository $entityRepository */
         $entityRepository = $this->doctrineHelper->getEntityRepository($entityName);
         $queryBuilder = $entityRepository->createQueryBuilder('e')->andWhere(implode(' AND ', $where))->setParameters($criteria)->setMaxResults(1);
         if ($this->shouldBeAddedOrganizationLimits($entityName)) {
             $ownershipMetadataProvider = $this->ownershipMetadataProviderLink->getService();
             $organizationField = $ownershipMetadataProvider->getMetadata($entityName)->getOrganizationFieldName();
             $queryBuilder->andWhere('e.' . $organizationField . ' = :organization')->setParameter('organization', $this->securityFacadeLink->getService()->getOrganization());
         }
         $this->entities[$entityName][$storageKey] = $queryBuilder->getQuery()->getOneOrNullResult();
     }
     return $this->entities[$entityName][$storageKey];
 }
开发者ID:startupz,项目名称:platform-1,代码行数:31,代码来源:DatabaseHelper.php

示例4: getCalendarEvents

 /**
  * {@inheritdoc}
  */
 public function getCalendarEvents($organizationId, $userId, $calendarId, $start, $end, $connections, $extraFields = [])
 {
     if (!$this->calendarConfig->isSystemCalendarEnabled() || !$this->securityFacade->isGranted('oro_system_calendar_view')) {
         return [];
     }
     //@TODO: temporary return all system calendars until BAP-6566 implemented
     ///** @var CalendarEventRepository $repo */
     //$repo = $this->doctrineHelper->getEntityRepository('OroCalendarBundle:CalendarEvent');
     //$qb = $repo->getSystemEventListByTimeIntervalQueryBuilder(
     //    $calendarId,
     //    $start,
     //    $end,
     //    []
     //);
     /** @var CalendarEventRepository $repo */
     $repo = $this->doctrineHelper->getEntityRepository('OroCalendarBundle:CalendarEvent');
     $qb = $repo->getSystemEventListByTimeIntervalQueryBuilder($start, $end, [], $extraFields)->andWhere('c.organization = :organizationId')->setParameter('organizationId', $organizationId);
     $invisibleIds = [];
     foreach ($connections as $id => $visible) {
         if (!$visible) {
             $invisibleIds[] = $id;
         }
     }
     if (!empty($invisibleIds)) {
         $qb->andWhere('c.id NOT IN (:invisibleIds)')->setParameter('invisibleIds', $invisibleIds);
     }
     return $this->calendarEventNormalizer->getCalendarEvents($calendarId, $qb->getQuery());
 }
开发者ID:northdakota,项目名称:platform,代码行数:31,代码来源:SystemCalendarProvider.php

示例5: applyAdditionalData

 /**
  * {@inheritdoc}
  */
 protected function applyAdditionalData(&$items, $calendarId)
 {
     $parentEventIds = $this->getParentEventIds($items);
     if (!empty($parentEventIds)) {
         /** @var CalendarEventRepository $repo */
         $repo = $this->doctrineHelper->getEntityRepository('OroCalendarBundle:CalendarEvent');
         $invitees = $repo->getInvitedUsersByParentsQueryBuilder($parentEventIds)->getQuery()->getArrayResult();
         $groupedInvitees = [];
         foreach ($invitees as $invitee) {
             $groupedInvitees[$invitee['parentEventId']][] = $invitee;
         }
         foreach ($items as &$item) {
             $item['invitedUsers'] = [];
             if (isset($groupedInvitees[$item['id']])) {
                 foreach ($groupedInvitees[$item['id']] as $invitee) {
                     $item['invitedUsers'][] = $invitee['userId'];
                 }
             }
         }
     } else {
         foreach ($items as &$item) {
             $item['invitedUsers'] = [];
         }
     }
 }
开发者ID:Maksold,项目名称:platform,代码行数:28,代码来源:UserCalendarEventNormalizer.php

示例6: onResultAfter

 /**
  * @param OrmResultAfter $event
  */
 public function onResultAfter(OrmResultAfter $event)
 {
     $currencies = $this->getCurrencies();
     if (!$currencies) {
         return;
     }
     /** @var ResultRecord[] $records */
     $records = $event->getRecords();
     $productIds = [];
     foreach ($records as $record) {
         $productIds[] = $record->getValue('id');
     }
     /** @var ProductPriceRepository $priceRepository */
     $priceRepository = $this->doctrineHelper->getEntityRepository('OroB2BPricingBundle:ProductPrice');
     $priceList = $this->getPriceList();
     $showTierPrices = $this->priceListRequestHandler->getShowTierPrices();
     $prices = $priceRepository->findByPriceListIdAndProductIds($priceList->getId(), $productIds, $showTierPrices);
     $groupedPrices = $this->groupPrices($prices);
     foreach ($records as $record) {
         $record->addData(['showTierPrices' => $showTierPrices]);
         $productId = $record->getValue('id');
         $priceContainer = [];
         foreach ($currencies as $currencyIsoCode) {
             $columnName = $this->buildColumnName($currencyIsoCode);
             if (isset($groupedPrices[$productId][$currencyIsoCode])) {
                 $priceContainer[$columnName] = $groupedPrices[$productId][$currencyIsoCode];
             } else {
                 $priceContainer[$columnName] = [];
             }
         }
         if ($priceContainer) {
             $record->addData($priceContainer);
         }
     }
 }
开发者ID:hafeez3000,项目名称:orocommerce,代码行数:38,代码来源:ProductPriceDatagridListener.php

示例7: getJob

 /**
  * @param string $args
  * @param array $states
  *
  * @return Job[]
  */
 public function getJob($args = null, array $states = [])
 {
     $qb = $this->doctrineHelper->getEntityRepository('JMSJobQueueBundle:Job')->createQueryBuilder('j');
     $qb->where($qb->expr()->andX($qb->expr()->eq('j.command', ':command'), $qb->expr()->in('j.state', ':states')))->setParameters(['command' => CalculateAnalyticsCommand::COMMAND_NAME, 'states' => $states ?: [Job::STATE_PENDING]]);
     if ($args) {
         $qb->andWhere($qb->expr()->like('cast(j.args as text)', ':args'))->setParameter('args', '%' . $args . '%');
     } else {
         $qb->andWhere($qb->expr()->notLike('cast(j.args as text)', ':args'))->setParameter('args', '%--channel%');
     }
     return $qb->getQuery()->getResult();
 }
开发者ID:antrampa,项目名称:crm,代码行数:17,代码来源:StateManager.php

示例8: getEnumChoices

 /**
  * @param string $enumClass = ExtendHelper::buildEnumValueClassName($enumCode);
  * @return array
  */
 public function getEnumChoices($enumClass)
 {
     /** @var EnumValueRepository $repository */
     $repository = $this->doctrineHelper->getEntityRepository($enumClass);
     $values = $repository->getValues();
     $result = [];
     /** @var AbstractEnumValue $enum */
     foreach ($values as $enum) {
         $result[$enum->getId()] = $enum->getName();
     }
     return $result;
 }
开发者ID:Maksold,项目名称:platform,代码行数:16,代码来源:EnumValueProvider.php

示例9: hasMarketingList

 /**
  * @param string $className
  * @return bool
  */
 public function hasMarketingList($className)
 {
     if (null === $this->marketingListByEntity) {
         $this->marketingListByEntity = [];
         $repository = $this->doctrineHelper->getEntityRepository('OroCRMMarketingListBundle:MarketingList');
         $qb = $repository->createQueryBuilder('ml')->select('ml.entity')->distinct(true);
         $entities = $qb->getQuery()->getArrayResult();
         foreach ($entities as $entity) {
             $this->marketingListByEntity[$entity['entity']] = true;
         }
     }
     return !empty($this->marketingListByEntity[$className]);
 }
开发者ID:antrampa,项目名称:crm,代码行数:17,代码来源:MarketingListVirtualRelationProvider.php

示例10: getRemoveAceQueryBuilder

 /**
  * {@inheritdoc}
  */
 public function getRemoveAceQueryBuilder(AclClass $aclClass, array $removeScopes)
 {
     $qb = $this->doctrineHelper->getEntityRepository('OroSecurityBundle:AclEntry')->createQueryBuilder('ae')->delete();
     $qb->where('ae.class = :class');
     $qbSub = $this->doctrineHelper->getEntityRepository('OroSecurityBundle:AclSecurityIdentity')->createQueryBuilder('asid')->select('asid.id');
     $exprOr = $qbSub->expr()->orX();
     foreach ($removeScopes as $scope) {
         $this->addExprByShareScope($qbSub, $exprOr, $scope);
     }
     $qbSub->where($exprOr);
     $qb->andWhere($qb->expr()->in('ae.securityIdentity', $qbSub->getDQL()))->setParameter('class', $aclClass);
     return $qb;
 }
开发者ID:kstupak,项目名称:platform,代码行数:16,代码来源:AceQueryManager.php

示例11: getCalendarEvents

 /**
  * {@inheritdoc}
  */
 public function getCalendarEvents($organizationId, $userId, $calendarId, $start, $end, $connections, $extraFields = [])
 {
     if (!$this->myTasksEnabled) {
         return [];
     }
     if ($this->isCalendarVisible($connections, self::MY_TASKS_CALENDAR_ID)) {
         /** @var TaskRepository $repo */
         $repo = $this->doctrineHelper->getEntityRepository('OroCRMTaskBundle:Task');
         $qb = $repo->getTaskListByTimeIntervalQueryBuilder($userId, $start, $end, $extraFields);
         $query = $this->aclHelper->apply($qb);
         return $this->taskCalendarNormalizer->getTasks(self::MY_TASKS_CALENDAR_ID, $query);
     }
     return [];
 }
开发者ID:rodolfobandeira,项目名称:crm,代码行数:17,代码来源:TaskCalendarProvider.php

示例12: onProductView

 /**
  * @param BeforeListRenderEvent $event
  */
 public function onProductView(BeforeListRenderEvent $event)
 {
     if (!$this->request) {
         return;
     }
     $productId = $this->request->get('id');
     /** @var Product $product */
     $product = $this->doctrineHelper->getEntityReference('OroB2BProductBundle:Product', $productId);
     /** @var CategoryRepository $repository */
     $repository = $this->doctrineHelper->getEntityRepository('OroB2BCatalogBundle:Category');
     $category = $repository->findOneByProduct($product);
     $template = $event->getEnvironment()->render('OroB2BCatalogBundle:Product:category_view.html.twig', ['entity' => $category]);
     $this->addCategoryBlock($event->getScrollData(), $template);
 }
开发者ID:hafeez3000,项目名称:orocommerce,代码行数:17,代码来源:FormViewListener.php

示例13: testGetEntityRepositoryNotManageableEntity

 public function testGetEntityRepositoryNotManageableEntity()
 {
     $class = 'ItemStubProxy';
     $this->setExpectedException('Oro\\Bundle\\EntityBundle\\Exception\\NotManageableEntityException', sprintf('Entity class "%s" is not manageable', $class));
     $this->registry->expects($this->once())->method('getManagerForClass')->with($class)->will($this->returnValue(null));
     $this->doctrineHelper->getEntityRepository($class);
 }
开发者ID:antrampa,项目名称:platform,代码行数:7,代码来源:DoctrineHelperTest.php

示例14: getProductRepository

 /**
  * @return ProductRepository
  */
 protected function getProductRepository()
 {
     if (!$this->productRepository) {
         $this->productRepository = $this->doctrineHelper->getEntityRepository($this->productClass);
     }
     return $this->productRepository;
 }
开发者ID:adam-paterson,项目名称:orocommerce,代码行数:10,代码来源:AbstractProductDataStorageExtension.php

示例15: getCategories

 /**
  * @param int $channelId
  * @param string $type
  *
  * @return RFMMetricCategory[]
  */
 protected function getCategories($channelId, $type)
 {
     if (array_key_exists($channelId, $this->categories) && array_key_exists($type, $this->categories[$channelId])) {
         return $this->categories[$channelId][$type];
     }
     $categories = $this->doctrineHelper->getEntityRepository('OroCRMAnalyticsBundle:RFMMetricCategory')->findBy(['channel' => $channelId, 'categoryType' => $type], ['categoryIndex' => Criteria::ASC]);
     $this->categories[$channelId][$type] = $categories;
     return $categories;
 }
开发者ID:antrampa,项目名称:crm,代码行数:15,代码来源:RFMBuilder.php


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