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


PHP DoctrineHelper::getEntity方法代码示例

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


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

示例1: getActivityContext

 /**
  * Returns the context for the given activity class and id
  *
  * @param string $class The FQCN of the activity entity
  * @param        $id
  *
  * @return array
  */
 public function getActivityContext($class, $id)
 {
     $currentUser = $this->securityTokenStorage->getToken()->getUser();
     $userClass = ClassUtils::getClass($currentUser);
     $entity = $this->doctrineHelper->getEntity($class, $id);
     $result = [];
     if (!$entity || !$entity instanceof ActivityInterface) {
         return $result;
     }
     $targets = $entity->getActivityTargetEntities();
     $entityProvider = $this->configManager->getProvider('entity');
     foreach ($targets as $target) {
         $targetClass = ClassUtils::getClass($target);
         $targetId = $target->getId();
         if ($userClass === $targetClass && $currentUser->getId() === $targetId) {
             continue;
         }
         $item = [];
         $config = $entityProvider->getConfig($targetClass);
         $safeClassName = $this->entityClassNameHelper->getUrlSafeClassName($targetClass);
         $item = $this->prepareItemTitle($item, $targetClass, $target, $targetId);
         $item['activityClassAlias'] = $this->entityAliasResolver->getPluralAlias($class);
         $item['entityId'] = $id;
         $item['targetId'] = $targetId;
         $item['targetClassName'] = $safeClassName;
         $item['icon'] = $config->get('icon');
         $item['link'] = $this->getContextLink($targetClass, $targetId);
         $item = $this->dispatchContextTitle($item, $targetClass);
         $result[] = $item;
     }
     return $result;
 }
开发者ID:woei66,项目名称:platform,代码行数:40,代码来源:ActivityContextApiEntityManager.php

示例2: process

 /**
  * Process email model sending.
  *
  * @param EmailModel $model
  * @return Email
  * @throws \Swift_SwiftException
  */
 public function process(EmailModel $model)
 {
     $this->assertModel($model);
     $messageDate = new \DateTime('now', new \DateTimeZone('UTC'));
     /** @var \Swift_Message $message */
     $message = $this->mailer->createMessage();
     $message->setDate($messageDate->getTimestamp());
     $message->setFrom($this->getAddresses($model->getFrom()));
     $message->setTo($this->getAddresses($model->getTo()));
     $message->setSubject($model->getSubject());
     $message->setBody($model->getBody(), $model->getType() === 'html' ? 'text/html' : 'text/plain');
     $messageId = $message->generateId();
     if (!$this->mailer->send($message)) {
         throw new \Swift_SwiftException('An email was not delivered.');
     }
     $origin = $this->getEmailOrigin($model->getFrom());
     $this->emailEntityBuilder->setOrigin($origin);
     $email = $this->emailEntityBuilder->email($model->getSubject(), $model->getFrom(), $model->getTo(), $messageDate, $messageDate, $messageDate);
     $email->addFolder($origin->getFolder(FolderType::SENT));
     $email->setEmailBody($this->emailEntityBuilder->body($model->getBody(), $model->getType() === 'html', true));
     $email->setMessageId($messageId);
     // persist the email and all related entities such as folders, email addresses etc.
     $this->emailEntityBuilder->getBatch()->persist($this->getEntityManager());
     // associate the email with the target entity if exist
     if ($model->hasEntity()) {
         $targetEntity = $this->doctrineHelper->getEntity($model->getEntityClass(), $model->getEntityId());
         if ($targetEntity) {
             $this->emailActivityManager->addAssociation($email, $targetEntity);
         }
     }
     // flush all changes to the database
     $this->getEntityManager()->flush();
     return $email;
 }
开发者ID:xamin123,项目名称:platform,代码行数:41,代码来源:Processor.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: prepareEmailContextTitleEvent

 /**
  * Correct link and title for email context by EmailUser entity index
  *
  * @param PrepareContextTitleEvent $event
  */
 public function prepareEmailContextTitleEvent(PrepareContextTitleEvent $event)
 {
     if ($event->getTargetClass() === Email::ENTITY_CLASS) {
         $item = $event->getItem();
         /** @var Email $email */
         $email = $this->doctrineHelper->getEntity(Email::ENTITY_CLASS, $item['targetId']);
         $item['title'] = $email->getSubject();
         $item['link'] = $this->router->generate('oro_email_thread_view', ['id' => $item['targetId']], true);
         $event->setItem($item);
     }
 }
开发者ID:ramunasd,项目名称:platform,代码行数:16,代码来源:PrepareContextTitleListener.php

示例5: prepareIdsForEmailThreadEvent

 /**
  * Add email thread ids to qb params
  *
  * @param ActivityListPreQueryBuildEvent $event
  */
 public function prepareIdsForEmailThreadEvent(ActivityListPreQueryBuildEvent $event)
 {
     if ($event->getTargetClass() === Email::ENTITY_CLASS) {
         /** @var Email $email */
         $email = $this->doctrineHelper->getEntity(Email::ENTITY_CLASS, $event->getTargetId());
         if ($email->getThread()) {
             $emailIds = array_map(function ($emailEntity) {
                 return $emailEntity->getId();
             }, $email->getThread()->getEmails()->toArray());
             $event->setTargetIds($emailIds);
         }
     }
 }
开发者ID:ramunasd,项目名称:platform,代码行数:18,代码来源:ActivityListPreQueryBuildListener.php

示例6: getResult

 /**
  * @param object $entity
  * @param string $resultType
  * @param string $scope
  * @return NavigationResult
  */
 protected function getResult($entity, $resultType, $scope = EntityPaginationManager::VIEW_SCOPE)
 {
     $result = new NavigationResult();
     if ($this->storage->isEnvironmentValid() && $this->storage->isEntityInStorage($entity, $scope)) {
         $entityName = ClassUtils::getClass($entity);
         if ($this->isIdentifierMatched($entity, $resultType, $scope)) {
             do {
                 $identifier = $this->getProcessedIdentifier($entity, $resultType, $scope);
                 if (!$identifier) {
                     break;
                 }
                 $navigationEntity = $this->doctrineHelper->getEntity($entityName, $identifier);
                 $permission = EntityPaginationManager::getPermission($scope);
                 if (!$navigationEntity) {
                     $this->storage->unsetIdentifier($identifier, $entity, $scope);
                     $result->setAvailable(false);
                 } elseif (!$this->securityFacade->isGranted($permission, $navigationEntity)) {
                     $this->storage->unsetIdentifier($identifier, $entity, $scope);
                     $result->setAccessible(false);
                 }
             } while (!$navigationEntity || !$this->securityFacade->isGranted($permission, $navigationEntity));
             $result->setId($identifier);
         }
     }
     return $result;
 }
开发者ID:Maksold,项目名称:platform,代码行数:32,代码来源:EntityPaginationNavigation.php

示例7: getActivityContext

 /**
  * Returns the context for the given activity class and id
  *
  * @param string $class The FQCN of the activity entity
  * @param        $id
  *
  * @return array
  */
 public function getActivityContext($class, $id)
 {
     $currentUser = $this->securityTokenStorage->getToken()->getUser();
     $userClass = ClassUtils::getClass($currentUser);
     $entity = $this->doctrineHelper->getEntity($class, $id);
     $result = [];
     if (!$entity || !$entity instanceof ActivityInterface) {
         return $result;
     }
     $targets = $entity->getActivityTargetEntities();
     $entityProvider = $this->configManager->getProvider('entity');
     foreach ($targets as $target) {
         $targetClass = ClassUtils::getClass($target);
         $targetId = $target->getId();
         if ($userClass === $targetClass && $currentUser->getId() === $targetId) {
             continue;
         }
         $item = [];
         $config = $entityProvider->getConfig($targetClass);
         $metadata = $this->configManager->getEntityMetadata($targetClass);
         $safeClassName = $this->entityClassNameHelper->getUrlSafeClassName($targetClass);
         $link = null;
         if ($metadata) {
             $link = $this->router->generate($metadata->getRoute(), ['id' => $targetId]);
         } elseif ($link === null && ExtendHelper::isCustomEntity($targetClass)) {
             // Generate view link for the custom entity
             $link = $this->router->generate('oro_entity_view', ['id' => $targetId, 'entityName' => $safeClassName]);
         }
         if ($fields = $this->mapper->getEntityMapParameter($targetClass, 'title_fields')) {
             $text = [];
             foreach ($fields as $field) {
                 $text[] = $this->mapper->getFieldValue($target, $field);
             }
             $item['title'] = implode(' ', $text);
         } else {
             $item['title'] = $this->translator->trans('oro.entity.item', ['%id%' => $targetId]);
         }
         $item['activityClassAlias'] = $this->entityAliasResolver->getPluralAlias($class);
         $item['entityId'] = $id;
         $item['targetId'] = $targetId;
         $item['targetClassName'] = $safeClassName;
         $item['icon'] = $config->get('icon');
         $item['link'] = $link;
         $result[] = $item;
     }
     return $result;
 }
开发者ID:Maksold,项目名称:platform,代码行数:55,代码来源:ActivityContextApiEntityManager.php

示例8: getActivityContext

 /**
  * Returns the context for the given activity class and id
  *
  * @param string $class The FQCN of the activity entity
  * @param        $id
  *
  * @return array
  */
 public function getActivityContext($class, $id)
 {
     $currentUser = $this->securityTokenStorage->getToken()->getUser();
     $userClass = ClassUtils::getClass($currentUser);
     $entity = $this->doctrineHelper->getEntity($class, $id);
     $result = [];
     if (!$entity || !$entity instanceof ActivityInterface) {
         return $result;
     }
     $targets = $entity->getActivityTargetEntities();
     $entityProvider = $this->configManager->getProvider('entity');
     foreach ($targets as $target) {
         $targetClass = ClassUtils::getClass($target);
         $targetId = $target->getId();
         if ($userClass === $targetClass && $currentUser->getId() === $targetId) {
             continue;
         }
         $item = [];
         $config = $entityProvider->getConfig($targetClass);
         $safeClassName = $this->entityClassNameHelper->getUrlSafeClassName($targetClass);
         if (!array_key_exists('title', $item) || !$item['title']) {
             if ($fields = $this->mapper->getEntityMapParameter($targetClass, 'title_fields')) {
                 $text = [];
                 foreach ($fields as $field) {
                     $text[] = $this->mapper->getFieldValue($target, $field);
                 }
                 $item['title'] = implode(' ', $text);
             } else {
                 $item['title'] = $this->translator->trans('oro.entity.item', ['%id%' => $targetId]);
             }
         }
         $item['activityClassAlias'] = $this->entityAliasResolver->getPluralAlias($class);
         $item['entityId'] = $id;
         $item['targetId'] = $targetId;
         $item['targetClassName'] = $safeClassName;
         $item['icon'] = $config->get('icon');
         $item['link'] = $this->getContextLink($targetClass, $targetId);
         $event = new PrepareContextTitleEvent($item, $targetClass);
         $this->dispatcher->dispatch(PrepareContextTitleEvent::EVENT_NAME, $event);
         $item = $event->getItem();
         $result[] = $item;
     }
     return $result;
 }
开发者ID:ramunasd,项目名称:platform,代码行数:52,代码来源:ActivityContextApiEntityManager.php

示例9: testGetEntity

 public function testGetEntity()
 {
     $expectedResult = new TestEntity();
     $entityClass = 'MockEntity';
     $entityId = 100;
     $repo = $this->getMockBuilder('Doctrine\\ORM\\EntityRepository')->disableOriginalConstructor()->getMock();
     $repo->expects($this->once())->method('find')->with($entityId)->will($this->returnValue($expectedResult));
     $this->em->expects($this->once())->method('getRepository')->with($entityClass)->will($this->returnValue($repo));
     $this->registry->expects($this->any())->method('getManagerForClass')->with($entityClass)->will($this->returnValue($this->em));
     $this->assertSame($expectedResult, $this->doctrineHelper->getEntity($entityClass, $entityId));
 }
开发者ID:xamin123,项目名称:platform,代码行数:11,代码来源:DoctrineHelperTest.php

示例10: getRelatedActivityEntities

 /**
  * @param ActivityList $entity
  * @param object       $entityProvider
  *
  * @return array
  */
 protected function getRelatedActivityEntities(ActivityList $entity, $entityProvider)
 {
     $relatedActivityEntities = [$entity];
     if ($this->isGroupingApplicable($entityProvider)) {
         $relationEntity = $this->doctrineHelper->getEntity($entity->getRelatedActivityClass(), $entity->getRelatedActivityId());
         $relatedActivityEntities = $entityProvider->getGroupedEntities($relationEntity);
         if (count($relatedActivityEntities) === 0) {
             $relatedActivityEntities = [$entity];
         }
     }
     return $relatedActivityEntities;
 }
开发者ID:northdakota,项目名称:platform,代码行数:18,代码来源:ActivityListManager.php

示例11: getEntity

 /**
  * Returns the entity object by its class name and id
  *
  * @param string $entityClass The class name. Also the _ char can be used instead of \
  * @param mixed  $entityId    The object id
  *
  * @return object The entity object
  *
  * @throws BadRequestHttpException
  * @throws NotFoundHttpException
  */
 public function getEntity($entityClass, $entityId)
 {
     $entityClass = $this->decodeClassName($entityClass);
     $entity = null;
     try {
         $entity = $this->doctrineHelper->getEntity($entityClass, $entityId);
     } catch (NotManageableEntityException $e) {
         throw new BadRequestHttpException($e->getMessage(), $e);
     }
     if (!$entity) {
         throw new NotFoundHttpException(sprintf('The entity "%s" with ID "%s" was not found.', $entityClass, $entityId));
     }
     return $entity;
 }
开发者ID:xamin123,项目名称:platform,代码行数:25,代码来源:EntityRoutingHelper.php

示例12: find

 /**
  * @param string $entityName
  * @param int|string $identifier
  * @return object|null
  */
 public function find($entityName, $identifier)
 {
     $entity = $this->doctrineHelper->getEntity($entityName, $identifier);
     if ($entity && $this->shouldBeAddedOrganizationLimits($entityName)) {
         $ownershipMetadataProvider = $this->ownershipMetadataProviderLink->getService();
         $organizationField = $ownershipMetadataProvider->getMetadata($entityName)->getOrganizationFieldName();
         /** @var FieldHelper $fieldHelper */
         $fieldHelper = $this->fieldHelperLink->getService();
         $entityOrganization = $fieldHelper->getObjectValue($entity, $organizationField);
         if (!$entityOrganization || $entityOrganization->getId() !== $this->securityFacadeLink->getService()->getOrganizationId()) {
             return null;
         }
     }
     return $entity;
 }
开发者ID:northdakota,项目名称:platform,代码行数:20,代码来源:DatabaseHelper.php

示例13: find

 /**
  * @param string $entityName
  * @param int|string $identifier
  * @return object|null
  */
 public function find($entityName, $identifier)
 {
     $storageKey = $this->getStorageKey([$this->doctrineHelper->getSingleEntityIdentifierFieldName($entityName) => $identifier]);
     if (!empty($this->entities[$entityName][$storageKey])) {
         return $this->entities[$entityName][$storageKey];
     }
     $entity = $this->doctrineHelper->getEntity($entityName, $identifier);
     if ($entity && $this->shouldBeAddedOrganizationLimits($entityName)) {
         $ownershipMetadataProvider = $this->ownershipMetadataProviderLink->getService();
         $organizationField = $ownershipMetadataProvider->getMetadata($entityName)->getOrganizationFieldName();
         /** @var FieldHelper $fieldHelper */
         $fieldHelper = $this->fieldHelperLink->getService();
         $entityOrganization = $fieldHelper->getObjectValue($entity, $organizationField);
         if (!$entityOrganization || $entityOrganization->getId() !== $this->securityFacadeLink->getService()->getOrganizationId()) {
             return null;
         }
     }
     $this->entities[$entityName][$storageKey] = $entity;
     return $entity;
 }
开发者ID:startupz,项目名称:platform-1,代码行数:25,代码来源:DatabaseHelper.php

示例14: reloadEntity

 /**
  * @param object $entity
  * @return Integration
  */
 protected function reloadEntity($entity)
 {
     return $this->doctrineHelper->getEntity($this->doctrineHelper->getEntityClass($entity), $this->doctrineHelper->getEntityIdentifier($entity));
 }
开发者ID:antrampa,项目名称:crm,代码行数:8,代码来源:InitialScheduleProcessor.php

示例15: find

 /**
  * @param string $entityName
  * @param int|string $identifier
  * @return object|null
  */
 public function find($entityName, $identifier)
 {
     return $this->doctrineHelper->getEntity($entityName, $identifier);
 }
开发者ID:xamin123,项目名称:platform,代码行数:9,代码来源:DatabaseHelper.php


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