Commit db5b18f0 authored by Julie gauthier's avatar Julie gauthier

Merge branch '685-maj-3-4-request-response-deprecations' into 'develop'

Resolve "maj 3.4 Request & Response Deprecations"

Closes #685

See merge request !258
parents 3783dd3d 7dbdb715
Pipeline #5305 failed with stage
in 6 minutes and 59 seconds
<?php <?php
namespace App\Controller\Api\V1; namespace App\Controller\Api\V1;
use App\Controller\AppController; use App\Controller\AppController;
...@@ -53,7 +54,7 @@ class LicenceTypesController extends AppController ...@@ -53,7 +54,7 @@ class LicenceTypesController extends AppController
{ {
$licenceType = $this->LicenceTypes->newEntity(); $licenceType = $this->LicenceTypes->newEntity();
if ($this->request->is('post')) { if ($this->request->is('post')) {
$licenceType = $this->LicenceTypes->patchEntity($licenceType, $this->request->data); $licenceType = $this->LicenceTypes->patchEntity($licenceType, $this->request->getData());
if ($this->LicenceTypes->save($licenceType)) { if ($this->LicenceTypes->save($licenceType)) {
$this->Flash->success(__('The licence type has been saved.')); $this->Flash->success(__('The licence type has been saved.'));
return $this->redirect(['action' => 'index']); return $this->redirect(['action' => 'index']);
...@@ -62,8 +63,8 @@ class LicenceTypesController extends AppController ...@@ -62,8 +63,8 @@ class LicenceTypesController extends AppController
$errors = $licenceType->errors(); $errors = $licenceType->errors();
} }
} }
$this->set(compact(['licenceType','errors'])); $this->set(compact(['licenceType', 'errors']));
$this->set('_serialize', ['licenceType','errors']); $this->set('_serialize', ['licenceType', 'errors']);
} }
/** /**
...@@ -82,7 +83,7 @@ class LicenceTypesController extends AppController ...@@ -82,7 +83,7 @@ class LicenceTypesController extends AppController
] ]
); );
if ($this->request->is(['patch', 'post', 'put'])) { if ($this->request->is(['patch', 'post', 'put'])) {
$licenceType = $this->LicenceTypes->patchEntity($licenceType, $this->request->data); $licenceType = $this->LicenceTypes->patchEntity($licenceType, $this->request->getData());
if ($this->LicenceTypes->save($licenceType)) { if ($this->LicenceTypes->save($licenceType)) {
$this->Flash->success(__('The licence type has been saved.')); $this->Flash->success(__('The licence type has been saved.'));
return $this->redirect(['action' => 'index']); return $this->redirect(['action' => 'index']);
......
...@@ -57,7 +57,7 @@ class LicensesController extends AppController ...@@ -57,7 +57,7 @@ class LicensesController extends AppController
{ {
$license = $this->Licenses->newEntity(); $license = $this->Licenses->newEntity();
if ($this->request->is('post')) { if ($this->request->is('post')) {
$license = $this->Licenses->patchEntity($license, $this->request->data); $license = $this->Licenses->patchEntity($license, $this->request->getData());
if ($this->Licenses->save($license)) { if ($this->Licenses->save($license)) {
$this->Flash->success(__('The license has been saved.')); $this->Flash->success(__('The license has been saved.'));
return $this->redirect(['action' => 'index']); return $this->redirect(['action' => 'index']);
...@@ -86,7 +86,7 @@ class LicensesController extends AppController ...@@ -86,7 +86,7 @@ class LicensesController extends AppController
] ]
); );
if ($this->request->is(['patch', 'post', 'put'])) { if ($this->request->is(['patch', 'post', 'put'])) {
$license = $this->Licenses->patchEntity($license, $this->request->data); $license = $this->Licenses->patchEntity($license, $this->request->getData());
if ($this->Licenses->save($license)) { if ($this->Licenses->save($license)) {
$this->Flash->success(__('The license has been saved.')); $this->Flash->success(__('The license has been saved.'));
return $this->redirect(['action' => 'index']); return $this->redirect(['action' => 'index']);
......
...@@ -99,8 +99,10 @@ class PagesController extends AppController ...@@ -99,8 +99,10 @@ class PagesController extends AppController
$Softwares = TableRegistry::get("Softwares"); $Softwares = TableRegistry::get("Softwares");
//TO SORT //TO SORT
if (isset($this->request->query["order"])) { if (!is_null($this->request->getQuery("order"))) {
$sort = explode(".", $this->request->query["order"]); $sort = explode(".", $this->request->getQuery("order"));
// Note JGauthier 2019-07-16: just discovered this horror. This is not the correct way to do this.
// TODO This should be fixed
$this->request->query["sort"] = $sort[0]; $this->request->query["sort"] = $sort[0];
$this->request->query["direction"] = $sort[1]; $this->request->query["direction"] = $sort[1];
} }
...@@ -122,20 +124,22 @@ class PagesController extends AppController ...@@ -122,20 +124,22 @@ class PagesController extends AppController
] ]
]; ];
if (isset($this->request->data["search"])) { if (null !== ($this->request->getData("search"))) {
$searchQuery = $this->request->data["search"]; $searchQuery = $this->request->getData("search");
} else { } else {
$searchQuery = $this->request->query["search"]; $searchQuery = $this->request->getData("search");
} }
$this->set('searchQuery', $searchQuery); $this->set('searchQuery', $searchQuery);
// keep spaces , uppercase and transiterate accent characters to non-accent characters. // keep spaces , uppercase and transiterate accent characters to non-accent characters.
// Note JGauthier 2019-07-16: just discovered this horror. This is not the correct way to do this.
// TODO This should be fixed
$this->request->query['search'] = strtoupper(Text::slug($searchQuery)); $this->request->query['search'] = strtoupper(Text::slug($searchQuery));
$softwares = $Softwares $softwares = $Softwares
->find( ->find(
'search', 'search',
[ [
'search' => $this->request->query, 'search' => $this->request->getQueryParams(),
"contain" => ["Reviews"], "contain" => ["Reviews"],
] ]
) )
...@@ -155,7 +159,7 @@ class PagesController extends AppController ...@@ -155,7 +159,7 @@ class PagesController extends AppController
->find( ->find(
'search', 'search',
[ [
'search' => $this->request->query, 'search' => $this->request->getQueryParams(),
'contain' => ['UserTypes'], 'contain' => ['UserTypes'],
'order' => [ 'order' => [
'Users.username' => Configure::read('ORDER') 'Users.username' => Configure::read('ORDER')
...@@ -199,11 +203,11 @@ class PagesController extends AppController ...@@ -199,11 +203,11 @@ class PagesController extends AppController
$this->set('hasServiceProvider', $hasServiceProvider); $this->set('hasServiceProvider', $hasServiceProvider);
$this->set('order', $order); $this->set('order', $order);
$this->set('screenCaptured', $screenCaptured); $this->set('screenCaptured', $screenCaptured);
// $this->set('sort',$this->request->data['sort']); // $this->set('sort',$this->request->getData('sort'));
// $this->set('direction',$this->request->data['direction']); // $this->set('direction',$this->request->getData('direction'));
//To populate SearchForm //To populate SearchForm
$this->request->data = $this->request->query; $this->request->getData($this->request->getQueryParams());
$this->set('softwares', $this->paginate($softwares)); $this->set('softwares', $this->paginate($softwares));
$this->set('users', $this->paginate($this->Users)); $this->set('users', $this->paginate($this->Users));
......
...@@ -61,7 +61,10 @@ class RawMetricsSoftwaresController extends AppController ...@@ -61,7 +61,10 @@ class RawMetricsSoftwaresController extends AppController
{ {
$rawMetricsSoftware = $this->RawMetricsSoftwares->newEntity(); $rawMetricsSoftware = $this->RawMetricsSoftwares->newEntity();
if ($this->request->is('post')) { if ($this->request->is('post')) {
$rawMetricsSoftware = $this->RawMetricsSoftwares->patchEntity($rawMetricsSoftware, $this->request->data); $rawMetricsSoftware = $this->RawMetricsSoftwares->patchEntity(
$rawMetricsSoftware,
$this->request->getData()
);
if ($this->RawMetricsSoftwares->save($rawMetricsSoftware)) { if ($this->RawMetricsSoftwares->save($rawMetricsSoftware)) {
$this->Flash->success(__('The raw metrics software has been saved.')); $this->Flash->success(__('The raw metrics software has been saved.'));
return $this->redirect(['action' => 'index']); return $this->redirect(['action' => 'index']);
...@@ -90,7 +93,10 @@ class RawMetricsSoftwaresController extends AppController ...@@ -90,7 +93,10 @@ class RawMetricsSoftwaresController extends AppController
] ]
); );
if ($this->request->is(['patch', 'post', 'put'])) { if ($this->request->is(['patch', 'post', 'put'])) {
$rawMetricsSoftware = $this->RawMetricsSoftwares->patchEntity($rawMetricsSoftware, $this->request->data); $rawMetricsSoftware = $this->RawMetricsSoftwares->patchEntity(
$rawMetricsSoftware,
$this->request->getData()
);
if ($this->RawMetricsSoftwares->save($rawMetricsSoftware)) { if ($this->RawMetricsSoftwares->save($rawMetricsSoftware)) {
$this->Flash->success(__('The raw metrics software has been saved.')); $this->Flash->success(__('The raw metrics software has been saved.'));
return $this->redirect(['action' => 'index']); return $this->redirect(['action' => 'index']);
......
...@@ -54,7 +54,7 @@ class RelationshipTypesController extends AppController ...@@ -54,7 +54,7 @@ class RelationshipTypesController extends AppController
{ {
$relationshipType = $this->RelationshipTypes->newEntity(); $relationshipType = $this->RelationshipTypes->newEntity();
if ($this->request->is('post')) { if ($this->request->is('post')) {
$relationshipType = $this->RelationshipTypes->patchEntity($relationshipType, $this->request->data); $relationshipType = $this->RelationshipTypes->patchEntity($relationshipType, $this->request->getData());
if ($this->RelationshipTypes->save($relationshipType)) { if ($this->RelationshipTypes->save($relationshipType)) {
$this->Flash->success(__('The relationship type has been saved.')); $this->Flash->success(__('The relationship type has been saved.'));
return $this->redirect(['action' => 'index']); return $this->redirect(['action' => 'index']);
...@@ -82,7 +82,7 @@ class RelationshipTypesController extends AppController ...@@ -82,7 +82,7 @@ class RelationshipTypesController extends AppController
] ]
); );
if ($this->request->is(['patch', 'post', 'put'])) { if ($this->request->is(['patch', 'post', 'put'])) {
$relationshipType = $this->RelationshipTypes->patchEntity($relationshipType, $this->request->data); $relationshipType = $this->RelationshipTypes->patchEntity($relationshipType, $this->request->getData());
if ($this->RelationshipTypes->save($relationshipType)) { if ($this->RelationshipTypes->save($relationshipType)) {
$this->Flash->success(__('The relationship type has been saved.')); $this->Flash->success(__('The relationship type has been saved.'));
return $this->redirect(['action' => 'index']); return $this->redirect(['action' => 'index']);
......
...@@ -59,7 +59,7 @@ class RelationshipsController extends AppController ...@@ -59,7 +59,7 @@ class RelationshipsController extends AppController
{ {
$relationship = $this->Relationships->newEntity(); $relationship = $this->Relationships->newEntity();
if ($this->request->is('post')) { if ($this->request->is('post')) {
$relationship = $this->Relationships->patchEntity($relationship, $this->request->data); $relationship = $this->Relationships->patchEntity($relationship, $this->request->getData());
if ($this->Relationships->save($relationship)) { if ($this->Relationships->save($relationship)) {
$this->Flash->success(__('The relationship has been saved.')); $this->Flash->success(__('The relationship has been saved.'));
return $this->redirect(['action' => 'index']); return $this->redirect(['action' => 'index']);
...@@ -90,7 +90,7 @@ class RelationshipsController extends AppController ...@@ -90,7 +90,7 @@ class RelationshipsController extends AppController
] ]
); );
if ($this->request->is(['patch', 'post', 'put'])) { if ($this->request->is(['patch', 'post', 'put'])) {
$relationship = $this->Relationships->patchEntity($relationship, $this->request->data); $relationship = $this->Relationships->patchEntity($relationship, $this->request->getData());
if ($this->Relationships->save($relationship)) { if ($this->Relationships->save($relationship)) {
$this->Flash->success(__('The relationship has been saved.')); $this->Flash->success(__('The relationship has been saved.'));
return $this->redirect(['action' => 'index']); return $this->redirect(['action' => 'index']);
......
...@@ -69,7 +69,7 @@ class RelationshipsSoftwaresController extends AppController ...@@ -69,7 +69,7 @@ class RelationshipsSoftwaresController extends AppController
if ($this->request->is('post')) { if ($this->request->is('post')) {
$relationshipsSoftware = $this->RelationshipsSoftwares->patchEntity( $relationshipsSoftware = $this->RelationshipsSoftwares->patchEntity(
$relationshipsSoftware, $relationshipsSoftware,
$this->request->data $this->request->getData()
); );
if ($this->RelationshipsSoftwares->save($relationshipsSoftware)) { if ($this->RelationshipsSoftwares->save($relationshipsSoftware)) {
$this->Flash->success(__('The relationships software has been saved.')); $this->Flash->success(__('The relationships software has been saved.'));
...@@ -102,7 +102,7 @@ class RelationshipsSoftwaresController extends AppController ...@@ -102,7 +102,7 @@ class RelationshipsSoftwaresController extends AppController
if ($this->request->is(['patch', 'post', 'put'])) { if ($this->request->is(['patch', 'post', 'put'])) {
$relationshipsSoftware = $this->RelationshipsSoftwares->patchEntity( $relationshipsSoftware = $this->RelationshipsSoftwares->patchEntity(
$relationshipsSoftware, $relationshipsSoftware,
$this->request->data $this->request->getData()
); );
if ($this->RelationshipsSoftwares->save($relationshipsSoftware)) { if ($this->RelationshipsSoftwares->save($relationshipsSoftware)) {
$this->Flash->success(__('The relationships software has been saved.')); $this->Flash->success(__('The relationships software has been saved.'));
......
...@@ -40,7 +40,7 @@ class RelationshipsSoftwaresUsersController extends AppController ...@@ -40,7 +40,7 @@ class RelationshipsSoftwaresUsersController extends AppController
'all', 'all',
[ [
'contain' => ["Users", "Relationships"], 'contain' => ["Users", "Relationships"],
'conditions' => ["Relationships.cd = " => $this->request->query['Relationships']], 'conditions' => ["Relationships.cd = " => $this->request->getQuery('Relationships')],
] ]
) )
->distinct("user_id"); ->distinct("user_id");
...@@ -90,7 +90,7 @@ class RelationshipsSoftwaresUsersController extends AppController ...@@ -90,7 +90,7 @@ class RelationshipsSoftwaresUsersController extends AppController
if ($this->request->is('post') && !$this->request->is('json')) { if ($this->request->is('post') && !$this->request->is('json')) {
$relationshipsSoftwaresUser = $this->RelationshipsSoftwaresUsers->patchEntity( $relationshipsSoftwaresUser = $this->RelationshipsSoftwaresUsers->patchEntity(
$relationshipsSoftwaresUser, $relationshipsSoftwaresUser,
$this->request->data $this->request->getData()
); );
if ($this->RelationshipsSoftwaresUsers->save($relationshipsSoftwaresUser)) { if ($this->RelationshipsSoftwaresUsers->save($relationshipsSoftwaresUser)) {
$this->Flash->success(__('The relationships softwares user has been saved.')); $this->Flash->success(__('The relationships softwares user has been saved.'));
...@@ -106,7 +106,7 @@ class RelationshipsSoftwaresUsersController extends AppController ...@@ -106,7 +106,7 @@ class RelationshipsSoftwaresUsersController extends AppController
} elseif ($this->request->is('post') && $this->request->is('json')) { } elseif ($this->request->is('post') && $this->request->is('json')) {
$relationshipsSoftwaresUser = $this->RelationshipsSoftwaresUsers->patchEntity( $relationshipsSoftwaresUser = $this->RelationshipsSoftwaresUsers->patchEntity(
$relationshipsSoftwaresUser, $relationshipsSoftwaresUser,
$this->request->data $this->request->getData()
); );
if ($this->RelationshipsSoftwaresUsers->save($relationshipsSoftwaresUser)) { if ($this->RelationshipsSoftwaresUsers->save($relationshipsSoftwaresUser)) {
$message = "Success"; $message = "Success";
...@@ -153,7 +153,7 @@ class RelationshipsSoftwaresUsersController extends AppController ...@@ -153,7 +153,7 @@ class RelationshipsSoftwaresUsersController extends AppController
if ($this->request->is(['patch', 'post', 'put']) && !$this->request->is('json')) { if ($this->request->is(['patch', 'post', 'put']) && !$this->request->is('json')) {
$relationshipsSoftwaresUser = $this->RelationshipsSoftwaresUsers->patchEntity( $relationshipsSoftwaresUser = $this->RelationshipsSoftwaresUsers->patchEntity(
$relationshipsSoftwaresUser, $relationshipsSoftwaresUser,
$this->request->data $this->request->getData()
); );
if ($this->RelationshipsSoftwaresUsers->save($relationshipsSoftwaresUser)) { if ($this->RelationshipsSoftwaresUsers->save($relationshipsSoftwaresUser)) {
$this->Flash->success(__('The relationships softwares user has been saved.')); $this->Flash->success(__('The relationships softwares user has been saved.'));
...@@ -170,7 +170,7 @@ class RelationshipsSoftwaresUsersController extends AppController ...@@ -170,7 +170,7 @@ class RelationshipsSoftwaresUsersController extends AppController
} elseif ($this->request->is(['patch', 'post', 'put']) && $this->request->is('json')) { } elseif ($this->request->is(['patch', 'post', 'put']) && $this->request->is('json')) {
$relationshipsSoftwaresUser = $this->RelationshipsSoftwaresUsers->patchEntity( $relationshipsSoftwaresUser = $this->RelationshipsSoftwaresUsers->patchEntity(
$relationshipsSoftwaresUser, $relationshipsSoftwaresUser,
$this->request->data $this->request->getData()
); );
if ($this->RelationshipsSoftwaresUsers->save($relationshipsSoftwaresUser)) { if ($this->RelationshipsSoftwaresUsers->save($relationshipsSoftwaresUser)) {
$message = "Success"; $message = "Success";
......
...@@ -57,7 +57,7 @@ class RelationshipsUsersController extends AppController ...@@ -57,7 +57,7 @@ class RelationshipsUsersController extends AppController
{ {
$relationshipsUser = $this->RelationshipsUsers->newEntity(); $relationshipsUser = $this->RelationshipsUsers->newEntity();
if ($this->request->is('post')) { if ($this->request->is('post')) {
$relationshipsUser = $this->RelationshipsUsers->patchEntity($relationshipsUser, $this->request->data); $relationshipsUser = $this->RelationshipsUsers->patchEntity($relationshipsUser, $this->request->getData());
if ($this->RelationshipsUsers->save($relationshipsUser)) { if ($this->RelationshipsUsers->save($relationshipsUser)) {
$this->Flash->success(__('The relationships user has been saved.')); $this->Flash->success(__('The relationships user has been saved.'));
return $this->redirect(['action' => 'index']); return $this->redirect(['action' => 'index']);
...@@ -87,7 +87,7 @@ class RelationshipsUsersController extends AppController ...@@ -87,7 +87,7 @@ class RelationshipsUsersController extends AppController
] ]
); );
if ($this->request->is(['patch', 'post', 'put'])) { if ($this->request->is(['patch', 'post', 'put'])) {
$relationshipsUser = $this->RelationshipsUsers->patchEntity($relationshipsUser, $this->request->data); $relationshipsUser = $this->RelationshipsUsers->patchEntity($relationshipsUser, $this->request->getData());
if ($this->RelationshipsUsers->save($relationshipsUser)) { if ($this->RelationshipsUsers->save($relationshipsUser)) {
$this->Flash->success(__('The relationships user has been saved.')); $this->Flash->success(__('The relationships user has been saved.'));
return $this->redirect(['action' => 'index']); return $this->redirect(['action' => 'index']);
......
...@@ -44,19 +44,19 @@ class ReviewsController extends AppController ...@@ -44,19 +44,19 @@ class ReviewsController extends AppController
public function index() public function index()
{ {
if (isset($this->request->params['software_id'])) { if (!is_null($this->request->getParam('software_id'))) {
$this->viewBuilder()->setTemplate("reviews_software"); $this->viewBuilder()->setTemplate("reviews_software");
$software = $this->Reviews->Softwares->find("all")->select([ $software = $this->Reviews->Softwares->find("all")->select([
"id", "id",
"softwarename" "softwarename"
])->where(["id" => $this->request->params['software_id']])->firstOrFail(); ])->where(["id" => $this->request->getParam('software_id')])->firstOrFail();
$this->set('software', $software); $this->set('software', $software);
$this->set('_serialize', ['software']); $this->set('_serialize', ['software']);
} }
$this->paginate = [ $this->paginate = [
'conditions' => isset($this->request->params['software_id']) ? [ 'conditions' => !is_null($this->request->getParam('software_id')) ? [
'Softwares.id ' => $this->request->params['software_id'] 'Softwares.id ' => $this->request->getParam('software_id')
] : [], ] : [],
'contain' => [ 'contain' => [
'Users' => ["fields" => ["id", "username", 'logo_directory', 'photo',]], 'Users' => ["fields" => ["id", "username", 'logo_directory', 'photo',]],
...@@ -123,34 +123,34 @@ class ReviewsController extends AppController ...@@ -123,34 +123,34 @@ class ReviewsController extends AppController
$message = ""; $message = "";
if ($this->request->is('post')) { if ($this->request->is('post')) {
try { try {
$software = $this->Reviews->Softwares->get($this->request->params['software_id']); $software = $this->Reviews->Softwares->get($this->request->getParam('software_id'));
$this->request->data['software_id'] = $software->id; $this->request->getData($software->id);
} catch (Exception $e) { } catch (Exception $e) {
throw new SoftwareNotFoundException( throw new SoftwareNotFoundException(
"The software with the id " . $this->request->params['software_id'] . " does not exist" "The software with the id " . $this->request->getParam('software_id') . " does not exist"
); );
} }
try { try {
$user = $this->Reviews->Users->get($this->Auth->user('id')); $user = $this->Reviews->Users->get($this->Auth->user('id'));
$this->request->data['user_id'] = $user->id; $this->request->getData($user->id);
} catch (Exception $e) { } catch (Exception $e) {
throw new UserNotFoundException("The user with the id " . $this->Auth->user('id') . " does not exist"); throw new UserNotFoundException("The user with the id " . $this->Auth->user('id') . " does not exist");
} }
$review = $this->Reviews->patchEntity($review, $this->request->data); $review = $this->Reviews->patchEntity($review, $this->request->getData());
if ($this->Reviews->save($review)) { if ($this->Reviews->save($review)) {
$message = "Success"; $message = "Success";
if (!$this->request->is('json')) { if (!$this->request->is('json')) {
$this->Flash->success(__d("Forms", "Your review has been posted")); $this->Flash->success(__d("Forms", "Your review has been posted"));
$this->redirect("softwares/" . $this->request->data['software_id']); $this->redirect("softwares/" . $this->request->getData('software_id'));
} }
} else { } else {
if (!$this->request->is('json')) { if (!$this->request->is('json')) {
$this->Flash->error(__d("Forms", "You can not post more than one review for a software.")); $this->Flash->error(__d("Forms", "You can not post more than one review for a software."));
$this->redirect("softwares/" . $this->request->data['software_id']); $this->redirect("softwares/" . $this->request->getData('software_id'));
} else { } else {
$message = "Error"; $message = "Error";
$review = $review->errors(); $review = $review->errors();
...@@ -182,7 +182,7 @@ class ReviewsController extends AppController ...@@ -182,7 +182,7 @@ class ReviewsController extends AppController
] ]
); );
if ($this->request->is(['patch', 'post', 'put'])) { if ($this->request->is(['patch', 'post', 'put'])) {
$review = $this->Reviews->patchEntity($review, $this->request->data); $review = $this->Reviews->patchEntity($review, $this->request->getData());
if ($this->Reviews->save($review)) { if ($this->Reviews->save($review)) {
$this->Flash->success(__('The review has been saved.')); $this->Flash->success(__('The review has been saved.'));
return $this->redirect(['action' => 'index']); return $this->redirect(['action' => 'index']);
......
...@@ -22,19 +22,19 @@ class ScreenshotsController extends AppController ...@@ -22,19 +22,19 @@ class ScreenshotsController extends AppController
*/ */
public function index() public function index()
{ {
if (isset($this->request->params['software_id'])) { if (! is_null($this->request->getParam('software_id'))) {
$this->viewBuilder()->setTemplate("screenshots_software"); $this->viewBuilder()->setTemplate("screenshots_software");
$software = $this->Screenshots->Softwares->find("all")->select([ $software = $this->Screenshots->Softwares->find("all")->select([
"id", "id",
"softwarename" "softwarename"
])->where(["id" => $this->request->params['software_id']])->firstOrFail(); ])->where(["id" => $this->request->getParam('software_id')])->firstOrFail();
$this->set('software', $software); $this->set('software', $software);
$this->set('_serialize', ['software']); $this->set('_serialize', ['software']);
} }
$this->paginate = [ $this->paginate = [
'conditions' => isset($this->request->params['software_id']) ? [ 'conditions' => ! is_null($this->request->getParam('software_id')) ? [
'Softwares.id ' => $this->request->params['software_id'] 'Softwares.id ' => $this->request->getParam('software_id')
] : [], ] : [],
'contain' => [ 'contain' => [
'Softwares' 'Softwares'
...@@ -73,7 +73,7 @@ class ScreenshotsController extends AppController ...@@ -73,7 +73,7 @@ class ScreenshotsController extends AppController
{ {
$screenshot = $this->Screenshots->newEntity(); $screenshot = $this->Screenshots->newEntity();
if ($this->request->is('post')) { if ($this->request->is('post')) {
$screenshot = $this->Screenshots->patchEntity($screenshot, $this->request->data); $screenshot = $this->Screenshots->patchEntity($screenshot, $this->request->getData());
if ($this->Screenshots->save($screenshot)) { if ($this->Screenshots->save($screenshot)) {
$this->Flash->success(__('The screenshot has been saved.')); $this->Flash->success(__('The screenshot has been saved.'));
return $this->redirect(['action' => 'index']); return $this->redirect(['action' => 'index']);
...@@ -102,7 +102,7 @@ class ScreenshotsController extends AppController ...@@ -102,7 +102,7 @@ class ScreenshotsController extends AppController
] ]
); );
if ($this->request->is(['patch', 'post', 'put'])) { if ($this->request->is(['patch', 'post', 'put'])) {
$screenshot = $this->Screenshots->patchEntity($screenshot, $this->request->data); $screenshot = $this->Screenshots->patchEntity($screenshot, $this->request->getData());
if ($this->Screenshots->save($screenshot)) { if ($this->Screenshots->save($screenshot)) {
$this->Flash->success(__('The screenshot has been saved.')); $this->Flash->success(__('The screenshot has been saved.'));
return $this->redirect(['action' => 'index']); return $this->redirect(['action' => 'index']);
......
...@@ -107,8 +107,8 @@ class SoftwaresController extends AppController ...@@ -107,8 +107,8 @@ class SoftwaresController extends AppController
$this->request->allowMethod(['post', 'get']); $this->request->allowMethod(['post', 'get']);
// For sorting // For sorting
if (!empty($this->request->data) && isset($this->request->data["order"])) { if (!is_null($this->request->getData()) && !is_null($this->request->getData("order"))) {
$sort = explode(".", $this->request->data["order"]); $sort = explode(".", $this->request->getData("order"));
$this->request->query["sort"] = $sort[0]; $this->request->query["sort"] = $sort[0];
$this->request->query["direction"] = $sort[1]; $this->request->query["direction"] = $sort[1];
} }
...@@ -168,7 +168,7 @@ class SoftwaresController extends AppController ...@@ -168,7 +168,7 @@ class SoftwaresController extends AppController
->find( ->find(
'search', 'search',
[ [
'search' => $this->request->data, 'search' => $this->request->getData(),
"contain" => ["Reviews"], "contain" => ["Reviews"],
] ]
) )
...@@ -309,7 +309,7 @@ class SoftwaresController extends AppController ...@@ -309,7 +309,7 @@ class SoftwaresController extends AppController
// no id specified => ALL software listed // no id specified => ALL software listed
if ($id == null && $this->request->is('get') && $this->request->is('json')) { if ($id == null && $this->request->is('get') && $this->request->is('json')) {
$softwares = $this->Softwares $softwares = $this->Softwares
->find('search', ['search' => $this->request->query]); ->find('search', ['search' => $this->request->getQueryParams()]);
$this->set('softwares', $this->paginate($softwares)); $this->set('softwares', $this->paginate($softwares));
$this->set('_serialize', ['softwares']); $this->set('_serialize', ['softwares']);
...@@ -323,11 +323,11 @@ class SoftwaresController extends AppController ...@@ -323,11 +323,11 @@ class SoftwaresController extends AppController
*/ */
public function add() public function add()
{ {
if (isset($this->request->data) if (null !== ($this->request->getData())
&& !empty($this->request->data) && null !== ($this->request->getData())
) { ) {
$software = $this->Softwares->newEntity( $software = $this->Softwares->newEntity(
$this->request->data, $this->request->getData(),
['associated' => "Screenshots", "Tags"] ['associated' => "Screenshots", "Tags"]
); );
} else { } else {
...@@ -339,7 +339,7 @@ class SoftwaresController extends AppController ...@@ -339,7 +339,7 @@ class SoftwaresController extends AppController
$message = ""; $message = "";
if ($this->Auth->user('id')) { if ($this->Auth->user('id')) {
if (!empty($this->request->data)) { if (null !== ($this->request->getData())) {
if ($this->Softwares->save($software)) { if ($this->Softwares->save($software)) {
$message = "Success"; $message = "Success";
$this->request->is('json') $this->request->is('json')
...@@ -500,7 +500,7 @@ class SoftwaresController extends AppController ...@@ -500,7 +500,7 @@ class SoftwaresController extends AppController
"prefix" => false, "prefix" => false,
"controller" => "Softwares", "controller" => "Softwares",
"action" => $id, "action" => $id,
"language" => $this->request->param("language"), "language" => $this->request->getParam("language"),
] ]
); );
} else { } else {
...@@ -516,7 +516,7 @@ class SoftwaresController extends AppController ...@@ -516,7 +516,7 @@ class SoftwaresController extends AppController
"prefix" => false, "prefix" => false,
"controller" => "Softwares", "controller" => "Softwares",
"action" => $id, "action" => $id,
"language" => $this->request->param("language"), "language" => $this->request->getParam("language"),
]); ]);
} }
} }
...