Skip to content

Commit

Permalink
[Task]: Replace Request::get with explicit input sources (#52)
Browse files Browse the repository at this point in the history
* request explicit input sources

* fix stan workflow

* Create CHANGELOG.md

* Apply php-cs-fixer changes

---------

Co-authored-by: kingjia90 <kingjia90@users.noreply.github.com>
  • Loading branch information
kingjia90 and kingjia90 authored Nov 18, 2024
1 parent eb27d7b commit 685231e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/static-analysis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ jobs:
strategy:
matrix:
include:
- { php-version: "8.0", dependencies: "lowest", pimcore_version: "", phpstan_args: "", experimental: false }
- { php-version: "8.1", dependencies: "highest", pimcore_version: "", phpstan_args: "", experimental: false}
- { php-version: "8.1", dependencies: "highest", pimcore_version: "11.x-dev", phpstan_args: "", experimental: true}
- { php-version: "8.1", dependencies: "lowest", pimcore_version: "", phpstan_args: "", experimental: false }
- { php-version: "8.2", dependencies: "highest", pimcore_version: "", phpstan_args: "", experimental: false}
- { php-version: "8.3", dependencies: "highest", pimcore_version: "11.x-dev", phpstan_args: "", experimental: true}
steps:
- name: "Checkout code"
uses: "actions/checkout@v2"
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#### v4.1.0
- Dropped support `pimcore/pimcore` `10.6`, bumped minimum requirement to `11.2`
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
}
},
"require": {
"pimcore/pimcore": "^10.6 || ^11.0"
"pimcore/pimcore": "^11.2"
},
"require-dev": {
"phpstan/phpstan": "^1.2"
Expand Down
20 changes: 10 additions & 10 deletions src/Controller/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ protected function getLatestVersion(Concrete $object): Concrete
*/
public function diffAction(Request $request): JsonResponse
{
$id1 = $request->get('id1');
$id2 = $request->get('id2');
$id1 = $request->request->getString('id1');
$id2 = $request->request->getString('id2');

/** @var Concrete $object1 */
$object1 = AbstractObject::getById(intval($id1));
Expand All @@ -129,7 +129,7 @@ public function diffAction(Request $request): JsonResponse
$keys2 = array_keys($dataFromObject2);
$combinedKeys = $this->combineKeys($keys1, $keys2);

foreach ($combinedKeys as $key => $value) {
foreach ($combinedKeys as $key => $value) {
$entry1 = $dataFromObject1[$key] ?? null;
$entry2 = $dataFromObject2[$key] ?? null;

Expand Down Expand Up @@ -217,8 +217,8 @@ public function diffAction(Request $request): JsonResponse
*/
public function getidAction(Request $request): JsonResponse
{
$path1 = $request->get('path1');
$path2 = $request->get('path2');
$path1 = $request->request->getString('path1');
$path2 = $request->request->getString('path2');

$object1 = Concrete::getByPath($path1);
$object2 = Concrete::getByPath($path2);
Expand All @@ -243,7 +243,7 @@ public function getidAction(Request $request): JsonResponse
*/
public function saveAction(Request $request): JsonResponse
{
$objectId = $request->get('id');
$objectId = $request->request->getInt('id');

/**
* @TODO Remove when removing support for Pimcore 10
Expand All @@ -258,14 +258,14 @@ public function saveAction(Request $request): JsonResponse
}
}

$attributes = json_decode($request->get('attributes'), true);
$attributes = json_decode($request->request->getString('attributes'), true);

/** @var \Pimcore\Model\DataObject\Concrete $object */
$object = AbstractObject::getById($objectId);

$preMergeEvent = new GenericEvent($this, [
'targetId' => $object->getId(),
'sourceId' => $request->get('sourceId'),
'sourceId' => $request->request->getInt('sourceId'),
]);
$this->eventDispatcher->dispatch($preMergeEvent, 'plugin.ObjectMerger.preMerge');

Expand Down Expand Up @@ -295,11 +295,11 @@ public function saveAction(Request $request): JsonResponse

$postMergeEvent = new GenericEvent($this, [
'targetId' => $object->getId(),
'sourceId' => $request->get('sourceId'),
'sourceId' => $request->request->getInt('sourceId'),
]);

$this->eventDispatcher->dispatch($postMergeEvent, 'plugin.ObjectMerger.postMerge');

return $this->jsonResponse(['success' => true, 'targetId' => $object->getId(), 'sourceId' => $request->get('sourceId')]);
return $this->jsonResponse(['success' => true, 'targetId' => $object->getId(), 'sourceId' => $request->request->getInt('sourceId')]);
}
}

0 comments on commit 685231e

Please sign in to comment.