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


PHP DoctrineHelper::getEntityMetadata方法代码示例

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


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

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

示例2: getEntityName

 /**
  * @param DatagridInterface $dataGrid
  * @return string
  */
 protected function getEntityName(DatagridInterface $dataGrid)
 {
     /** @var OrmDatasource $dataSource */
     $dataSource = $dataGrid->getDatasource();
     $queryBuilder = $dataSource->getQueryBuilder();
     $entityName = $queryBuilder->getRootEntities()[0];
     return $this->doctrineHelper->getEntityMetadata($entityName)->getName();
 }
开发者ID:Maksold,项目名称:platform,代码行数:12,代码来源:EntityPaginationListener.php

示例3: getEntityContactInformationColumns

 /**
  * Get entity contact information fields.
  *
  * @param string|object $entity
  * @return array
  */
 public function getEntityContactInformationColumns($entity)
 {
     $metadata = $this->doctrineHelper->getEntityMetadata($entity);
     $columns = $metadata->getColumnNames();
     $contactInformationColumns = array();
     foreach ($columns as $column) {
         if ($type = $this->getContactInformationFieldType($entity, $column)) {
             $contactInformationColumns[$column] = $type;
         }
     }
     return array_merge($contactInformationColumns, $this->getEntityLevelContactInfoColumns($entity));
 }
开发者ID:antrampa,项目名称:crm,代码行数:18,代码来源:ContactInformationFieldHelper.php

示例4: getMetadata

 /**
  * @return ClassMetadata
  */
 protected function getMetadata()
 {
     if (!$this->metadata) {
         $this->metadata = $this->doctrineHelper->getEntityMetadata(self::CALENDAR_PROPERTY_CLASS);
     }
     return $this->metadata;
 }
开发者ID:ramunasd,项目名称:platform,代码行数:10,代码来源:CalendarPropertyProvider.php

示例5: testGetEntityMetadataNotManageableEntity

 public function testGetEntityMetadataNotManageableEntity()
 {
     $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->getEntityMetadata($class);
 }
开发者ID:xamin123,项目名称:platform,代码行数:7,代码来源:DoctrineHelperTest.php

示例6: postSubmit

 /**
  * @param FormEvent $event
  */
 public function postSubmit(FormEvent $event)
 {
     $form = $event->getForm();
     $added = $form->get('added')->getData();
     $removed = $form->get('removed')->getData();
     $parentData = $form->getParent()->getData();
     /** @var ClassMetadata $parentMetadata */
     $parentMetadata = $this->doctrineHelper->getEntityMetadata(ClassUtils::getClass($parentData));
     /** @var Collection $collection */
     $collection = $form->getData();
     foreach ($added as $relation) {
         $this->processRelation($parentMetadata, $relation, $parentData);
         $collection->add($relation);
     }
     foreach ($removed as $relation) {
         $this->processRelation($parentMetadata, $relation, null);
         $collection->removeElement($relation);
     }
 }
开发者ID:Maksold,项目名称:platform,代码行数:22,代码来源:MultipleEntitySubscriber.php

示例7: addRFMTypes

 /**
  * @param FormInterface $form
  * @param array $categories
  */
 protected function addRFMTypes(FormInterface $form, array $categories)
 {
     foreach (RFMMetricCategory::$types as $type) {
         $typeCategories = array_filter($categories, function (RFMMetricCategory $category) use($type) {
             return $category->getCategoryType() === $type;
         });
         $collection = new PersistentCollection($this->doctrineHelper->getEntityManager($this->rfmCategoryClass), $this->doctrineHelper->getEntityMetadata($this->rfmCategoryClass), new ArrayCollection($typeCategories));
         $collection->takeSnapshot();
         $constraint = new CategoriesConstraint();
         $constraint->setType($type);
         $form->add($type, RFMCategorySettingsType::NAME, [RFMCategorySettingsType::TYPE_OPTION => $type, 'label' => sprintf('orocrm.analytics.form.%s.label', $type), 'tooltip' => sprintf('orocrm.analytics.%s.tooltip', $type), 'mapped' => false, 'required' => false, 'error_bubbling' => false, 'is_increasing' => $type === RFMMetricCategory::TYPE_RECENCY, 'constraints' => [$constraint], 'data' => $collection]);
     }
 }
开发者ID:CopeX,项目名称:crm,代码行数:17,代码来源:ChannelTypeExtension.php

示例8: fillEntityData

 /**
  * @param object $entity
  * @param array $data
  */
 protected function fillEntityData($entity, array $data = [])
 {
     if (!$data) {
         return;
     }
     if (!$this->propertyAccessor) {
         $this->propertyAccessor = PropertyAccess::createPropertyAccessor();
     }
     $metadata = $this->doctrineHelper->getEntityMetadata($entity);
     foreach ($data as $property => $value) {
         try {
             if ($metadata->hasAssociation($property)) {
                 $value = $this->doctrineHelper->getEntityReference($metadata->getAssociationTargetClass($property), $value);
             }
             $this->propertyAccessor->setValue($entity, $property, $value);
         } catch (NoSuchPropertyException $e) {
         }
     }
 }
开发者ID:adam-paterson,项目名称:orocommerce,代码行数:23,代码来源:AbstractProductDataStorageExtension.php

示例9: replaceActivityTargetWithPlainQuery

 /**
  * This method should be used for fast changing data in 'relation' tables, because
  * it uses Plain SQL for updating data in tables.
  * Currently there is no another way for updating big amount of data: with Doctrine way
  * it takes a lot of time(because of big amount of operations with objects, event listeners etc.);
  * with DQL currently it impossible to build query, because DQL works only with entities, but
  * 'relation' tables are not entities. For example: there is 'relation'
  * table 'oro_rel_c3990ba6b28b6f38c460bc' and it has activitylist_id and account_id columns,
  * in fact to solve initial issue with big amount of data we need update only account_id column
  * with new values.
  *
  * @param array       $activityIds
  * @param string      $targetClass
  * @param integer     $oldTargetId
  * @param integer     $newTargetId
  * @param null|string $activityClass
  *
  * @return $this
  *
  * @throws \Doctrine\DBAL\DBALException
  * @throws \Doctrine\ORM\Mapping\MappingException
  */
 public function replaceActivityTargetWithPlainQuery(array $activityIds, $targetClass, $oldTargetId, $newTargetId, $activityClass = null)
 {
     if (is_null($activityClass)) {
         $associationName = $this->getActivityListAssociationName($targetClass);
         $entityClass = ActivityList::ENTITY_NAME;
     } else {
         $associationName = $this->getActivityAssociationName($targetClass);
         $entityClass = $activityClass;
     }
     $entityMetadata = $this->doctrineHelper->getEntityMetadata($entityClass);
     if (!empty($activityIds) && $entityMetadata->hasAssociation($associationName)) {
         $association = $entityMetadata->getAssociationMapping($associationName);
         $tableName = $association['joinTable']['name'];
         $activityField = current(array_keys($association['relationToSourceKeyColumns']));
         $targetField = current(array_keys($association['relationToTargetKeyColumns']));
         $where = "WHERE {$targetField} = :sourceEntityId AND {$activityField} IN(" . implode(',', $activityIds) . ")";
         $dbConnection = $this->doctrineHelper->getEntityManager(ActivityList::ENTITY_NAME)->getConnection()->prepare("UPDATE {$tableName} SET {$targetField} = :masterEntityId {$where}");
         $dbConnection->bindValue('masterEntityId', $newTargetId);
         $dbConnection->bindValue('sourceEntityId', $oldTargetId);
         $dbConnection->execute();
     }
     return $this;
 }
开发者ID:ramunasd,项目名称:platform,代码行数:45,代码来源:ActivityListManager.php

示例10: getSupportedFields

 /**
  * @param string $className
  *
  * @return array
  */
 protected function getSupportedFields($className)
 {
     $classMetadata = $this->doctrineHelper->getEntityMetadata($className);
     return $classMetadata->fieldNames;
 }
开发者ID:Maksold,项目名称:platform,代码行数:10,代码来源:AbstractCalendarProvider.php

示例11: getEntityName

 /**
  * @param OrmDatasource $dataSource
  * @return string
  */
 protected function getEntityName(OrmDatasource $dataSource)
 {
     $queryBuilder = $dataSource->getQueryBuilder();
     $entityName = $queryBuilder->getRootEntities()[0];
     return $this->doctrineHelper->getEntityMetadata($entityName)->getName();
 }
开发者ID:ramunasd,项目名称:platform,代码行数:10,代码来源:StorageDataCollector.php

示例12: testGetEntityMetadataNotManageableEntity

 /**
  * @expectedException \Oro\Bundle\EntityBundle\Exception\NotManageableEntityException
  * @expectedExceptionMessage Entity class "ItemStubProxy" is not manageable
  */
 public function testGetEntityMetadataNotManageableEntity()
 {
     $class = 'ItemStubProxy';
     $this->registry->expects($this->once())->method('getManagerForClass')->with($class)->will($this->returnValue(null));
     $this->doctrineHelper->getEntityMetadata($class);
 }
开发者ID:antrampa,项目名称:platform,代码行数:10,代码来源:DoctrineHelperTest.php

示例13: testGetEntityMetadataNotManageableEntityWithoutThrowException

 public function testGetEntityMetadataNotManageableEntityWithoutThrowException()
 {
     $class = 'ItemStub';
     $this->registry->expects($this->once())->method('getManagerForClass')->with($class)->will($this->returnValue(null));
     $this->assertNull($this->doctrineHelper->getEntityMetadata($class, false));
 }
开发者ID:Maksold,项目名称:platform,代码行数:6,代码来源:DoctrineHelperTest.php


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