私はSymfony + Syliusを使用しています。シリウスは存在しないメソッドを呼び出すようです
sylius_shop_checkout_complete:
path: /complete
methods: [GET, PUT]
defaults:
_controller: sylius.controller.order:updateAction
_sylius:
event: summary
flash: false
template: SyliusShopBundle:Checkout:complete.html.twig
repository:
method: find
arguments: [expr:service('sylius.context.cart').getCart()]
state_machine:
graph: sylius_order_checkout
transition: complete
redirect:
route: sylius_shop_order_pay
parameters:
paymentId: expr:service('sylius.context.cart').getCart().getLastNewPayment().getId()
form:
type: sylius_checkout_complete
options:
validation_groups: 'sylius_checkout_complete'
はかなりまっすぐ進むがないようだ:私は、チェックアウト(checkout.yml)のルーティングに定義されたが、次のされていることに気付きましたか?はい。ただし、Order ControllerでupdateActionメソッドを検索すると、単に存在しません。私はコードが正常に私のサイトから製品を注文することができるように動作している知っているしかし、私はupdateActionにいくつかのCURLコマンドをフックし、テンプレート内のいくつかの応答をレンダリングしたいが、私は単にメソッドを見つけることができませんでしたか?
この狂気は何ですか?すべてのヘルプをいただければ幸いです
<?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\Controller;
use Doctrine\ORM\EntityManager;
use FOS\RestBundle\View\View;
use Payum\Core\Registry\RegistryInterface;
use Sylius\Bundle\ResourceBundle\Controller\RequestConfiguration;
use Sylius\Bundle\ResourceBundle\Controller\ResourceController;
use Sylius\Component\Order\Context\CartContextInterface;
use Sylius\Component\Order\Model\OrderInterface;
use Sylius\Component\Order\SyliusCartEvents;
use Sylius\Component\Resource\ResourceActions;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\GenericEvent;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Webmozart\Assert\Assert;
class OrderController extends ResourceController
{
/**
* @param Request $request
*
* @return Response
*/
public function summaryAction(Request $request)
{
$configuration = $this->requestConfigurationFactory->create($this->metadata, $request);
$cart = $this->getCurrentCart();
if (!$configuration->isHtmlRequest()) {
return $this->viewHandler->handle($configuration, View::create($cart));
}
$form = $this->resourceFormFactory->create($configuration, $cart);
$view = View::create()
->setTemplate($configuration->getTemplate('summary.html'))
->setData([
'cart' => $cart,
'form' => $form->createView(),
])
;
return $this->viewHandler->handle($configuration, $view);
}
/**
* @param Request $request
*
* @return Response
*/
public function saveAction(Request $request)
{
$configuration = $this->requestConfigurationFactory->create($this->metadata, $request);
$this->isGrantedOr403($configuration, ResourceActions::UPDATE);
$resource = $this->getCurrentCart();
$form = $this->resourceFormFactory->create($configuration, $resource);
if (in_array($request->getMethod(), ['POST', 'PUT', 'PATCH'], true) && $form->submit($request, !$request->isMethod('PATCH'))->isValid()) {
$resource = $form->getData();
$event = $this->eventDispatcher->dispatchPreEvent(ResourceActions::UPDATE, $configuration, $resource);
if ($event->isStopped() && !$configuration->isHtmlRequest()) {
throw new HttpException($event->getErrorCode(), $event->getMessage());
}
if ($event->isStopped()) {
$this->flashHelper->addFlashFromEvent($configuration, $event);
return $this->redirectHandler->redirectToResource($configuration, $resource);
}
if ($configuration->hasStateMachine()) {
$this->stateMachine->apply($configuration, $resource);
}
$this->eventDispatcher->dispatchPostEvent(ResourceActions::UPDATE, $configuration, $resource);
if (!$configuration->isHtmlRequest()) {
return $this->viewHandler->handle($configuration, View::create(null, Response::HTTP_NO_CONTENT));
}
$this->getEventDispatcher()->dispatch(SyliusCartEvents::CART_CHANGE, new GenericEvent($resource));
$this->manager->flush();
$this->flashHelper->addSuccessFlash($configuration, ResourceActions::UPDATE, $resource);
return $this->redirectHandler->redirectToResource($configuration, $resource);
}
if (!$configuration->isHtmlRequest()) {
return $this->viewHandler->handle($configuration, View::create($form, Response::HTTP_BAD_REQUEST));
}
$view = View::create()
->setData([
'configuration' => $configuration,
$this->metadata->getName() => $resource,
'form' => $form->createView(),
'cart' => $resource,
])
->setTemplate($configuration->getTemplate(ResourceActions::UPDATE . '.html'))
;
return $this->viewHandler->handle($configuration, $view);
}
/**
* @param Request $request
*
* @return Response
*/
public function thankYouAction(Request $request)
{
$configuration = $this->requestConfigurationFactory->create($this->metadata, $request);
$orderId = $request->getSession()->get('sylius_order_id', null);
if (null === $orderId) {
return $this->redirectHandler->redirectToRoute(
$configuration,
$configuration->getParameters()->get('after_failure[route]', 'sylius_shop_homepage', true),
$configuration->getParameters()->get('after_failure[parameters]', [], true)
);
}
$request->getSession()->remove('sylius_order_id');
$order = $this->repository->find($orderId);
Assert::notNull($order);
$view = View::create()
->setData([
'order' => $order
])
->setTemplate($configuration->getParameters()->get('template'))
;
return $this->viewHandler->handle($configuration, $view);
}
/**
* @param Request $request
*
* @return Response
*/
public function clearAction(Request $request)
{
$configuration = $this->requestConfigurationFactory->create($this->metadata, $request);
$this->isGrantedOr403($configuration, ResourceActions::DELETE);
$resource = $this->getCurrentCart();
$event = $this->eventDispatcher->dispatchPreEvent(ResourceActions::DELETE, $configuration, $resource);
if ($event->isStopped() && !$configuration->isHtmlRequest()) {
throw new HttpException($event->getErrorCode(), $event->getMessage());
}
if ($event->isStopped()) {
$this->flashHelper->addFlashFromEvent($configuration, $event);
return $this->redirectHandler->redirectToIndex($configuration, $resource);
}
$this->repository->remove($resource);
$this->eventDispatcher->dispatchPostEvent(ResourceActions::DELETE, $configuration, $resource);
if (!$configuration->isHtmlRequest()) {
return $this->viewHandler->handle($configuration, View::create(null, Response::HTTP_NO_CONTENT));
}
$this->flashHelper->addSuccessFlash($configuration, ResourceActions::DELETE, $resource);
return $this->redirectHandler->redirectToIndex($configuration, $resource);
}
/**
* @param RequestConfiguration $configuration
*
* @return RedirectResponse
*/
protected function redirectToCartSummary(RequestConfiguration $configuration)
{
if (null === $configuration->getParameters()->get('redirect')) {
return $this->redirectHandler->redirectToRoute($configuration, $this->getCartSummaryRoute());
}
return $this->redirectHandler->redirectToRoute($configuration, $configuration->getParameters()->get('redirect'));
}
/**
* @return string
*/
protected function getCartSummaryRoute()
{
return 'sylius_cart_summary';
}
/**
* @return OrderInterface
*/
protected function getCurrentCart()
{
return $this->getContext()->getCart();
}
/**
* @return CartContextInterface
*/
protected function getContext()
{
return $this->get('sylius.context.cart');
}
/**
* @return EventDispatcherInterface
*/
protected function getEventDispatcher()
{
return $this->container->get('event_dispatcher');
}
}
:
は、ここでは、証明を必要とする場合のご注文・コントローラです。
EDIT
$ app/console debug:router sylius_shop_checkout_complete
+--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Property | Value |
+--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Route Name | sylius_shop_checkout_complete |
| Path | /checkout/complete |
| Path Regex | #^/checkout/complete$#s |
| Host | ANY |
| Host Regex | |
| Scheme | ANY |
| Method | GET|PUT |
| Requirements | NO CUSTOM |
| Class | Symfony\Component\Routing\Route |
| Defaults | _controller: sylius.controller.order:updateAction |
| | _sylius: array ('event' => 'summary','flash' => false,'template' => 'SyliusShopBundle:Checkout:complete.html.twig','repository' => array ('method' => 'find','arguments' => array (0 => 'expr:service(\'sylius.context.cart\').getCart()',),),'state_machine' => array ('graph' => 'sylius_order_checkout','transition' => 'complete',),'redirect' => array ('route' => 'sylius_shop_order_pay','parameters' => array ('paymentId' => 'expr:service(\'sylius.context.cart\').getCart().getLastNewPayment().getId()',),),'form' => array ('type' => 'sylius_checkout_complete','options' => array ('validation_groups' => 'sylius_checkout_complete',),),) |
| Options | compiler_class: Symfony\Component\Routing\RouteCompiler |
+--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
「bin/console debug:router sylius_shop_checkout_complete」とは何ですか? –
@AlisterBulmanの質問が更新されました –