Adyen / adyen-shopware6

Adyen Payment plugin for Shopware 6
MIT License
21 stars 22 forks source link

Various properties in FrontendProxyController do not use the Abstract* version but the constructor does #400

Open AndreasA opened 1 year ago

AndreasA commented 1 year ago

Describe the bug

If one e.g. decorates the CartOrderRoute by extending the AbstractCartOrderRoute, it will work for the constructor but fails to be stored in the property as the property typehinting only allows CartOrderRoute directly.

The same is true for various other properties / constructor services.

Versions Shopware version: [e.g. 6.5.4.4] Plugin version: [e.g. 3.12.1]

see e.g. https://github.com/Adyen/adyen-shopware6/blob/3.12.1/src/Storefront/Controller/FrontendProxyController.php#L54 and https://github.com/Adyen/adyen-shopware6/blob/3.12.1/src/Storefront/Controller/FrontendProxyController.php#L63

AndreasA commented 1 year ago

also: is that controller actually necessary? why not just call the store api directly as I think shopware does also?

peterojo commented 1 year ago

@AndreasA this controller was created only to be able to access store-api routes from our frontend components in shopware 6.5 and this is necessary because of this change

AndreasA commented 1 year ago

Hi @peterojo

Ok. So did not add another solution regarding proxy routing except to implement a corresponding contorller manually. Weird.

Anyway, my main point was that if I use a service decoration for e.g. Shopware\Core\Checkout\Cart\SalesChannel\CartOrderRoute like:

namespace Foo;

public class DecoratedCartOrderRoute extends AbstractCartOrder {
   ....
}
<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema-instance"
    xsd:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd">
    <services>
        <service id="Foo\DecoratedCartOrderRoute "
            decorates="Shopware\Core\Checkout\Cart\SalesChannel\CartOrderRoute"
        />
    </services>
</container>

Routes like /adyen/proxy-switch-context will fail to work as the controller expects the property to be of the type CartOrderRoute not AbstractCartOrderRoute

AndreasA commented 1 year ago

@peterojo I could create a PR for this, it should be quite straight forward.