Силиус, кажется, вызывает несуществующий метод

Итак, я использую Symfony + Sylius. Я заметил, что в маршрутизации для checkout (checkout.yml) определено следующее:

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'

Кажется довольно просто нет? Да. Однако при поиске метода updateAction в контроллере заказов его просто не существует. Я знаю, что код работает, поскольку я могу успешно заказывать продукты с моего сайта, однако я надеялся подключить некоторые команды CURL к updateAction и обработать некоторые ответы в шаблоне, но я просто не могу найти метод ?!

Что это за безумие?

Вот Контроллер заказа, если вам нужны доказательства:

<?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');
}
}

Любая помощь будет принята с благодарностью.

РЕДАКТИРОВАТЬ

$ 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                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
+--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

0

Решение

Sylius очень динамичен, и во время сборки создается хорошая порция в контейнере из конфигураций, что даже позволяет изменять рабочие процессы, связанные с перемещением данных через систему.

sylius.controller.order пример тому. Order Модель, контроллер и хранилище передаются в ResourceController.php, где находится updateAction. Те же действия с другими параметрами используются и для других моделей данных.

1

Другие решения

Других решений пока нет …

По вопросам рекламы [email protected]