diff --git a/src/Controller/CartItemsController.php b/src/Controller/CartItemsController.php index 1b1ef1a..d4b0001 100644 --- a/src/Controller/CartItemsController.php +++ b/src/Controller/CartItemsController.php @@ -21,11 +21,14 @@ class CartItemsController extends AppController { parent::initialize(); // TODO: Change the autogenerated stub - $this->loadComponent('CakeCarts.ShoppingCart', [ - // This is default config. You can modify "actions" as needed to make - // component work only for specified methods. - 'actions' => ['add'], - ]); + if (!$this->components()->has('ShoppingCart')) { + $this->loadComponent('CakeCarts.ShoppingCart', [ + // This is default config. You can modify "actions" as needed to make + // component work only for specified methods. + 'actions' => ['add'], + ]); + } + if ($this->components()->has('Authorization')) { $this->Authorization->skipAuthorization(); } diff --git a/src/Controller/CartsController.php b/src/Controller/CartsController.php index d0de855..74e87d0 100644 --- a/src/Controller/CartsController.php +++ b/src/Controller/CartsController.php @@ -19,11 +19,13 @@ class CartsController extends AppController { parent::initialize(); // TODO: Change the autogenerated stub - $this->loadComponent('CakeCarts.ShoppingCart', [ - // This is default config. You can modify "actions" as needed to make - // component work only for specified methods. - 'actions' => true, - ]); + if (!$this->components()->has('ShoppingCart')) { + $this->loadComponent('CakeCarts.ShoppingCart', [ + // This is default config. You can modify "actions" as needed to make + // component work only for specified methods. + 'actions' => true, + ]); + } } /**