本文整理匯總了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);
}