欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程资源 > 编程问答 >内容正文

编程问答

Sylius不需要缓存使用默认地址

发布时间:2025/3/21 编程问答 45 豆豆
生活随笔 收集整理的这篇文章主要介绍了 Sylius不需要缓存使用默认地址 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

为什么80%的码农都做不了架构师?>>>   

<?php/** This file is part of the Sylius package.** (c) Paweł Jędrzejewski** For the full copyright and license information, please view the LICENSE* file that was distributed with this source code.*/namespace Sylius\Bundle\CoreBundle\Checkout\Step;use Sylius\Bundle\FlowBundle\Process\Context\ProcessContextInterface; use Sylius\Component\Core\Model\OrderInterface; use Sylius\Component\Core\SyliusCheckoutEvents; use Symfony\Component\Form\FormInterface;/*** The addressing step of checkout.* User enters the shipping and shipping address.** @author Paweł Jędrzejewski <pawel@sylius.org>*/ class AddressingStep extends CheckoutStep {/*** {@inheritdoc}*/public function displayAction(ProcessContextInterface $context){$order = $this->getCurrentCart();$this->dispatchCheckoutEvent(SyliusCheckoutEvents::ADDRESSING_INITIALIZE, $order);$form = $this->createCheckoutAddressingForm($order);return $this->renderStep($context, $order, $form);}/*** {@inheritdoc}*/public function forwardAction(ProcessContextInterface $context){$request = $this->getRequest();$order = $this->getCurrentCart();$this->dispatchCheckoutEvent(SyliusCheckoutEvents::ADDRESSING_INITIALIZE, $order);$form = $this->createCheckoutAddressingForm($order);if ($request->isMethod('POST') && $form->submit($request)->isValid()) {$this->dispatchCheckoutEvent(SyliusCheckoutEvents::ADDRESSING_PRE_COMPLETE, $order);$this->getManager()->persist($order);$this->getManager()->flush();$this->dispatchCheckoutEvent(SyliusCheckoutEvents::ADDRESSING_COMPLETE, $order);return $this->complete();}return $this->renderStep($context, $order, $form);}protected function renderStep(ProcessContextInterface $context, OrderInterface $order, FormInterface $form){$pre_data = $form->getData();  $address = $pre_data->getUser()->getShippingAddress();$pre_data->setShippingAddress( $address );$form->setData( $pre_data );return $this->render('SyliusWebBundle:Frontend/Checkout/Step:addressing.html.twig', array('order'   => $order,'form'    => $form->createView(),'context' => $context));}protected function createCheckoutAddressingForm(OrderInterface $order){return $this->createForm('sylius_checkout_addressing', $order);} }


转载于:https://my.oschina.net/imot/blog/284705

总结

以上是生活随笔为你收集整理的Sylius不需要缓存使用默认地址的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。