product photos controller test fixes, test out
This commit is contained in:
@@ -80,7 +80,6 @@ class ProductPhotosController extends AppController
|
||||
|
||||
if (!file_exists($path)) {
|
||||
if (!mkdir($path, 0777, true)) {
|
||||
dd('Failed to create the required folders. Please check the folder permissions and try again. PATH: ' . $path);
|
||||
throw new ForbiddenException('Failed to create the required folders. Please check the folder permissions and try again.');
|
||||
}
|
||||
}
|
||||
@@ -89,7 +88,6 @@ class ProductPhotosController extends AppController
|
||||
// Existing files with the same name will be replaced.
|
||||
$photoObject->moveTo($destination);
|
||||
if (!file_exists($destination)) {
|
||||
dd('Failed to move the uploaded image to the appropriate folder. Please try again.');
|
||||
throw new ForbiddenException('Failed to move the uploaded image to the appropriate folder. Please try again.');
|
||||
}
|
||||
$postData['photo_dir'] = $path;
|
||||
@@ -100,14 +98,13 @@ class ProductPhotosController extends AppController
|
||||
|
||||
return $this->redirect(['action' => 'index']);
|
||||
}
|
||||
dd(print_r($productPhoto->getErrors(), true));
|
||||
$this->Flash->error(__('The product photo could not be saved. Please, try again.'));
|
||||
}
|
||||
$products = $productPhotosTable->Products->find('list', limit: 200)->all();
|
||||
$this->set(compact('productPhoto', 'products'));
|
||||
}
|
||||
|
||||
/**
|
||||
d /**
|
||||
* Edit method
|
||||
*
|
||||
* @param string|null $id Product Photo id.
|
||||
@@ -119,13 +116,14 @@ class ProductPhotosController extends AppController
|
||||
$productPhotosTable = $this->getTable();
|
||||
$productPhoto = $productPhotosTable->get($id, contain: []);
|
||||
if ($this->request->is(['patch', 'post', 'put'])) {
|
||||
$productPhoto = $productPhotosTable->patchEntity($productPhoto, $this->request->getData());
|
||||
$postData = $this->request->getData();
|
||||
|
||||
$productPhoto = $productPhotosTable->patchEntity($productPhoto, $postData);
|
||||
if ($productPhotosTable->save($productPhoto)) {
|
||||
$this->Flash->success(__('The product photo has been saved.'));
|
||||
|
||||
return $this->redirect(['action' => 'index']);
|
||||
}
|
||||
dd(print_r($productPhoto->getErrors(), true));
|
||||
$this->Flash->error(__('The product photo could not be saved. Please, try again.'));
|
||||
}
|
||||
$products = $productPhotosTable->Products->find('list', limit: 200)->all();
|
||||
|
||||
Reference in New Issue
Block a user