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


PHP ORM\DoctrineHelper类代码示例

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


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

示例1: getChoices

 /**
  * {@inheritdoc}
  */
 protected function getChoices($entityName, $withRelations, $withVirtualFields)
 {
     $choiceFields = [];
     $choiceRelations = [];
     $idFieldNames = $this->doctrineHelper->getEntityIdentifierFieldNames($entityName);
     foreach ($this->getEntityFields($entityName, $withRelations, $withVirtualFields) as $fieldName => $field) {
         $formConfig = $this->formConfigProvider->getConfig($entityName, $fieldName);
         if ($formConfig->is('is_enabled', false) || in_array($fieldName, $idFieldNames)) {
             // field is not enabled for displaying in forms
             // or field is entity identifier
             continue;
         }
         if (!isset($field['relation_type'])) {
             $choiceFields[$fieldName] = $field['label'];
         } elseif (!in_array($field['relation_type'], RelationType::$toManyRelations)) {
             // enable only mass update for *-to-one relations
             $choiceRelations[$fieldName] = $field['label'];
         }
     }
     if (empty($choiceRelations)) {
         return $choiceFields;
     }
     $choices = [];
     if (!empty($choiceFields)) {
         $choices[$this->translator->trans('oro.entity.form.entity_fields')] = $choiceFields;
     }
     $choices[$this->translator->trans('oro.entity.form.entity_related')] = $choiceRelations;
     return $choices;
 }
开发者ID:trustify,项目名称:oroplatform-mass-update-bundle,代码行数:32,代码来源:UpdateFieldChoiceType.php

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

示例3: onBuildAfter

 /**
  * @param BuildAfter $event
  */
 public function onBuildAfter(BuildAfter $event)
 {
     /** @var OrmDatasource $dataSource */
     $datagrid = $event->getDatagrid();
     $config = $datagrid->getConfig();
     $configParameters = $config->toArray();
     if (!array_key_exists('extended_entity_name', $configParameters) || !$configParameters['extended_entity_name']) {
         return;
     }
     $targetClass = $configParameters['extended_entity_name'];
     $parameters = $datagrid->getParameters();
     $dataSource = $datagrid->getDatasource();
     $queryBuilder = $dataSource->getQueryBuilder();
     $alias = current($queryBuilder->getDQLPart('from'))->getAlias();
     if ($dataSource instanceof OrmDatasource && $parameters->has('activityId') && $parameters->has('activityClass')) {
         $id = $parameters->get('activityId');
         $class = $parameters->get('activityClass');
         $entityClass = $this->entityClassNameHelper->resolveEntityClass($class, true);
         $entity = $this->doctrineHelper->getEntity($entityClass, $id);
         if ($entity && $entity instanceof ActivityInterface) {
             $targetsArray = $entity->getActivityTargets($targetClass);
             $targetIds = [];
             foreach ($targetsArray as $target) {
                 $targetIds[] = $target->getId();
             }
             if ($targetIds) {
                 $queryBuilder->andWhere($queryBuilder->expr()->notIn(sprintf('%s.id', $alias), $targetIds));
             }
         }
     }
 }
开发者ID:ramunasd,项目名称:platform,代码行数:34,代码来源:ContextGridListener.php

示例4: onFlush

 /**
  * Collect activities changes
  *
  * @param OnFlushEventArgs $args
  */
 public function onFlush(OnFlushEventArgs $args)
 {
     $entitiesToDelete = $args->getEntityManager()->getUnitOfWork()->getScheduledEntityDeletions();
     $entitiesToUpdate = $args->getEntityManager()->getUnitOfWork()->getScheduledEntityUpdates();
     if (!empty($entitiesToDelete) || !empty($entitiesToUpdate)) {
         foreach ($entitiesToDelete as $entity) {
             $class = $this->doctrineHelper->getEntityClass($entity);
             $id = $this->doctrineHelper->getSingleEntityIdentifier($entity);
             $key = $class . '_' . $id;
             if ($this->activityContactProvider->isSupportedEntity($class) && !isset($this->deletedEntities[$key])) {
                 $targets = $entity->getActivityTargetEntities();
                 $targetsInfo = [];
                 foreach ($targets as $target) {
                     $targetsInfo[] = ['class' => $this->doctrineHelper->getEntityClass($target), 'id' => $this->doctrineHelper->getSingleEntityIdentifier($target), 'direction' => $this->activityContactProvider->getActivityDirection($entity, $target)];
                 }
                 $this->deletedEntities[$key] = ['class' => $class, 'id' => $id, 'contactDate' => $this->activityContactProvider->getActivityDate($entity), 'targets' => $targetsInfo];
             }
         }
         foreach ($entitiesToUpdate as $entity) {
             $class = $this->doctrineHelper->getEntityClass($entity);
             $id = $this->doctrineHelper->getSingleEntityIdentifier($entity);
             $key = $class . '_' . $id;
             if ($this->activityContactProvider->isSupportedEntity($class) && !isset($this->updatedEntities[$key])) {
                 $changes = $args->getEntityManager()->getUnitOfWork()->getEntityChangeSet($entity);
                 $isDirectionChanged = $this->activityContactProvider->getActivityDirectionProvider($entity)->isDirectionChanged($changes);
                 $targets = $entity->getActivityTargetEntities();
                 $targetsInfo = [];
                 foreach ($targets as $target) {
                     $targetsInfo[] = ['class' => $this->doctrineHelper->getEntityClass($target), 'id' => $this->doctrineHelper->getSingleEntityIdentifier($target), 'direction' => $this->activityContactProvider->getActivityDirection($entity, $target), 'is_direction_changed' => $isDirectionChanged];
                 }
                 $this->updatedEntities[$key] = ['class' => $class, 'id' => $id, 'contactDate' => $this->activityContactProvider->getActivityDate($entity), 'targets' => $targetsInfo];
             }
         }
     }
 }
开发者ID:antrampa,项目名称:crm,代码行数:40,代码来源:ActivityListener.php

示例5: isAttachmentAssociationEnabled

 /**
  * Delegated method
  *
  * @param object $entity
  * @return bool
  */
 public function isAttachmentAssociationEnabled($entity)
 {
     if (!is_object($entity) || !$this->doctrineHelper->isManageableEntity($entity) || $this->doctrineHelper->isNewEntity($entity)) {
         return false;
     }
     return $this->config->isAttachmentAssociationEnabled($entity);
 }
开发者ID:Maksold,项目名称:platform,代码行数:13,代码来源:PlaceholderFilter.php

示例6: createSubordinateIterator

 /**
  * @param StaticSegment $staticSegment
  *
  * {@inheritdoc}
  */
 protected function createSubordinateIterator($staticSegment)
 {
     $this->assertRequiredDependencies();
     if (!$staticSegment->getExtendedMergeVars()) {
         return new \EmptyIterator();
     }
     $qb = $this->getIteratorQueryBuilder($staticSegment);
     $marketingList = $staticSegment->getMarketingList();
     $memberIdentifier = MarketingListQueryBuilderAdapter::MEMBER_ALIAS . '.id';
     $fieldExpr = $this->fieldHelper->getFieldExpr($marketingList->getEntity(), $qb, $this->doctrineHelper->getSingleEntityIdentifierFieldName($marketingList->getEntity()));
     $qb->addSelect($fieldExpr . ' AS entity_id');
     $qb->addSelect($memberIdentifier . ' AS member_id');
     $qb->andWhere($qb->expr()->andX($qb->expr()->isNotNull($memberIdentifier)));
     $bufferedIterator = new BufferedQueryResultIterator($qb);
     $bufferedIterator->setHydrationMode(AbstractQuery::HYDRATE_ARRAY)->setReverse(true);
     $uniqueMembers =& $this->uniqueMembers;
     return new \CallbackFilterIterator($bufferedIterator, function (&$current) use($staticSegment, &$uniqueMembers) {
         if (is_array($current)) {
             if (!empty($current['member_id']) && in_array($current['member_id'], $uniqueMembers, true)) {
                 return false;
             }
             $current['subscribersList_id'] = $staticSegment->getSubscribersList()->getId();
             $current['static_segment_id'] = $staticSegment->getId();
             $uniqueMembers[] = $current['member_id'];
             unset($current['id']);
         }
         return true;
     });
 }
开发者ID:aculvi,项目名称:OroCRMMailChimpBundle,代码行数:34,代码来源:MmbrExtdMergeVarIterator.php

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

示例8: testMerge

 public function testMerge()
 {
     $account1 = new User();
     $account2 = new User();
     $this->setId($account1, 1);
     $this->setId($account2, 2);
     $entityMetadata = new EntityMetadata(['type' => ClassUtils::getRealClass($account1)]);
     $entityData = new EntityData($entityMetadata, [$account1, $account2]);
     $entityData->setMasterEntity($account1);
     $fieldData = new FieldData($entityData, new FieldMetadata());
     $fieldData->setMode(MergeModes::NOTES_REPLACE);
     $fieldData->setSourceEntity($account2);
     $queryBuilder = $this->getMockBuilder('Doctrine\\ORM\\QueryBuilder')->disableOriginalConstructor()->setMethods(['getQuery', 'getResult'])->getMock();
     $queryBuilder->expects($this->any())->method('getQuery')->will($this->returnSelf());
     $queryBuilder->expects($this->any())->method('getResult')->will($this->returnValue([new ExtendNote()]));
     $repository = $this->getMockBuilder('Oro\\Bundle\\ActivityListBundle\\Entity\\Repository\\ActivityListRepository')->disableOriginalConstructor()->setMethods(['getBaseAssociatedNotesQB', 'getActivityListQueryBuilderByActivityClass'])->getMock();
     $repository->expects($this->any())->method('getBaseAssociatedNotesQB')->willReturn($queryBuilder);
     $activityQueryBuilder = $this->getMockBuilder('Doctrine\\ORM\\QueryBuilder')->disableOriginalConstructor()->setMethods(['getQuery', 'getResult'])->getMock();
     $activityQueryBuilder->expects($this->any())->method('getQuery')->will($this->returnSelf());
     $activityQueryBuilder->expects($this->any())->method('getResult')->will($this->returnValue([['id' => 1, 'relatedActivityId' => 11], ['id' => 3, 'relatedActivityId' => 2]]));
     $repository->expects($this->any())->method('getActivityListQueryBuilderByActivityClass')->willReturn($activityQueryBuilder);
     $entityManager = $this->getMockBuilder('Doctrine\\ORM\\EntityManager')->disableOriginalConstructor()->setMethods(['remove'])->getMock();
     $this->doctrineHelper->expects($this->any())->method('getEntityRepository')->willReturn($repository);
     $this->doctrineHelper->expects($this->any())->method('getEntityManager')->willReturn($entityManager);
     $this->activityListManager->expects($this->once())->method('replaceActivityTargetWithPlainQuery');
     $this->strategy->merge($fieldData);
 }
开发者ID:startupz,项目名称:platform-1,代码行数:27,代码来源:ReplaceStrategyTest.php

示例9: getStatisticsRecord

 /**
  * @param EmailCampaign $emailCampaign
  * @param object  $entity
  * @return EmailCampaignStatistics
  */
 public function getStatisticsRecord(EmailCampaign $emailCampaign, $entity)
 {
     $marketingList = $emailCampaign->getMarketingList();
     $entityId = $this->doctrineHelper->getSingleEntityIdentifier($entity);
     /**
      * Cache was added because there is a case:
      * - 2 email campaigns linked to one marketing list
      * - statistic can created using batches (marketing list item connector will be used)
      *  and flush will be run once per N records creation
      * in this case same Marketing list entity will be received twice for one marketing list
      * and new MarketingListItem for same $marketingList and $entityId will be persisted twice.
      *
      * Marketing list name used as key for cache because Id can be empty and name is unique
      *
      */
     if (empty($this->marketingListItemCache[$marketingList->getName()][$entityId])) {
         // Mark marketing list item as contacted
         $this->marketingListItemCache[$marketingList->getName()][$entityId] = $this->marketingListItemConnector->getMarketingListItem($marketingList, $entityId);
     }
     /** @var MarketingListItem $marketingListItem */
     $marketingListItem = $this->marketingListItemCache[$marketingList->getName()][$entityId];
     $manager = $this->doctrineHelper->getEntityManager($this->entityName);
     $statisticsRecord = null;
     if ($marketingListItem->getId() !== null) {
         $statisticsRecord = $manager->getRepository($this->entityName)->findOneBy(['emailCampaign' => $emailCampaign, 'marketingListItem' => $marketingListItem]);
     }
     if (!$statisticsRecord) {
         $statisticsRecord = new EmailCampaignStatistics();
         $statisticsRecord->setEmailCampaign($emailCampaign)->setMarketingListItem($marketingListItem)->setOwner($emailCampaign->getOwner())->setOrganization($emailCampaign->getOrganization());
         $manager->persist($statisticsRecord);
     }
     return $statisticsRecord;
 }
开发者ID:antrampa,项目名称:crm,代码行数:38,代码来源:EmailCampaignStatisticsConnector.php

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

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

示例12: isApplicable

 /**
  * Checks if the entity can have comments
  *
  * @param object|null $entity
  *
  * @return bool
  */
 public function isApplicable($entity)
 {
     if (!is_object($entity) || !$this->doctrineHelper->isManageableEntity($entity) || !$this->securityFacade->isGranted('oro_comment_view')) {
         return false;
     }
     return $this->commentAssociationHelper->isCommentAssociationEnabled(ClassUtils::getClass($entity));
 }
开发者ID:olegpopadko,项目名称:platform,代码行数:14,代码来源:CommentPlaceholderFilter.php

示例13: getDirection

 /**
  * {@inheritdoc}
  */
 public function getDirection($activity, $target)
 {
     //check if target is entity created from admin part
     if (!$target instanceof EmailHolderInterface) {
         $metadata = $this->doctrineHelper->getEntityMetadata($target);
         $columns = $metadata->getColumnNames();
         $className = get_class($target);
         foreach ($columns as $column) {
             //check only columns with 'contact_information'
             if ($this->isEmailType($className, $column)) {
                 $getMethodName = "get" . Inflector::classify($column);
                 /** @var $activity Email */
                 if ($activity->getFromEmailAddress()->getEmail() === $target->{$getMethodName}()) {
                     return DirectionProviderInterface::DIRECTION_OUTGOING;
                 } else {
                     foreach ($activity->getTo() as $recipient) {
                         if ($recipient->getEmailAddress()->getEmail() === $target->{$getMethodName}()) {
                             return DirectionProviderInterface::DIRECTION_INCOMING;
                         }
                     }
                 }
             }
         }
         return DirectionProviderInterface::DIRECTION_UNKNOWN;
     }
     /** @var $activity Email */
     /** @var $target EmailHolderInterface */
     if ($activity->getFromEmailAddress()->getEmail() === $target->getEmail()) {
         return DirectionProviderInterface::DIRECTION_OUTGOING;
     }
     return DirectionProviderInterface::DIRECTION_INCOMING;
 }
开发者ID:antrampa,项目名称:crm,代码行数:35,代码来源:EmailDirectionProvider.php

示例14: testIncrementSku

 /**
  * @dataProvider skuDataProvider
  * @param string[] $existingSku
  * @param array $testCases
  */
 public function testIncrementSku(array $existingSku, array $testCases)
 {
     $this->doctrineHelper->expects($this->any())->method('getEntityRepository')->with(self::PRODUCT_CLASS)->willReturn($this->getProductRepositoryMock($existingSku));
     foreach ($testCases as $expected => $sku) {
         $this->assertEquals($expected, $this->service->increment($sku));
     }
 }
开发者ID:hafeez3000,项目名称:orocommerce,代码行数:12,代码来源:SkuIncrementorTest.php

示例15: isNoteAssociationEnabled

 /**
  * Checks if the entity can has notes
  *
  * @param object $entity
  * @return bool
  */
 public function isNoteAssociationEnabled($entity)
 {
     if (!is_object($entity) || !$this->doctrineHelper->isManageableEntity($entity) || $this->doctrineHelper->isNewEntity($entity)) {
         return false;
     }
     return $this->noteAssociationHelper->isNoteAssociationEnabled(ClassUtils::getClass($entity));
 }
开发者ID:snorchel,项目名称:platform,代码行数:13,代码来源:PlaceholderFilter.php


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