當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。