本文整理汇总了PHP中Oro\Bundle\EntityBundle\ORM\DoctrineHelper::getEntityReference方法的典型用法代码示例。如果您正苦于以下问题:PHP DoctrineHelper::getEntityReference方法的具体用法?PHP DoctrineHelper::getEntityReference怎么用?PHP DoctrineHelper::getEntityReference使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Oro\Bundle\EntityBundle\ORM\DoctrineHelper
的用法示例。
在下文中一共展示了DoctrineHelper::getEntityReference方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onAccountGroupView
/**
* @param BeforeListRenderEvent $event
*/
public function onAccountGroupView(BeforeListRenderEvent $event)
{
if (!$this->request) {
return;
}
$groupId = (int) $this->request->get('id');
/** @var AccountGroup $group */
$group = $this->doctrineHelper->getEntityReference('OroB2BAccountBundle:AccountGroup', $groupId);
$paymentTermRepository = $this->getPaymentTermRepository();
$paymentTerm = $paymentTermRepository->getOnePaymentTermByAccountGroup($group);
$paymentTermData = ['paymentTerm' => $paymentTerm, 'paymentTermLabel' => $paymentTerm ? $paymentTerm->getLabel() : null, 'empty' => $this->translator->trans('N/A'), 'defineToTheGroup' => false];
$template = $event->getEnvironment()->render('OroB2BPaymentBundle:Account:payment_term_view.html.twig', ['paymentTermData' => $paymentTermData]);
$event->getScrollData()->addSubBlockData(0, 0, $template);
}
示例2: onProductView
/**
* @param BeforeListRenderEvent $event
*/
public function onProductView(BeforeListRenderEvent $event)
{
if (!$this->request) {
return;
}
$productId = $this->request->get('id');
/** @var Product $product */
$product = $this->doctrineHelper->getEntityReference('OroB2BProductBundle:Product', $productId);
/** @var CategoryRepository $repository */
$repository = $this->doctrineHelper->getEntityRepository('OroB2BCatalogBundle:Category');
$category = $repository->findOneByProduct($product);
$template = $event->getEnvironment()->render('OroB2BCatalogBundle:Product:category_view.html.twig', ['entity' => $category]);
$this->addCategoryBlock($event->getScrollData(), $template);
}
示例3: onFrontendProductView
/**
* @param BeforeListRenderEvent $event
*/
public function onFrontendProductView(BeforeListRenderEvent $event)
{
if (!$this->request) {
return;
}
$productId = (int) $this->request->get('id');
if (!$productId) {
return;
}
if (!$this->doctrineHelper->getEntityReference('OroB2BProductBundle:Product', $productId)) {
return;
}
$template = $event->getEnvironment()->render('OroB2BShoppingListBundle:Product/Frontend:view.html.twig', ['productId' => $productId]);
$this->addShoppingListBlock($event->getScrollData(), $template);
}
示例4: getEntityFromRequestId
/**
* @param $className
* @return null|object
*/
protected function getEntityFromRequestId($className)
{
if (!$this->request) {
return null;
}
$entityId = (int) $this->request->get('id');
if (!$entityId) {
return null;
}
$entity = $this->doctrineHelper->getEntityReference($className, $entityId);
if (!$entity) {
return null;
}
return $entity;
}
示例5: deserialize
/**
* Deserialize data of WorkflowItem
*
* @param WorkflowItem $workflowItem
*/
protected function deserialize(WorkflowItem $workflowItem)
{
// Pass serializer into $workflowItem to make lazy loading of workflow item data.
$workflowItem->setSerializer($this->serializer, $this->format);
// Set related entity
$relatedEntity = $this->doctrineHelper->getEntityReference($workflowItem->getDefinition()->getRelatedEntity(), $workflowItem->getEntityId());
$workflowItem->setEntity($relatedEntity);
}
示例6: testGetEntityReference
public function testGetEntityReference()
{
$expectedResult = $this->getMock('MockEntityReference');
$entityClass = 'MockEntity';
$entityId = 100;
$this->em->expects($this->once())->method('getReference')->with($entityClass, $entityId)->will($this->returnValue($expectedResult));
$this->registry->expects($this->any())->method('getManagerForClass')->with($entityClass)->will($this->returnValue($this->em));
$this->assertEquals($expectedResult, $this->doctrineHelper->getEntityReference($entityClass, $entityId));
}
示例7: 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;
}
示例8: onProductView
/**
* @param BeforeListRenderEvent $event
*/
public function onProductView(BeforeListRenderEvent $event)
{
if (!$this->request) {
return;
}
$productId = $this->request->get('id');
/** @var Customer $customer */
$product = $this->doctrineHelper->getEntityReference('OroB2BProductBundle:Product', $productId);
$template = $event->getEnvironment()->render('OroB2BPricingBundle:Product:prices_view.html.twig', ['entity' => $product]);
$this->addProductPricesBlock($event->getScrollData(), $template);
}
示例9: onFrontendProductView
/**
* @param BeforeListRenderEvent $event
*/
public function onFrontendProductView(BeforeListRenderEvent $event)
{
if (!$this->request) {
return;
}
$productId = (int) $this->request->get('id');
/** @var Product $product */
$product = $this->doctrineHelper->getEntityReference('OroB2BProductBundle:Product', $productId);
$priceList = $this->frontendPriceListRequestHandler->getPriceList();
/** @var ProductPriceRepository $priceRepository */
$priceRepository = $this->doctrineHelper->getEntityRepository('OroB2BPricingBundle:ProductPrice');
$prices = $priceRepository->findByPriceListIdAndProductIds($priceList->getId(), [$product->getId()]);
$template = $event->getEnvironment()->render('OroB2BPricingBundle:Frontend/Product:productPrice.html.twig', ['prices' => $prices]);
$scrollData = $event->getScrollData();
$subBlockId = $scrollData->addSubBlock(0);
$scrollData->addSubBlockData(0, $subBlockId, $template);
}
示例10: 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) {
}
}
}
示例11: getEntityById
/**
* @param int|string $id
* @return object
*/
protected function getEntityById($id)
{
return $this->doctrineHelper->getEntityReference($this->class, $id);
}
示例12: getEntityReference
/**
* @param object $entity
* @return object
*/
public function getEntityReference($entity)
{
$entityName = ClassUtils::getClass($entity);
$identifier = $this->getIdentifier($entity);
return $this->doctrineHelper->getEntityReference($entityName, $identifier);
}
示例13: getEnumValueByCode
/**
* @param string $enumCode
* @param string $id
* @return AbstractEnumValue
*/
public function getEnumValueByCode($enumCode, $id)
{
$enumClass = ExtendHelper::buildEnumValueClassName($enumCode);
return $this->doctrineHelper->getEntityReference($enumClass, $id);
}