Jump to content

Edit History

Mehdib92

Mehdib92

I think I don't understand 100% how it works.

 

I have created mymodule/src/Presenter/CartPresenter.php

namespace Mfacilities\OrderExtras\Presenter;

use Currency;
use Order as PrestashopOrder;
use OrderState;
//use PrestaShop\PrestaShop\Adapter\Cart;

class CartPresenter extends \PrestaShop\PrestaShop\Adapter\Presenter\Cart
{
    public $cartPresenter;

    public function __construct(CartPresenter $cartPresenter) {
        $this->cartPresenter = $cartPresenter;
    }
    /**
     * @param Cart $cart
     * @param bool $shouldSeparateGifts
     *
     * @return array
     *
     * @throws \Exception
     */
    public function present($cart, $shouldSeparateGifts = false)
    {
        die('TEST');
    }
}

If in my config/services.yml I add :

mycompany.mymodule.presenter.custom_cartpresenter:
    class: 'MyCompany\MyModule\Presenter\CartPresenter'
    arguments:
      - 'PrestaShop\PrestaShop\Adapter\Presenter\Cart\CartPresenter'

 

If I try like that (with a composer dumpautoload and a cache clear before), nothing happen.

Mehdib92

Mehdib92

I think I don't understand 100% how it works.

 

I have created mymodule/src/Presenter/CartPresenter.php

declare(strict_types=1);

namespace MyCompany\MyModule\Adapter\Presenter;

use Currency;
use Order as PrestashopOrder;
use OrderState;
use PrestaShop\PrestaShop\Adapter\Cart;

class CartPresenter extends \PrestaShop\PrestaShop\Adapter\Presenter\Cart\CartPresenter
{
    public function present($cart, $shouldSeparateGifts = false)
    {
        die('TEST');
    }
}

If I try like that (with a composer dumpautoload and a cache clear before), nothing happen.

If in my config/services.yml I add :

myconmpany.custom_cartpresenter:
    class: 'MyCompany\MyModule\Adapter\Presenter\CustomCartPresenter'
    decorates: 'PrestaShop\PrestaShop\Adapter\Cart\CartPresenter'
    arguments: ['@mycompany.custom_cartpresenter.inner']

When I do a cache:clear I have the message 

Quote

You have requested a non-existent service "PrestaShop\PrestaShop\Adapter\Cart\CartPresenter".

 

×
×
  • Create New...