本文整理汇总了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();
}
示例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;
}
示例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));
}
示例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;
}
示例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);
}