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


PHP DoctrineHelper::createEntityInstance方法代码示例

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


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

示例1: createWindowsState

 /**
  * @return int
  */
 public function createWindowsState()
 {
     /** @var AbstractWindowsState $state */
     $state = $this->doctrineHelper->createEntityInstance($this->className);
     $state->setData($this->requestStateManager->getData());
     $state->setUser($this->getUser());
     $em = $this->doctrineHelper->getEntityManagerForClass($this->className);
     $em->persist($state);
     $em->flush($state);
     return $state->getId();
 }
开发者ID:ramunasd,项目名称:platform,代码行数:14,代码来源:WindowsStateManager.php

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

示例3: testCreateEntityInstance

 public function testCreateEntityInstance()
 {
     $entity = new ItemStubProxy();
     $class = 'ItemStubProxy';
     $this->classMetadata->expects($this->once())->method('newInstance')->will($this->returnValue($entity));
     $this->em->expects($this->once())->method('getClassMetadata')->with($class)->will($this->returnValue($this->classMetadata));
     $this->registry->expects($this->once())->method('getManagerForClass')->with($class)->will($this->returnValue($this->em));
     $this->assertSame($entity, $this->doctrineHelper->createEntityInstance($class));
 }
开发者ID:xamin123,项目名称:platform,代码行数:9,代码来源:DoctrineHelperTest.php

示例4: getEntityReference

 /**
  * Returns the reference to the entity object by its class name and id
  *
  * If entity id is not specified the reference to the new entity object is returned
  *
  * @param string     $entityClass The class name. Also the _ char can be used instead of \
  * @param mixed|null $entityId    The object id
  *
  * @return object The entity reference
  *
  * @throws BadRequestHttpException
  */
 public function getEntityReference($entityClass, $entityId = null)
 {
     $entityClass = $this->decodeClassName($entityClass);
     try {
         $entity = $entityId ? $this->doctrineHelper->getEntityReference($entityClass, $entityId) : $this->doctrineHelper->createEntityInstance($entityClass);
     } catch (NotManageableEntityException $e) {
         throw new BadRequestHttpException($e->getMessage(), $e);
     }
     return $entity;
 }
开发者ID:xamin123,项目名称:platform,代码行数:22,代码来源:EntityRoutingHelper.php

示例5: preSubmit

 /**
  * Change transport settings subform to form matching transport passed in request.
  * Pass top level data to transportSettings.
  *
  * @param FormEvent $event
  */
 public function preSubmit(FormEvent $event)
 {
     $data = $event->getData();
     $form = $event->getForm();
     $formData = $form->getData();
     $transportName = isset($data['transport']) ? $data['transport'] : '';
     $selectedTransport = $this->getSelectedTransport($transportName);
     if ($selectedTransport->getName() != $formData->getTransport()) {
         $newSettings = $this->doctrineHelper->createEntityInstance($selectedTransport->getSettingsEntityFQCN());
         $formData->setTransportSettings($newSettings);
     }
     if ($selectedTransport) {
         $this->addTransportSettingsForm($selectedTransport, $form);
         $formData->setTransport($selectedTransport->getName());
         $form->get('transport')->setData($selectedTransport->getName());
     }
     if ($form->has('transportSettings')) {
         $parentData = $data;
         unset($parentData['transportSettings']);
         $data['transportSettings']['parentData'] = $parentData;
     }
     $event->setData($data);
 }
开发者ID:antrampa,项目名称:crm,代码行数:29,代码来源:TransportSettingsListener.php


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