當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DoctrineHelper::getEntityClass方法代碼示例

本文整理匯總了PHP中Oro\Bundle\EntityBundle\ORM\DoctrineHelper::getEntityClass方法的典型用法代碼示例。如果您正苦於以下問題:PHP DoctrineHelper::getEntityClass方法的具體用法?PHP DoctrineHelper::getEntityClass怎麽用?PHP DoctrineHelper::getEntityClass使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Oro\Bundle\EntityBundle\ORM\DoctrineHelper的用法示例。


在下文中一共展示了DoctrineHelper::getEntityClass方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

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

示例2: validate

 /**
  * {@inheritdoc}
  */
 public function validate($entity, Constraint $constraint)
 {
     $className = $this->doctrineHelper->getEntityClass($entity);
     $organizationField = $this->metadataProvider->getMetadata($className)->getGlobalOwnerFieldName();
     if ($organizationField) {
         $constraint->fields = array_merge((array) $constraint->fields, [$organizationField]);
     }
     parent::validate($entity, $constraint);
 }
開發者ID:ramunasd,項目名稱:platform,代碼行數:12,代碼來源:OrganizationUniqueEntityValidator.php

示例3: isApplicable

 /**
  * Checks if the entity can have activities
  *
  * @param object|null $entity
  * @return bool
  */
 public function isApplicable($entity = null)
 {
     if (null === $entity || !is_object($entity)) {
         return false;
     }
     $entityClass = $this->doctrineHelper->getEntityClass($entity);
     $id = $this->doctrineHelper->getSingleEntityIdentifier($entity);
     $activityListRepo = $this->doctrine->getRepository('OroActivityListBundle:ActivityList');
     return in_array($entityClass, $this->activityListProvider->getTargetEntityClasses()) || (bool) $activityListRepo->getRecordsCountForTargetClassAndId($entityClass, $id);
 }
開發者ID:northdakota,項目名稱:platform,代碼行數:16,代碼來源:PlaceholderFilter.php

示例4: collectDeletedEntities

 /**
  * We should collect here id's because after flush, object has no id
  *
  * @param $entities
  */
 protected function collectDeletedEntities($entities)
 {
     if (!empty($entities)) {
         foreach ($entities as $hash => $entity) {
             if ($this->activityListManager->isSupportedEntity($entity) && empty($this->deletedEntities[$hash])) {
                 $this->deletedEntities[$hash] = ['class' => $this->doctrineHelper->getEntityClass($entity), 'id' => $this->doctrineHelper->getSingleEntityIdentifier($entity)];
             }
         }
     }
 }
開發者ID:nmallare,項目名稱:platform,代碼行數:15,代碼來源:ActivityListListener.php

示例5: isApplicable

 /**
  * Checks if the entity can have activities
  *
  * @param object|null $entity
  * @param int|null    $pageType
  * @return bool
  */
 public function isApplicable($entity = null, $pageType = null)
 {
     if ($pageType === null || !is_object($entity) || !$this->doctrineHelper->isManageableEntity($entity) || $this->doctrineHelper->isNewEntity($entity)) {
         return false;
     }
     $pageType = (int) $pageType;
     $id = $this->doctrineHelper->getSingleEntityIdentifier($entity);
     $entityClass = $this->doctrineHelper->getEntityClass($entity);
     $activityListRepo = $this->doctrine->getRepository('OroActivityListBundle:ActivityList');
     return $this->isAllowedOnPage($entity, $pageType) && (in_array($entityClass, $this->activityListProvider->getTargetEntityClasses()) || (bool) $activityListRepo->getRecordsCountForTargetClassAndId($entityClass, $id));
 }
開發者ID:Maksold,項目名稱:platform,代碼行數:18,代碼來源:PlaceholderFilter.php

示例6: isConditionAllowed

 /**
  * Check ACL for resource.
  *
  * @param mixed $context
  * @return boolean
  */
 protected function isConditionAllowed($context)
 {
     $attributes = $this->contextAccessor->getValue($context, $this->attributes);
     $objectOrClass = $this->contextAccessor->getValue($context, $this->objectOrClass);
     if (is_object($objectOrClass)) {
         $unitOfWork = $this->doctrineHelper->getEntityManager($objectOrClass)->getUnitOfWork();
         if (!$unitOfWork->isInIdentityMap($objectOrClass) || $unitOfWork->isScheduledForInsert($objectOrClass)) {
             $objectOrClass = 'Entity:' . $this->doctrineHelper->getEntityClass($objectOrClass);
         }
     }
     return $this->securityFacade->isGranted($attributes, $objectOrClass);
 }
開發者ID:xamin123,項目名稱:platform,代碼行數:18,代碼來源:AclGranted.php

示例7: getOrCreateFieldsChanges

 /**
  * @param object $entity
  * @param bool   $allowCreate
  *
  * @return FieldsChanges
  */
 protected function getOrCreateFieldsChanges($entity, $allowCreate = true)
 {
     $className = $this->doctrineHelper->getEntityClass($entity);
     $identifier = $this->doctrineHelper->getSingleEntityIdentifier($entity);
     $em = $this->doctrineHelper->getEntityManager($this->className);
     $fieldChanges = $em->getRepository($this->className)->findOneBy(['entityClass' => $className, 'entityId' => $identifier]);
     if ($fieldChanges || !$fieldChanges && !$allowCreate) {
         return $fieldChanges;
     }
     $fieldChanges = $this->doctrineHelper->createEntityInstance($this->className)->setEntityClass($className)->setEntityId($identifier);
     $em->persist($fieldChanges);
     return $fieldChanges;
 }
開發者ID:Maksold,項目名稱:platform,代碼行數:19,代碼來源:FieldsChangesManager.php

示例8: doCompare

 /**
  * Compare two values for equality
  *
  * @param mixed $left
  * @param mixed $right
  * @return boolean
  */
 protected function doCompare($left, $right)
 {
     if (is_object($left) && is_object($right)) {
         $leftClass = $this->doctrineHelper->getEntityClass($left);
         $rightClass = $this->doctrineHelper->getEntityClass($right);
         if ($leftClass == $rightClass && $this->doctrineHelper->isManageableEntity($left) && $this->doctrineHelper->isManageableEntity($right)) {
             $leftIdentifier = $this->doctrineHelper->getEntityIdentifier($left);
             $rightIdentifier = $this->doctrineHelper->getEntityIdentifier($right);
             return $leftIdentifier == $rightIdentifier;
         }
     }
     return $left == $right;
 }
開發者ID:xamin123,項目名稱:platform,代碼行數:20,代碼來源:EqualTo.php

示例9: isApplicable

 /**
  * {@inheritdoc}
  */
 public function isApplicable($entity)
 {
     if (is_object($entity)) {
         $entity = $this->doctrineHelper->getEntityClass($entity);
     }
     return $entity == self::ACTIVITY_CLASS;
 }
開發者ID:rodolfobandeira,項目名稱:training-crm-application,代碼行數:10,代碼來源:GitHubIssueActivityListProvider.php

示例10: getActivityListEntityForEntity

 /**
  * @param object                        $entity
  * @param ActivityListProviderInterface $provider
  * @param string                        $verb
  * @param ActivityList|null             $list
  *
  * @return ActivityList
  */
 protected function getActivityListEntityForEntity($entity, ActivityListProviderInterface $provider, $verb = ActivityList::VERB_CREATE, $list = null)
 {
     if ($provider->isApplicable($entity)) {
         if (!$list) {
             $list = new ActivityList();
         }
         $list->setSubject($provider->getSubject($entity));
         $list->setDescription($this->htmlTagHelper->stripTags($this->htmlTagHelper->purify($provider->getDescription($entity))));
         $this->setDate($entity, $provider, $list);
         if ($this->hasGrouping($provider)) {
             $list->setHead($provider->isHead($entity));
         }
         $list->setVerb($verb);
         if ($verb === ActivityList::VERB_UPDATE) {
             $activityListTargets = $list->getActivityListTargetEntities();
             foreach ($activityListTargets as $target) {
                 $list->removeActivityListTarget($target);
             }
         } else {
             $className = $this->doctrineHelper->getEntityClass($entity);
             $list->setRelatedActivityClass($className);
             $list->setRelatedActivityId($this->doctrineHelper->getSingleEntityIdentifier($entity));
             $list->setOrganization($provider->getOrganization($entity));
         }
         $targets = $provider->getTargetEntities($entity);
         foreach ($targets as $target) {
             if ($list->supportActivityListTarget($this->doctrineHelper->getEntityClass($target))) {
                 $list->addActivityListTarget($target);
             }
         }
         return $list;
     }
     return null;
 }
開發者ID:hugeval,項目名稱:platform,代碼行數:42,代碼來源:ActivityListChainProvider.php

示例11: getWorkflowItemByEntity

 /**
  * @param object $entity
  * @return WorkflowItem|null
  */
 public function getWorkflowItemByEntity($entity)
 {
     $entityClass = $this->doctrineHelper->getEntityClass($entity);
     $entityIdentifier = $this->doctrineHelper->getSingleEntityIdentifier($entity);
     if (false === filter_var($entityIdentifier, FILTER_VALIDATE_INT)) {
         return null;
     }
     return $this->getWorkflowItemRepository()->findByEntityMetadata($entityClass, $entityIdentifier);
 }
開發者ID:xamin123,項目名稱:platform,代碼行數:13,代碼來源:WorkflowManager.php

示例12: getEntityClass

 /**
  * @param object $object
  * @return string
  */
 protected function getEntityClass($object)
 {
     if ($object instanceof ObjectIdentityInterface) {
         $class = $object->getType();
     } else {
         $class = $this->doctrineHelper->getEntityClass($object);
     }
     return ClassUtils::getRealClass($class);
 }
開發者ID:nmallare,項目名稱:platform,代碼行數:13,代碼來源:AbstractEntityVoter.php

示例13: isAllowedButton

 /**
  * @param BeforeGroupingChainWidgetEvent $event
  */
 public function isAllowedButton(BeforeGroupingChainWidgetEvent $event)
 {
     $entity = $event->getEntity();
     $pageType = $event->getPageType();
     if ($pageType === null || !is_object($entity) || !$this->configManager->hasConfig($this->doctrineHelper->getEntityClass($entity)) || !$this->isAllowedOnPage($this->doctrineHelper->getEntityClass($entity), $pageType)) {
         // Clear allowed widgets
         $event->setWidgets([]);
     }
 }
開發者ID:woei66,項目名稱:platform,代碼行數:12,代碼來源:PlaceholderFilter.php

示例14: testGetEntityRepositoryByEntity

 public function testGetEntityRepositoryByEntity()
 {
     $entity = new ItemStubProxy();
     $entityClass = $this->doctrineHelper->getEntityClass($entity);
     $repo = $this->getMockBuilder('Doctrine\\ORM\\EntityRepository');
     $this->registry->expects($this->once())->method('getManagerForClass')->with($entityClass)->will($this->returnValue($this->em));
     $this->em->expects($this->once())->method('getRepository')->with($entityClass)->will($this->returnValue($repo));
     $this->assertSame($repo, $this->doctrineHelper->getEntityRepository($entity));
 }
開發者ID:antrampa,項目名稱:platform,代碼行數:9,代碼來源:DoctrineHelperTest.php

示例15: getEntityClass

 /**
  * @param object $object
  * @return string
  */
 protected function getEntityClass($object)
 {
     if ($object instanceof ObjectIdentityInterface) {
         $class = $object->getType();
         $delim = strpos($class, '@');
         if ($delim) {
             $class = ltrim(substr($class, $delim + 1), ' ');
         }
     } else {
         $class = $this->doctrineHelper->getEntityClass($object);
     }
     return ClassUtils::getRealClass($class);
 }
開發者ID:Maksold,項目名稱:platform,代碼行數:17,代碼來源:AbstractEntityVoter.php


注:本文中的Oro\Bundle\EntityBundle\ORM\DoctrineHelper::getEntityClass方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。