workouse/SyliusDigitalWalletPlugin

WalletController::newAction won't work.

Closed this issue · 0 comments

Sylius version(s) affected: ~1.5.0@rc

Digital Wallet version(s) affected: dev-master

Description
New credit action won`t work in the admin panel

How to reproduce

  • Install plugin
  • Extend your customer class to App\Entity\Customer
  • Change sylius_customer.resources.customer.classes.model value as App\Entity\Customer
  • Create customer
  • Go to admin panel
  • Select a customer and click the show button
  • Click the credits button at the right top of the page
  • Click create button at the right top of the page
  • fill the form and submit

It occurs that error in the log:

request.CRITICAL: Uncaught PHP Exception Doctrine\ORM\ORMInvalidArgumentException: "Expected value of type "App\Entity\Customer\Customer" for association field "Workouse\DigitalWalletPlugin\Entity\Credit#$customer", got "Sylius\Component\Customer\Model\Customer" instead." at /home/delirehberi/www/bk-2019/vendor/doctrine/orm/lib/Doctrine/ORM/ORMInvalidArgumentException.php line 221 {"exception":"[object] (Doctrine\\ORM\\ORMInvalidArgumentException(code: 0): Expected value of type \"App\\Entity\\Customer\\Customer\" for association field \"Workouse\\DigitalWalletPlugin\\Entity\\Credit#$customer\", got \"Sylius\\Component\\Customer\\Model\\Customer\" instead. at /home/delirehberi/www/bk-2019/vendor/doctrine/orm/lib/Doctrine/ORM/ORMInvalidArgumentException.php:221)"} []

Possible Solution
You need to change the repository call way at the WalletController:newAction. Code explodes if you use Sylius\Component\Customer\Model\Customer repository because this repository returns customer type as Sylius\Component\Customer\Model\Customer. You need to use sylius_customer.resources.customer.classes.models repository for fixing.