only load component if not already loaded
This commit is contained in:
parent
80193e6242
commit
4b45725b33
|
|
@ -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();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue