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