dont use cheese cake override table trait - dont think is necessary
CI / testsuite (mysql, 8.2, ) (push) Successful in 10m51s Details
CI / testsuite (mysql, 8.4, ) (push) Successful in 10m14s Details
CI / testsuite (sqlite, 8.2, prefer-lowest) (push) Failing after 6m10s Details
CI / Coding Standard & Static Analysis (push) Failing after 5m57s Details

This commit is contained in:
Brandon Shipley 2025-11-11 01:01:42 -08:00
parent c8e44f3705
commit c196dc2fe0
Signed by: bmfs
GPG Key ID: 14E38571D8BB0DE4
31 changed files with 82 additions and 122 deletions

View File

@ -8,7 +8,6 @@
"php": ">=8.2", "php": ">=8.2",
"dereuromark/cakephp-tools": "^3.9", "dereuromark/cakephp-tools": "^3.9",
"muffin/trash": "^4.2", "muffin/trash": "^4.2",
"hi-powered-dev/cheese-cake": "dev-prod",
"cakephp/cakephp": "^5.0.1", "cakephp/cakephp": "^5.0.1",
"bentools/cartesian-product": "dev-master" "bentools/cartesian-product": "dev-master"
}, },

View File

@ -7,8 +7,6 @@ use Cake\Core\Configure;
use Cake\Log\Log; use Cake\Log\Log;
use Cake\ORM\Table; use Cake\ORM\Table;
use Cake\ORM\TableRegistry; use Cake\ORM\TableRegistry;
use CakeProducts\Controller\AppController;
use CheeseCake\Controller\Traits\OverrideTableTrait;
/** /**
* ExternalProductCatalogs Controller * ExternalProductCatalogs Controller
@ -17,7 +15,7 @@ use CheeseCake\Controller\Traits\OverrideTableTrait;
*/ */
class ExternalProductCatalogsController extends AppController class ExternalProductCatalogsController extends AppController
{ {
use OverrideTableTrait; // use OverrideTableTrait;
/** /**
* @return void * @return void

View File

@ -6,7 +6,6 @@ namespace CakeProducts\Controller;
use Cake\Datasource\Exception\RecordNotFoundException; use Cake\Datasource\Exception\RecordNotFoundException;
use Cake\Http\Response; use Cake\Http\Response;
use Cake\Log\Log; use Cake\Log\Log;
use CakeProducts\Controller\AppController;
/** /**
* ExternalProductCatalogsProductCatalogs Controller * ExternalProductCatalogsProductCatalogs Controller

View File

@ -9,9 +9,6 @@ use Cake\Http\Response;
use Cake\Log\Log; use Cake\Log\Log;
use Cake\ORM\Table; use Cake\ORM\Table;
use Cake\ORM\TableRegistry; use Cake\ORM\TableRegistry;
use CakeProducts\Controller\AppController;
use CheeseCake\Controller\Traits\OverrideTableTrait;
;
use CakeProducts\Model\Table\ProductCatalogsTable; use CakeProducts\Model\Table\ProductCatalogsTable;
/** /**
@ -21,8 +18,6 @@ use CakeProducts\Model\Table\ProductCatalogsTable;
*/ */
class ProductCatalogsController extends AppController class ProductCatalogsController extends AppController
{ {
use OverrideTableTrait;
/** /**
* @return void * @return void
*/ */
@ -40,7 +35,7 @@ class ProductCatalogsController extends AppController
*/ */
public function index() public function index()
{ {
$query = $this->getTable()->find(); $query = $this->ProductCatalogs->find();
$productCatalogs = $this->paginate($query); $productCatalogs = $this->paginate($query);
$this->set(compact('productCatalogs')); $this->set(compact('productCatalogs'));
@ -59,7 +54,7 @@ class ProductCatalogsController extends AppController
if (Configure::read('CakeProducts.internal.syncExternally', false)) { if (Configure::read('CakeProducts.internal.syncExternally', false)) {
$contain[] = 'ExternalProductCatalogs'; $contain[] = 'ExternalProductCatalogs';
} }
$productCatalog = $this->getTable()->get($id, contain: $contain); $productCatalog = $this->ProductCatalogs->get($id, contain: $contain);
$this->set(compact('productCatalog')); $this->set(compact('productCatalog'));
} }
@ -70,7 +65,7 @@ class ProductCatalogsController extends AppController
*/ */
public function add() public function add()
{ {
$productCatalogsTable = $this->getTable(); $productCatalogsTable = $this->ProductCatalogs;
$productCatalog = $productCatalogsTable->newEmptyEntity(); $productCatalog = $productCatalogsTable->newEmptyEntity();
if ($this->request->is('post')) { if ($this->request->is('post')) {
$productCatalog = $productCatalogsTable->patchEntity($productCatalog, $this->request->getData()); $productCatalog = $productCatalogsTable->patchEntity($productCatalog, $this->request->getData());
@ -97,7 +92,7 @@ class ProductCatalogsController extends AppController
*/ */
public function edit($id = null) public function edit($id = null)
{ {
$productCatalogsTable = $this->getTable(); $productCatalogsTable = $this->ProductCatalogs;
$productCatalog = $productCatalogsTable->get($id, contain: []); $productCatalog = $productCatalogsTable->get($id, contain: []);
if ($this->request->is(['patch', 'post', 'put'])) { if ($this->request->is(['patch', 'post', 'put'])) {
$productCatalog = $productCatalogsTable->patchEntity($productCatalog, $this->request->getData()); $productCatalog = $productCatalogsTable->patchEntity($productCatalog, $this->request->getData());
@ -121,7 +116,7 @@ class ProductCatalogsController extends AppController
public function delete($id = null) public function delete($id = null)
{ {
$this->request->allowMethod(['post', 'delete']); $this->request->allowMethod(['post', 'delete']);
$productCatalogsTable = $this->getTable(); $productCatalogsTable = $this->ProductCatalogs;
$productCatalog = $productCatalogsTable->get($id); $productCatalog = $productCatalogsTable->get($id);
if ($productCatalogsTable->delete($productCatalog)) { if ($productCatalogsTable->delete($productCatalog)) {
$this->Flash->success(__('The product catalog has been deleted.')); $this->Flash->success(__('The product catalog has been deleted.'));
@ -131,21 +126,4 @@ class ProductCatalogsController extends AppController
return $this->redirect(['action' => 'index']); return $this->redirect(['action' => 'index']);
} }
/**
* Gets the users table instance
*
* @return Table
*/
public function getTable()
{
if ($this->_table instanceof Table) {
return $this->_table;
}
$this->_table = TableRegistry::getTableLocator()->get(
Configure::read('CakeProducts.ProductCatalogs.table', 'CakeProducts.ProductCatalogs')
);
return $this->_table;
}
} }

View File

@ -8,8 +8,6 @@ use Cake\Log\Log;
use Cake\ORM\Table; use Cake\ORM\Table;
use Cake\ORM\TableRegistry; use Cake\ORM\TableRegistry;
use Cake\Utility\Text; use Cake\Utility\Text;
use CheeseCake\Controller\Traits\OverrideTableTrait;
;
/** /**
* ProductCategories Controller * ProductCategories Controller
@ -18,8 +16,6 @@ use CheeseCake\Controller\Traits\OverrideTableTrait;
*/ */
class ProductCategoriesController extends AppController class ProductCategoriesController extends AppController
{ {
use OverrideTableTrait;
/** /**
* @return void * @return void
*/ */
@ -37,7 +33,7 @@ class ProductCategoriesController extends AppController
*/ */
public function index() public function index()
{ {
$query = $this->getTable()->find() $query = $this->ProductCategories->find()
->contain(['ProductCatalogs', 'ParentProductCategories']); ->contain(['ProductCatalogs', 'ParentProductCategories']);
$productCategories = $this->paginate($query); $productCategories = $this->paginate($query);
@ -53,7 +49,7 @@ class ProductCategoriesController extends AppController
*/ */
public function view($id = null) public function view($id = null)
{ {
$productCategory = $this->getTable()->get($id, contain: [ $productCategory = $this->ProductCategories->get($id, contain: [
'ProductCatalogs', 'ProductCatalogs',
'ParentProductCategories', 'ParentProductCategories',
'ChildProductCategories', 'ChildProductCategories',
@ -62,7 +58,7 @@ class ProductCategoriesController extends AppController
'PrimaryProductPhotos', 'PrimaryProductPhotos',
]); ]);
$productCategoryAttributes = $this->getTable()->ProductCategoryAttributes->getAllCategoryAttributesForCategoryId($productCategory->internal_id); $productCategoryAttributes = $this->ProductCategories->ProductCategoryAttributes->getAllCategoryAttributesForCategoryId($productCategory->internal_id);
$this->set(compact('productCategory', 'productCategoryAttributes')); $this->set(compact('productCategory', 'productCategoryAttributes'));
} }
@ -73,7 +69,7 @@ class ProductCategoriesController extends AppController
*/ */
public function add() public function add()
{ {
$productCategoriesTable = $this->getTable(); $productCategoriesTable = $this->ProductCategories;
$productCategory = $productCategoriesTable->newEmptyEntity(); $productCategory = $productCategoriesTable->newEmptyEntity();
if ($this->request->is('post')) { if ($this->request->is('post')) {
$postData = $this->request->getData(); $postData = $this->request->getData();
@ -112,7 +108,7 @@ class ProductCategoriesController extends AppController
*/ */
public function edit($id = null) public function edit($id = null)
{ {
$productCategoriesTable = $this->getTable(); $productCategoriesTable = $this->ProductCategories;
$productCategory = $productCategoriesTable->get($id, contain: []); $productCategory = $productCategoriesTable->get($id, contain: []);
if ($this->request->is(['patch', 'post', 'put'])) { if ($this->request->is(['patch', 'post', 'put'])) {
$postData = $this->request->getData(); $postData = $this->request->getData();
@ -139,7 +135,7 @@ class ProductCategoriesController extends AppController
public function delete($id = null) public function delete($id = null)
{ {
$this->request->allowMethod(['post', 'delete']); $this->request->allowMethod(['post', 'delete']);
$productCategoriesTable = $this->getTable(); $productCategoriesTable = $this->ProductCategories;
$productCategory = $productCategoriesTable->get($id); $productCategory = $productCategoriesTable->get($id);
// $productCategoriesTable->behaviors()->get('Tree')->setConfig([ // $productCategoriesTable->behaviors()->get('Tree')->setConfig([
@ -161,7 +157,7 @@ class ProductCategoriesController extends AppController
*/ */
public function select() public function select()
{ {
$productCategoriesTable = $this->getTable(); $productCategoriesTable = $this->ProductCategories;
$productCategoriesTable->behaviors()->get('Tree')->setConfig([ $productCategoriesTable->behaviors()->get('Tree')->setConfig([
'scope' => [ 'scope' => [
'product_catalog_id' => $this->request->getQuery('product_catalog_id', -1), 'product_catalog_id' => $this->request->getQuery('product_catalog_id', -1),

View File

@ -7,9 +7,6 @@ use Cake\Core\Configure;
use Cake\Log\Log; use Cake\Log\Log;
use Cake\ORM\Table; use Cake\ORM\Table;
use Cake\ORM\TableRegistry; use Cake\ORM\TableRegistry;
use CakeProducts\Controller\AppController;
use CheeseCake\Controller\Traits\OverrideTableTrait;
;
/** /**
* ProductCategoryAttributeOptions Controller * ProductCategoryAttributeOptions Controller
@ -18,8 +15,6 @@ use CheeseCake\Controller\Traits\OverrideTableTrait;
*/ */
class ProductCategoryAttributeOptionsController extends AppController class ProductCategoryAttributeOptionsController extends AppController
{ {
use OverrideTableTrait;
/** /**
* @return void * @return void
*/ */
@ -39,7 +34,7 @@ class ProductCategoryAttributeOptionsController extends AppController
{ {
Log::debug('inside product category attribute options controller add'); Log::debug('inside product category attribute options controller add');
$productCategoryAttributeOption = $this->getTable()->newEmptyEntity(); $productCategoryAttributeOption = $this->ProductCategoryAttributeOptions->newEmptyEntity();
$this->set(compact('productCategoryAttributeOption')); $this->set(compact('productCategoryAttributeOption'));
} }
@ -53,7 +48,7 @@ class ProductCategoryAttributeOptionsController extends AppController
public function delete($id = null) public function delete($id = null)
{ {
$this->request->allowMethod(['post', 'delete']); $this->request->allowMethod(['post', 'delete']);
$productCategoryAttributeOptionsTable = $this->getTable(); $productCategoryAttributeOptionsTable = $this->ProductCategoryAttributeOptions;
$productCategoryAttributeOption = $productCategoryAttributeOptionsTable->get($id); $productCategoryAttributeOption = $productCategoryAttributeOptionsTable->get($id);
if ($productCategoryAttributeOptionsTable->delete($productCategoryAttributeOption)) { if ($productCategoryAttributeOptionsTable->delete($productCategoryAttributeOption)) {

View File

@ -9,8 +9,6 @@ use Cake\Http\Response;
use Cake\Log\Log; use Cake\Log\Log;
use Cake\ORM\Table; use Cake\ORM\Table;
use Cake\ORM\TableRegistry; use Cake\ORM\TableRegistry;
use CakeProducts\Controller\AppController;
use CheeseCake\Controller\Traits\OverrideTableTrait;
use CakeProducts\Model\Enum\ProductCategoryAttributeTypeId; use CakeProducts\Model\Enum\ProductCategoryAttributeTypeId;
use CakeProducts\Model\Table\ProductCategoryAttributesTable; use CakeProducts\Model\Table\ProductCategoryAttributesTable;
@ -21,8 +19,6 @@ use CakeProducts\Model\Table\ProductCategoryAttributesTable;
*/ */
class ProductCategoryAttributesController extends AppController class ProductCategoryAttributesController extends AppController
{ {
use OverrideTableTrait;
/** /**
* @return void * @return void
*/ */
@ -40,7 +36,7 @@ class ProductCategoryAttributesController extends AppController
*/ */
public function index() public function index()
{ {
$query = $this->getTable()->find() $query = $this->ProductCategoryAttributes->find()
->contain(['ProductCategories']); ->contain(['ProductCategories']);
$productCategoryAttributes = $this->paginate($query); $productCategoryAttributes = $this->paginate($query);
@ -56,7 +52,7 @@ class ProductCategoryAttributesController extends AppController
*/ */
public function view($id = null) public function view($id = null)
{ {
$productCategoryAttribute = $this->getTable()->get($id, contain: [ $productCategoryAttribute = $this->ProductCategoryAttributes->get($id, contain: [
'ProductCategories', 'ProductCategories',
'ProductCategoryAttributeOptions', 'ProductCategoryAttributeOptions',
]); ]);
@ -71,7 +67,7 @@ class ProductCategoryAttributesController extends AppController
*/ */
public function add() public function add()
{ {
$productCategoryAttributesTable = $this->getTable(); $productCategoryAttributesTable = $this->ProductCategoryAttributes;
$productCategoryAttribute = $productCategoryAttributesTable->newEmptyEntity(); $productCategoryAttribute = $productCategoryAttributesTable->newEmptyEntity();
if ($this->request->is('post')) { if ($this->request->is('post')) {
$postData = $this->request->getData(); $postData = $this->request->getData();
@ -113,7 +109,7 @@ class ProductCategoryAttributesController extends AppController
*/ */
public function edit($id = null) public function edit($id = null)
{ {
$productCategoryAttributesTable = $this->getTable(); $productCategoryAttributesTable = $this->ProductCategoryAttributes;
$productCategoryAttribute = $productCategoryAttributesTable->get($id, contain: ['ProductCategoryAttributeOptions']); $productCategoryAttribute = $productCategoryAttributesTable->get($id, contain: ['ProductCategoryAttributeOptions']);
if ($this->request->is(['patch', 'post', 'put'])) { if ($this->request->is(['patch', 'post', 'put'])) {
$postData = $this->request->getData(); $postData = $this->request->getData();
@ -155,7 +151,7 @@ class ProductCategoryAttributesController extends AppController
{ {
$this->request->allowMethod(['post', 'delete']); $this->request->allowMethod(['post', 'delete']);
$productCategoryAttributesTable = $this->getTable(); $productCategoryAttributesTable = $this->ProductCategoryAttributes;
$productCategoryAttribute = $productCategoryAttributesTable->get($id); $productCategoryAttribute = $productCategoryAttributesTable->get($id);
if ($productCategoryAttributesTable->delete($productCategoryAttribute)) { if ($productCategoryAttributesTable->delete($productCategoryAttribute)) {
$this->Flash->success(__('The product category attribute has been deleted.')); $this->Flash->success(__('The product category attribute has been deleted.'));
@ -171,7 +167,7 @@ class ProductCategoryAttributesController extends AppController
*/ */
public function form() public function form()
{ {
$productCategories = $this->getTable()->getAllCategoryAttributesForCategoryId($this->request->getQuery('product_category_id', '-1')); $productCategories = $this->ProductCategoryAttributes->getAllCategoryAttributesForCategoryId($this->request->getQuery('product_category_id', '-1'));
$this->set(compact('productCategories')); $this->set(compact('productCategories'));
} }

View File

@ -3,12 +3,10 @@ declare(strict_types=1);
namespace CakeProducts\Controller; namespace CakeProducts\Controller;
use App\Controller\AppController;
use Cake\Core\Configure; use Cake\Core\Configure;
use Cake\Log\Log; use Cake\Log\Log;
use Cake\ORM\Table; use Cake\ORM\Table;
use Cake\ORM\TableRegistry; use Cake\ORM\TableRegistry;
use CheeseCake\Controller\Traits\OverrideTableTrait;
/** /**
* ProductCategoryVariants Controller * ProductCategoryVariants Controller
@ -17,8 +15,6 @@ use CheeseCake\Controller\Traits\OverrideTableTrait;
*/ */
class ProductCategoryVariantsController extends AppController class ProductCategoryVariantsController extends AppController
{ {
use OverrideTableTrait;
/** /**
* @return void * @return void
*/ */
@ -36,7 +32,7 @@ class ProductCategoryVariantsController extends AppController
*/ */
public function index() public function index()
{ {
$query = $this->getTable()->find() $query = $this->ProductCategoryVariants->find()
->contain(['ProductCategories', 'Products', 'ProductCategoryVariantOptions']); ->contain(['ProductCategories', 'Products', 'ProductCategoryVariantOptions']);
$productCategoryVariants = $this->paginate($query); $productCategoryVariants = $this->paginate($query);
@ -52,7 +48,7 @@ class ProductCategoryVariantsController extends AppController
*/ */
public function view($id = null) public function view($id = null)
{ {
$productCategoryVariant = $this->getTable()->get($id, contain: [ $productCategoryVariant = $this->ProductCategoryVariants->get($id, contain: [
'ProductCategories', 'ProductCategories',
'Products', 'Products',
'ProductCategoryVariantOptions', 'ProductCategoryVariantOptions',
@ -67,7 +63,7 @@ class ProductCategoryVariantsController extends AppController
*/ */
public function add() public function add()
{ {
$productCategoryVariantsTable = $this->getTable(); $productCategoryVariantsTable = $this->ProductCategoryVariants;
$productCategoryVariant = $productCategoryVariantsTable->newEmptyEntity(); $productCategoryVariant = $productCategoryVariantsTable->newEmptyEntity();
if ($this->request->is('post')) { if ($this->request->is('post')) {
@ -104,7 +100,7 @@ class ProductCategoryVariantsController extends AppController
*/ */
public function edit($id = null) public function edit($id = null)
{ {
$productCategoryVariantsTable = $this->getTable(); $productCategoryVariantsTable = $this->ProductCategoryVariants;
$productCategoryVariant = $productCategoryVariantsTable->get($id, contain: []); $productCategoryVariant = $productCategoryVariantsTable->get($id, contain: []);
if ($this->request->is(['patch', 'post', 'put'])) { if ($this->request->is(['patch', 'post', 'put'])) {
$postData = $this->request->getData(); $postData = $this->request->getData();
@ -150,7 +146,7 @@ class ProductCategoryVariantsController extends AppController
public function delete($id = null) public function delete($id = null)
{ {
$this->request->allowMethod(['post', 'delete']); $this->request->allowMethod(['post', 'delete']);
$productCategoryVariantsTable = $this->getTable(); $productCategoryVariantsTable = $this->ProductCategoryVariants;
$productCategoryVariant = $productCategoryVariantsTable->get($id); $productCategoryVariant = $productCategoryVariantsTable->get($id);
if ($productCategoryVariantsTable->delete($productCategoryVariant)) { if ($productCategoryVariantsTable->delete($productCategoryVariant)) {

View File

@ -8,9 +8,7 @@ use Cake\Datasource\Exception\RecordNotFoundException;
use Cake\Http\Exception\ForbiddenException; use Cake\Http\Exception\ForbiddenException;
use Cake\Http\Response; use Cake\Http\Response;
use Cake\Utility\Text; use Cake\Utility\Text;
use CakeProducts\Controller\AppController;
use CakeProducts\Model\Table\ProductPhotosTable; use CakeProducts\Model\Table\ProductPhotosTable;
use CheeseCake\Controller\Traits\OverrideTableTrait;
use Psr\Http\Message\UploadedFileInterface; use Psr\Http\Message\UploadedFileInterface;
/** /**
@ -20,8 +18,6 @@ use Psr\Http\Message\UploadedFileInterface;
*/ */
class ProductPhotosController extends AppController class ProductPhotosController extends AppController
{ {
use OverrideTableTrait;
/** /**
* Index method * Index method
* *
@ -29,7 +25,7 @@ class ProductPhotosController extends AppController
*/ */
public function index() public function index()
{ {
$query = $this->getTable()->find() $query = $this->ProductPhotos->find()
->contain(['Products', 'ProductSkus', 'ProductCategories']); ->contain(['Products', 'ProductSkus', 'ProductCategories']);
$productPhotos = $this->paginate($query); $productPhotos = $this->paginate($query);
@ -45,7 +41,7 @@ class ProductPhotosController extends AppController
*/ */
public function view($id = null) public function view($id = null)
{ {
$productPhoto = $this->getTable()->get($id, contain: ['Products', 'ProductSkus', 'ProductCategories']); $productPhoto = $this->ProductPhotos->get($id, contain: ['Products', 'ProductSkus', 'ProductCategories']);
$this->set(compact('productPhoto')); $this->set(compact('productPhoto'));
} }
@ -56,7 +52,7 @@ class ProductPhotosController extends AppController
*/ */
public function add() public function add()
{ {
$productPhotosTable = $this->getTable(); $productPhotosTable = $this->ProductPhotos;
$productPhoto = $productPhotosTable->newEmptyEntity(); $productPhoto = $productPhotosTable->newEmptyEntity();
if ($this->request->is('post')) { if ($this->request->is('post')) {
if (!$this->request->getData('photo')) { if (!$this->request->getData('photo')) {
@ -161,7 +157,7 @@ class ProductPhotosController extends AppController
*/ */
public function edit($id = null) public function edit($id = null)
{ {
$productPhotosTable = $this->getTable(); $productPhotosTable = $this->ProductPhotos;
$productPhoto = $productPhotosTable->get($id, contain: []); $productPhoto = $productPhotosTable->get($id, contain: []);
if ($this->request->is(['patch', 'post', 'put'])) { if ($this->request->is(['patch', 'post', 'put'])) {
$postData = $this->request->getData(); $postData = $this->request->getData();
@ -189,7 +185,7 @@ class ProductPhotosController extends AppController
public function delete($id = null) public function delete($id = null)
{ {
$this->request->allowMethod(['post', 'delete']); $this->request->allowMethod(['post', 'delete']);
$productPhotosTable = $this->getTable(); $productPhotosTable = $this->ProductPhotos;
$productPhoto = $productPhotosTable->get($id); $productPhoto = $productPhotosTable->get($id);
if ($productPhotosTable->delete($productPhoto)) { if ($productPhotosTable->delete($productPhoto)) {
@ -207,7 +203,7 @@ class ProductPhotosController extends AppController
*/ */
public function image($id = null) public function image($id = null)
{ {
$productPhoto = $this->getTable()->get($id); $productPhoto = $this->ProductPhotos->get($id);
$fullPath = Configure::readOrFail('CakeProducts.photos.directory') . $productPhoto->photo_dir . DS . $productPhoto->photo_filename; $fullPath = Configure::readOrFail('CakeProducts.photos.directory') . $productPhoto->photo_dir . DS . $productPhoto->photo_filename;

View File

@ -5,7 +5,6 @@ namespace CakeProducts\Controller;
use Cake\Log\Log; use Cake\Log\Log;
use Cake\Utility\Hash; use Cake\Utility\Hash;
use CheeseCake\Controller\Traits\OverrideTableTrait;
use function BenTools\CartesianProduct\combinations; use function BenTools\CartesianProduct\combinations;
/** /**
@ -15,8 +14,6 @@ use function BenTools\CartesianProduct\combinations;
*/ */
class ProductSkusController extends AppController class ProductSkusController extends AppController
{ {
use OverrideTableTrait;
/** /**
* @return void * @return void
*/ */
@ -69,9 +66,7 @@ class ProductSkusController extends AppController
{ {
$toGetCartesianProductsFrom = []; $toGetCartesianProductsFrom = [];
$productSkus = []; $productSkus = [];
$table = $this->getTable(); $product = $this->ProductSkus->Products->get($productId, contain: [
$product = $table->Products->get($productId, contain: [
'ProductSkus', 'ProductSkus',
'ProductSkus.ProductSkuVariantValues', 'ProductSkus.ProductSkuVariantValues',
'ProductVariants', 'ProductVariants',
@ -103,7 +98,7 @@ class ProductSkusController extends AppController
$numSkusToAdd = count(combinations($toGetCartesianProductsFrom)); $numSkusToAdd = count(combinations($toGetCartesianProductsFrom));
for ($i = 0; $i < $numSkusToAdd; $i++) { for ($i = 0; $i < $numSkusToAdd; $i++) {
$productSkus[$i] = $this->getTable()->newEmptyEntity(); $productSkus[$i] = $this->ProductSkus->newEmptyEntity();
} }
$this->set(compact( $this->set(compact(
'product', 'product',
@ -159,13 +154,13 @@ class ProductSkusController extends AppController
return; return;
} }
// dd($finalPostData); // dd($finalPostData);
$productSkus = $table->patchEntities($productSkus, $finalPostData, $saveOptions); $productSkus = $this->ProductSkus->patchEntities($productSkus, $finalPostData, $saveOptions);
$errors = []; $errors = [];
$successes = []; $successes = [];
foreach ($productSkus as $productSkuToSave) { foreach ($productSkus as $productSkuToSave) {
// dd($productSkuToSave); // dd($productSkuToSave);
if (!$table->save($productSkuToSave, $saveOptions)) { if (!$this->ProductSkus->save($productSkuToSave, $saveOptions)) {
Log::debug(print_r('$productSkuToSave->getErrors()', true)); Log::debug(print_r('$productSkuToSave->getErrors()', true));
Log::debug(print_r($productSkuToSave->getErrors(), true)); Log::debug(print_r($productSkuToSave->getErrors(), true));
dd($productSkuToSave->getErrors()); dd($productSkuToSave->getErrors());
@ -245,7 +240,7 @@ class ProductSkusController extends AppController
*/ */
public function select() public function select()
{ {
$productSkus = $this->getTable() $productSkus = $this->ProductSkus
->find('list') ->find('list')
->where(['product_id' => $this->request->getQuery('product_id', '-1')]) ->where(['product_id' => $this->request->getQuery('product_id', '-1')])
->orderBy(['sku']) ->orderBy(['sku'])

View File

@ -3,7 +3,6 @@ declare(strict_types=1);
namespace CakeProducts\Controller; namespace CakeProducts\Controller;
use App\Controller\AppController;
use Cake\Log\Log; use Cake\Log\Log;
/** /**

View File

@ -7,9 +7,6 @@ use Cake\Core\Configure;
use Cake\Log\Log; use Cake\Log\Log;
use Cake\ORM\Table; use Cake\ORM\Table;
use Cake\ORM\TableRegistry; use Cake\ORM\TableRegistry;
use CakeProducts\Controller\AppController;
use CheeseCake\Controller\Traits\OverrideTableTrait;
;
/** /**
* Products Controller * Products Controller
@ -18,8 +15,6 @@ use CheeseCake\Controller\Traits\OverrideTableTrait;
*/ */
class ProductsController extends AppController class ProductsController extends AppController
{ {
use OverrideTableTrait;
/** /**
* @return void * @return void
*/ */
@ -37,7 +32,7 @@ class ProductsController extends AppController
*/ */
public function index() public function index()
{ {
$query = $this->getTable()->find() $query = $this->Products->find()
->contain(['ProductCategories']); ->contain(['ProductCategories']);
$products = $this->paginate($query); $products = $this->paginate($query);
@ -53,7 +48,7 @@ class ProductsController extends AppController
*/ */
public function view($id = null) public function view($id = null)
{ {
$product = $this->getTable()->get($id, contain: [ $product = $this->Products->get($id, contain: [
'ProductCategories', 'ProductCategories',
'ProductAttributes', 'ProductAttributes',
'ProductAttributes.ProductCategoryAttributes', 'ProductAttributes.ProductCategoryAttributes',
@ -74,7 +69,7 @@ class ProductsController extends AppController
*/ */
public function add() public function add()
{ {
$productsTable = $this->getTable(); $productsTable = $this->Products;
$product = $productsTable->newEmptyEntity(); $product = $productsTable->newEmptyEntity();
if ($this->request->is('post')) { if ($this->request->is('post')) {
$postData = $this->request->getData(); $postData = $this->request->getData();
@ -151,7 +146,7 @@ class ProductsController extends AppController
*/ */
public function edit($id = null) public function edit($id = null)
{ {
$productsTable = $this->getTable(); $productsTable = $this->Products;
$product = $productsTable->get($id, contain: [ $product = $productsTable->get($id, contain: [
'ProductAttributes', 'ProductAttributes',
'ProductAttributes.ProductCategoryAttributes', 'ProductAttributes.ProductCategoryAttributes',
@ -187,7 +182,7 @@ class ProductsController extends AppController
{ {
$this->request->allowMethod(['post', 'delete']); $this->request->allowMethod(['post', 'delete']);
$productsTable = $this->getTable(); $productsTable = $this->Products;
$product = $productsTable->get($id); $product = $productsTable->get($id);
if ($productsTable->delete($product)) { if ($productsTable->delete($product)) {
$this->Flash->success(__('The product has been deleted.')); $this->Flash->success(__('The product has been deleted.'));
@ -203,7 +198,7 @@ class ProductsController extends AppController
*/ */
public function select() public function select()
{ {
$productsTable = $this->getTable(); $productsTable = $this->Products;
$productCategory = $productsTable->ProductCategories->find() $productCategory = $productsTable->ProductCategories->find()
->where(['id' => $this->request->getQuery('product_category_id', '-1')]) ->where(['id' => $this->request->getQuery('product_category_id', '-1')])
->first(); ->first();

View File

@ -9,6 +9,11 @@ use FilesystemIterator;
use RecursiveDirectoryIterator; use RecursiveDirectoryIterator;
use RecursiveIteratorIterator; use RecursiveIteratorIterator;
/**
* BaseControllerTest
*
* Used to make logging in easier and to handle folder structure for product images
*/
class BaseControllerTest extends TestCase class BaseControllerTest extends TestCase
{ {
use IntegrationTestTrait; use IntegrationTestTrait;

View File

@ -11,12 +11,12 @@ use Cake\TestSuite\TestCase;
use CakeProducts\Controller\ExternalProductCatalogsController; use CakeProducts\Controller\ExternalProductCatalogsController;
use CakeProducts\Model\Table\ExternalProductCatalogsTable; use CakeProducts\Model\Table\ExternalProductCatalogsTable;
use PHPUnit\Exception; use PHPUnit\Exception;
use PHPUnit\Framework\Attributes\CoversClass;
/** /**
* CakeProducts\Controller\ExternalProductCatalogsController Test Case * CakeProducts\Controller\ExternalProductCatalogsController Test Case
*
* @uses \CakeProducts\Controller\ExternalProductCatalogsController
*/ */
#[CoversClass(ExternalProductCatalogsController::class)]
class ExternalProductCatalogsControllerTest extends BaseControllerTest class ExternalProductCatalogsControllerTest extends BaseControllerTest
{ {
/** /**

View File

@ -9,12 +9,12 @@ use Cake\TestSuite\IntegrationTestTrait;
use Cake\TestSuite\TestCase; use Cake\TestSuite\TestCase;
use CakeProducts\Model\Table\ExternalProductCatalogsProductCatalogsTable; use CakeProducts\Model\Table\ExternalProductCatalogsProductCatalogsTable;
use PHPUnit\Exception; use PHPUnit\Exception;
use PHPUnit\Framework\Attributes\CoversClass;
/** /**
* CakeProducts\Controller\ExternalProductCatalogsProductCatalogsController Test Case * CakeProducts\Controller\ExternalProductCatalogsProductCatalogsController Test Case
*
* @uses \CakeProducts\Controller\ExternalProductCatalogsProductCatalogsController
*/ */
#[CoversClass(ExternalProductCatalogsProductCatalogsController::class)]
class ExternalProductCatalogsProductCatalogsControllerTest extends BaseControllerTest class ExternalProductCatalogsProductCatalogsControllerTest extends BaseControllerTest
{ {
/** /**

View File

@ -9,12 +9,12 @@ use Cake\TestSuite\TestCase;
use CakeProducts\Controller\ProductCatalogsController; use CakeProducts\Controller\ProductCatalogsController;
use CakeProducts\Model\Table\ProductCatalogsTable; use CakeProducts\Model\Table\ProductCatalogsTable;
use PHPUnit\Exception; use PHPUnit\Exception;
use PHPUnit\Framework\Attributes\CoversClass;
/** /**
* CakeProducts\Controller\ProductCatalogsController Test Case * CakeProducts\Controller\ProductCatalogsController Test Case
*
* @uses \CakeProducts\Controller\ProductCatalogsController
*/ */
#[CoversClass(ProductCatalogsController::class)]
class ProductCatalogsControllerTest extends BaseControllerTest class ProductCatalogsControllerTest extends BaseControllerTest
{ {
/** /**

View File

@ -9,12 +9,12 @@ use Cake\TestSuite\TestCase;
use CakeProducts\Controller\ProductCategoriesController; use CakeProducts\Controller\ProductCategoriesController;
use CakeProducts\Model\Table\ProductCategoriesTable; use CakeProducts\Model\Table\ProductCategoriesTable;
use PHPUnit\Exception; use PHPUnit\Exception;
use PHPUnit\Framework\Attributes\CoversClass;
/** /**
* CakeProducts\Controller\ProductCategoriesController Test Case * CakeProducts\Controller\ProductCategoriesController Test Case
*
* @uses \CakeProducts\Controller\ProductCategoriesController
*/ */
#[CoversClass(ProductCategoriesController::class)]
class ProductCategoriesControllerTest extends BaseControllerTest class ProductCategoriesControllerTest extends BaseControllerTest
{ {
/** /**

View File

@ -7,12 +7,12 @@ use Cake\ORM\Table;
use CakeProducts\Controller\ProductCategoryAttributeOptionsController; use CakeProducts\Controller\ProductCategoryAttributeOptionsController;
use CakeProducts\Model\Table\ProductCategoryAttributeOptionsTable; use CakeProducts\Model\Table\ProductCategoryAttributeOptionsTable;
use PHPUnit\Exception; use PHPUnit\Exception;
use PHPUnit\Framework\Attributes\CoversClass;
/** /**
* CakeProducts\Controller\ProductCategoryAttributeOptionsController Test Case * CakeProducts\Controller\ProductCategoryAttributeOptionsController Test Case
*
* @uses \CakeProducts\Controller\ProductCategoryAttributeOptionsController
*/ */
#[CoversClass(ProductCategoryAttributeOptionsController::class)]
class ProductCategoryAttributeOptionsControllerTest extends BaseControllerTest class ProductCategoryAttributeOptionsControllerTest extends BaseControllerTest
{ {
/** /**

View File

@ -9,12 +9,12 @@ use Cake\TestSuite\TestCase;
use CakeProducts\Controller\ProductCategoryAttributesController; use CakeProducts\Controller\ProductCategoryAttributesController;
use CakeProducts\Model\Table\ProductCategoryAttributesTable; use CakeProducts\Model\Table\ProductCategoryAttributesTable;
use PHPUnit\Exception; use PHPUnit\Exception;
use PHPUnit\Framework\Attributes\CoversClass;
/** /**
* CakeProducts\Controller\ProductCategoryAttributesController Test Case * CakeProducts\Controller\ProductCategoryAttributesController Test Case
*
* @uses \CakeProducts\Controller\ProductCategoryAttributesController
*/ */
#[CoversClass(ProductCategoryAttributesController::class)]
class ProductCategoryAttributesControllerTest extends BaseControllerTest class ProductCategoryAttributesControllerTest extends BaseControllerTest
{ {
/** /**

View File

@ -9,12 +9,12 @@ use CakeProducts\Model\Table\ProductCategoryAttributesTable;
use CakeProducts\Model\Table\ProductCategoryVariantOptionsTable; use CakeProducts\Model\Table\ProductCategoryVariantOptionsTable;
use CakeProducts\Model\Table\ProductCategoryVariantsTable; use CakeProducts\Model\Table\ProductCategoryVariantsTable;
use PHPUnit\Exception; use PHPUnit\Exception;
use PHPUnit\Framework\Attributes\CoversClass;
/** /**
* CakeProducts\Controller\ProductCategoryVariantsController Test Case * CakeProducts\Controller\ProductCategoryVariantsController Test Case
*
* @uses \CakeProducts\Controller\ProductCategoryVariantsController
*/ */
#[CoversClass(ProductCategoryVariantsController::class)]
class ProductCategoryVariantsControllerTest extends BaseControllerTest class ProductCategoryVariantsControllerTest extends BaseControllerTest
{ {
/** /**

View File

@ -11,15 +11,15 @@ use CakeProducts\Model\Table\ProductsTable;
use FilesystemIterator; use FilesystemIterator;
use Laminas\Diactoros\UploadedFile; use Laminas\Diactoros\UploadedFile;
use PHPUnit\Exception; use PHPUnit\Exception;
use PHPUnit\Framework\Attributes\CoversClass;
use RecursiveDirectoryIterator; use RecursiveDirectoryIterator;
use RecursiveIteratorIterator; use RecursiveIteratorIterator;
use const UPLOAD_ERR_OK; use const UPLOAD_ERR_OK;
/** /**
* CakeProducts\Controller\ProductPhotosController Test Case * CakeProducts\Controller\ProductPhotosController Test Case
*
* @uses \CakeProducts\Controller\ProductPhotosController
*/ */
#[CoversClass(ProductPhotosController::class)]
class ProductPhotosControllerTest extends BaseControllerTest class ProductPhotosControllerTest extends BaseControllerTest
{ {
/** /**

View File

@ -11,12 +11,12 @@ use CakeProducts\Model\Table\ProductSkusTable;
use CakeProducts\Model\Table\ProductSkuVariantValuesTable; use CakeProducts\Model\Table\ProductSkuVariantValuesTable;
use CakeProducts\Model\Table\ProductsTable; use CakeProducts\Model\Table\ProductsTable;
use PHPUnit\Exception; use PHPUnit\Exception;
use PHPUnit\Framework\Attributes\CoversClass;
/** /**
* CakeProducts\Controller\ProductSkusController Test Case * CakeProducts\Controller\ProductSkusController Test Case
*
* @uses \CakeProducts\Controller\ProductSkusController
*/ */
#[CoversClass(ProductSkusController::class)]
class ProductSkusControllerTest extends BaseControllerTest class ProductSkusControllerTest extends BaseControllerTest
{ {
/** /**

View File

@ -10,12 +10,12 @@ use CakeProducts\Controller\ProductsController;
use CakeProducts\Model\Table\ProductCatalogsTable; use CakeProducts\Model\Table\ProductCatalogsTable;
use CakeProducts\Model\Table\ProductsTable; use CakeProducts\Model\Table\ProductsTable;
use PHPUnit\Exception; use PHPUnit\Exception;
use PHPUnit\Framework\Attributes\CoversClass;
/** /**
* CakeProducts\Controller\ProductsController Test Case * CakeProducts\Controller\ProductsController Test Case
*
* @uses \CakeProducts\Controller\ProductsController
*/ */
#[CoversClass(ProductsController::class)]
class ProductsControllerTest extends BaseControllerTest class ProductsControllerTest extends BaseControllerTest
{ {
/** /**

View File

@ -6,10 +6,12 @@ namespace CakeProducts\Test\TestCase\Model\Table;
use Cake\ORM\Table; use Cake\ORM\Table;
use Cake\TestSuite\TestCase; use Cake\TestSuite\TestCase;
use CakeProducts\Model\Table\ExternalProductCatalogsTable; use CakeProducts\Model\Table\ExternalProductCatalogsTable;
use PHPUnit\Framework\Attributes\CoversClass;
/** /**
* CakeProducts\Model\Table\ExternalProductCatalogsTable Test Case * CakeProducts\Model\Table\ExternalProductCatalogsTable Test Case
*/ */
#[CoversClass(ExternalProductCatalogsTable::class)]
class ExternalProductCatalogsTableTest extends TestCase class ExternalProductCatalogsTableTest extends TestCase
{ {
/** /**

View File

@ -6,10 +6,12 @@ namespace CakeProducts\Test\TestCase\Model\Table;
use Cake\ORM\Table; use Cake\ORM\Table;
use Cake\TestSuite\TestCase; use Cake\TestSuite\TestCase;
use CakeProducts\Model\Table\ProductCatalogsTable; use CakeProducts\Model\Table\ProductCatalogsTable;
use PHPUnit\Framework\Attributes\CoversClass;
/** /**
* CakeProducts\Model\Table\ProductCatalogsTable Test Case * CakeProducts\Model\Table\ProductCatalogsTable Test Case
*/ */
#[CoversClass(ProductCatalogsTable::class)]
class ProductCatalogsTableTest extends TestCase class ProductCatalogsTableTest extends TestCase
{ {
/** /**

View File

@ -5,10 +5,12 @@ namespace CakeProducts\Test\TestCase\Model\Table;
use Cake\TestSuite\TestCase; use Cake\TestSuite\TestCase;
use CakeProducts\Model\Table\ProductCategoriesTable; use CakeProducts\Model\Table\ProductCategoriesTable;
use PHPUnit\Framework\Attributes\CoversClass;
/** /**
* CakeProducts\Model\Table\ProductCategoriesTable Test Case * CakeProducts\Model\Table\ProductCategoriesTable Test Case
*/ */
#[CoversClass(ProductCategoriesTable::class)]
class ProductCategoriesTableTest extends TestCase class ProductCategoriesTableTest extends TestCase
{ {
/** /**

View File

@ -5,10 +5,12 @@ namespace CakeProducts\Test\TestCase\Model\Table;
use Cake\TestSuite\TestCase; use Cake\TestSuite\TestCase;
use CakeProducts\Model\Table\ProductCategoryAttributeOptionsTable; use CakeProducts\Model\Table\ProductCategoryAttributeOptionsTable;
use PHPUnit\Framework\Attributes\CoversClass;
/** /**
* CakeProducts\Model\Table\ProductCategoryAttributeOptionsTable Test Case * CakeProducts\Model\Table\ProductCategoryAttributeOptionsTable Test Case
*/ */
#[CoversClass(ProductCategoryAttributeOptionsTable::class)]
class ProductCategoryAttributeOptionsTableTest extends TestCase class ProductCategoryAttributeOptionsTableTest extends TestCase
{ {
/** /**

View File

@ -5,10 +5,12 @@ namespace CakeProducts\Test\TestCase\Model\Table;
use Cake\TestSuite\TestCase; use Cake\TestSuite\TestCase;
use CakeProducts\Model\Table\ProductCategoryAttributesTable; use CakeProducts\Model\Table\ProductCategoryAttributesTable;
use PHPUnit\Framework\Attributes\CoversClass;
/** /**
* CakeProducts\Model\Table\ProductCategoryAttributesTable Test Case * CakeProducts\Model\Table\ProductCategoryAttributesTable Test Case
*/ */
#[CoversClass(ProductCategoryAttributesTable::class)]
class ProductCategoryAttributesTableTest extends TestCase class ProductCategoryAttributesTableTest extends TestCase
{ {
/** /**

View File

@ -5,10 +5,12 @@ namespace CakeProducts\Test\TestCase\Model\Table;
use CakeProducts\Model\Table\ProductCategoryVariantOptionsTable; use CakeProducts\Model\Table\ProductCategoryVariantOptionsTable;
use Cake\TestSuite\TestCase; use Cake\TestSuite\TestCase;
use PHPUnit\Framework\Attributes\CoversClass;
/** /**
* App\Model\Table\ProductCategoryVariantOptionsTable Test Case * App\Model\Table\ProductCategoryVariantOptionsTable Test Case
*/ */
#[CoversClass(ProductCategoryVariantOptionsTable::class)]
class ProductCategoryVariantOptionsTableTest extends TestCase class ProductCategoryVariantOptionsTableTest extends TestCase
{ {
/** /**

View File

@ -57,7 +57,6 @@ class ProductVariantsTableTest extends TestCase
* TestInitialize method * TestInitialize method
* *
* @return void * @return void
* @uses \App\Model\Table\ProductVariantsTable::initialize()
*/ */
public function testInitialize(): void public function testInitialize(): void
{ {

View File

@ -5,10 +5,12 @@ namespace CakeProducts\Test\TestCase\Model\Table;
use Cake\TestSuite\TestCase; use Cake\TestSuite\TestCase;
use CakeProducts\Model\Table\ProductsTable; use CakeProducts\Model\Table\ProductsTable;
use PHPUnit\Framework\Attributes\CoversClass;
/** /**
* CakeProducts\Model\Table\ProductsTable Test Case * CakeProducts\Model\Table\ProductsTable Test Case
*/ */
#[CoversClass(ProductsTable::class)]
class ProductsTableTest extends TestCase class ProductsTableTest extends TestCase
{ {
/** /**