only load component if not already loaded
CI / testsuite (mysql, 8.2, ) (push) Has been cancelled Details
CI / testsuite (mysql, 8.4, ) (push) Has been cancelled Details
CI / testsuite (sqlite, 8.2, prefer-lowest) (push) Has been cancelled Details
CI / Coding Standard & Static Analysis (push) Has been cancelled Details

This commit is contained in:
Brandon Shipley 2025-11-07 00:43:39 -08:00
parent 80193e6242
commit 4b45725b33
Signed by: bmfs
GPG Key ID: 14E38571D8BB0DE4
2 changed files with 15 additions and 10 deletions

View File

@ -21,11 +21,14 @@ class CartItemsController extends AppController
{ {
parent::initialize(); // TODO: Change the autogenerated stub parent::initialize(); // TODO: Change the autogenerated stub
if (!$this->components()->has('ShoppingCart')) {
$this->loadComponent('CakeCarts.ShoppingCart', [ $this->loadComponent('CakeCarts.ShoppingCart', [
// This is default config. You can modify "actions" as needed to make // This is default config. You can modify "actions" as needed to make
// component work only for specified methods. // component work only for specified methods.
'actions' => ['add'], 'actions' => ['add'],
]); ]);
}
if ($this->components()->has('Authorization')) { if ($this->components()->has('Authorization')) {
$this->Authorization->skipAuthorization(); $this->Authorization->skipAuthorization();
} }

View File

@ -19,12 +19,14 @@ class CartsController extends AppController
{ {
parent::initialize(); // TODO: Change the autogenerated stub parent::initialize(); // TODO: Change the autogenerated stub
if (!$this->components()->has('ShoppingCart')) {
$this->loadComponent('CakeCarts.ShoppingCart', [ $this->loadComponent('CakeCarts.ShoppingCart', [
// This is default config. You can modify "actions" as needed to make // This is default config. You can modify "actions" as needed to make
// component work only for specified methods. // component work only for specified methods.
'actions' => true, 'actions' => true,
]); ]);
} }
}
/** /**
* Index method * Index method