diff --git a/src/Controller/Admin/Asset/AssetController.php b/src/Controller/Admin/Asset/AssetController.php index 4b7f6bbdea..7002f4684d 100644 --- a/src/Controller/Admin/Asset/AssetController.php +++ b/src/Controller/Admin/Asset/AssetController.php @@ -256,7 +256,7 @@ public function treeGetChildrenByIdAction(Request $request, EventDispatcherInter $cv = []; $asset = Asset::getById((int) $allParams['node']); - $filter = $request->get('filter'); + $filter = $request->query->getString('filter'); $limit = (int)$allParams['limit']; if (!is_null($filter)) { if (substr($filter, -1) != '*') { @@ -328,8 +328,8 @@ public function treeGetChildrenByIdAction(Request $request, EventDispatcherInter 'total' => $asset->getChildAmount($this->getAdminUser()), 'overflow' => !is_null($filter) && ($filteredTotalCount > $limit), 'nodes' => $assets, - 'filter' => $request->get('filter') ? $request->get('filter') : '', - 'inSearch' => (int)$request->get('inSearch'), + 'filter' => $request->query->getString('filter'), + 'inSearch' => $request->query->getInt('inSearch'), ]); } else { return $this->adminJson($assets); @@ -399,10 +399,10 @@ public function addAssetCompatibilityAction(Request $request, Config $config): J */ public function existsAction(Request $request): JsonResponse { - $parentAsset = \Pimcore\Model\Asset::getById((int)$request->get('parentId')); + $parentAsset = \Pimcore\Model\Asset::getById($request->query->getInt('parentId')); return new JsonResponse([ - 'exists' => Asset\Service::pathExists($parentAsset->getRealFullPath().'/'.$request->get('filename')), + 'exists' => Asset\Service::pathExists($parentAsset->getRealFullPath().'/'.$request->query->getString('filename')), ]); } @@ -628,7 +628,7 @@ public function replaceAssetAction(Request $request, TranslatorInterface $transl public function addFolderAction(Request $request): JsonResponse { $success = false; - $parentAsset = Asset::getById((int)$request->get('parentId')); + $parentAsset = Asset::getById($request->request->getInt('parentId')); $equalAsset = Asset::getByPath($parentAsset->getRealFullPath() . '/' . $request->get('name')); if ($parentAsset->isAllowed('create')) { @@ -926,7 +926,7 @@ public function publishVersionAction(Request $request): JsonResponse */ public function showVersionAction(Request $request, Environment $twig): Response { - $id = (int)$request->get('id'); + $id = $request->query->getInt('id'); $version = Model\Version::getById($id); $asset = $version?->loadData(); if (!$asset) { @@ -1128,7 +1128,7 @@ public function downloadImageThumbnailAction(Request $request): BinaryFileRespon */ public function getAssetAction(Request $request): StreamedResponse { - $image = Asset::getById((int)$request->get('id')); + $image = Asset::getById($request->query->getInt('id')); if (!$image) { throw $this->createNotFoundException('Asset not found'); @@ -1161,7 +1161,7 @@ public function getAssetAction(Request $request): StreamedResponse public function getImageThumbnailAction(Request $request): BinaryFileResponse|JsonResponse|StreamedResponse { $fileinfo = $request->get('fileinfo'); - $image = Asset\Image::getById((int)$request->get('id')); + $image = Asset\Image::getById($request->query->getInt('id')); if (!$image) { throw $this->createNotFoundException('Asset not found'); @@ -1251,8 +1251,8 @@ public function getFolderThumbnailAction(Request $request): StreamedResponse { $folder = null; - if ($request->get('id')) { - $folder = Asset\Folder::getById((int)$request->get('id')); + if ($request->query->has('id')) { + $folder = Asset\Folder::getById($request->query->getInt('id')); if ($folder instanceof Asset\Folder) { if (!$folder->isAllowed('view')) { throw $this->createAccessDeniedException('not allowed to view thumbnail'); @@ -1286,9 +1286,9 @@ public function getVideoThumbnailAction(Request $request): StreamedResponse $video = null; if ($request->get('id')) { - $video = Asset\Video::getById((int)$request->get('id')); - } elseif ($request->get('path')) { - $video = Asset\Video::getByPath($request->get('path')); + $video = Asset\Video::getById($request->query->getInt('id')); + } elseif ($request->query->has('path')) { + $video = Asset\Video::getByPath($request->query->getString('path')); } if (!$video) { @@ -1358,7 +1358,7 @@ public function getVideoThumbnailAction(Request $request): StreamedResponse */ public function getDocumentThumbnailAction(Request $request): BinaryFileResponse|StreamedResponse { - $document = Asset\Document::getById((int)$request->get('id')); + $document = Asset\Document::getById($request->query->getInt('id')); if (!$document) { throw $this->createNotFoundException('could not load document asset'); diff --git a/src/Controller/Admin/Asset/AssetHelperController.php b/src/Controller/Admin/Asset/AssetHelperController.php index 099fa83b3d..38b7374ae6 100644 --- a/src/Controller/Admin/Asset/AssetHelperController.php +++ b/src/Controller/Admin/Asset/AssetHelperController.php @@ -128,7 +128,7 @@ public function getSharedGridColumnConfigs(User $user, string $classId, string $ */ public function gridDeleteColumnConfigAction(Request $request): JsonResponse { - $gridConfigId = (int) $request->get('gridConfigId'); + $gridConfigId = $request->request->getInt('gridConfigId'); $gridConfig = GridConfig::getById($gridConfigId); $success = false; if ($gridConfig) { diff --git a/src/Controller/Admin/DataObject/ClassController.php b/src/Controller/Admin/DataObject/ClassController.php index 4b6b2b7d31..5863b8a27f 100644 --- a/src/Controller/Admin/DataObject/ClassController.php +++ b/src/Controller/Admin/DataObject/ClassController.php @@ -101,7 +101,7 @@ public function getTreeAction(Request $request): JsonResponse $classes = $classesList->load(); // filter classes - if ($request->get('createAllowed')) { + if ($request->query->getBoolean('createAllowed')) { $tmpClasses = []; foreach ($classes as $class) { if ($this->getAdminUser()->isAllowed($class->getId(), 'class')) { @@ -111,8 +111,8 @@ public function getTreeAction(Request $request): JsonResponse $classes = $tmpClasses; } - $withId = $request->get('withId'); - $useTitle = $request->get('useTitle'); + $withId = $request->query->has('withId'); + $useTitle = $request->query->has('useTitle'); $getClassConfig = function ($class) use ($defaultIcon, $withId, $useTitle) { $text = $class->getName(); if ($useTitle) { @@ -180,7 +180,7 @@ public function getTreeAction(Request $request): JsonResponse array_multisort($types, SORT_ASC, array_keys($groups), SORT_ASC, $groups); } - if (!$request->get('grouped')) { + if (!$request->query->getInt('grouped')) { // list output foreach ($groups as $groupName => $groupData) { foreach ($groupData['classes'] as $class) { diff --git a/src/Controller/Admin/DataObject/ClassificationstoreController.php b/src/Controller/Admin/DataObject/ClassificationstoreController.php index 4dbc37ae33..bca66a6974 100644 --- a/src/Controller/Admin/DataObject/ClassificationstoreController.php +++ b/src/Controller/Admin/DataObject/ClassificationstoreController.php @@ -87,8 +87,8 @@ public function deleteRelationAction(Request $request): JsonResponse { $this->checkPermission('classificationstore'); - $keyId = (int) $request->get('keyId'); - $groupId = (int) $request->get('groupId'); + $keyId = $request->request->getInt('keyId'); + $groupId = $request->request->getInt('groupId'); $config = new Classificationstore\KeyGroupRelation(); $config->setKeyId($keyId); diff --git a/src/Controller/Admin/DataObject/DataObjectController.php b/src/Controller/Admin/DataObject/DataObjectController.php index 728d454d79..c81c803779 100644 --- a/src/Controller/Admin/DataObject/DataObjectController.php +++ b/src/Controller/Admin/DataObject/DataObjectController.php @@ -89,8 +89,8 @@ class DataObjectController extends ElementControllerBase implements KernelContro public function treeGetChildrenByIdAction(Request $request, EventDispatcherInterface $eventDispatcher): JsonResponse { $allParams = array_merge($request->request->all(), $request->query->all()); - $filter = $request->get('filter'); - $object = DataObject::getById((int) $request->get('node')); + $filter = $request->query->getString('filter'); + $object = DataObject::getById($request->query->getInt('node')); $objectTypes = [DataObject::OBJECT_TYPE_OBJECT, DataObject::OBJECT_TYPE_FOLDER]; $objects = []; $cv = []; @@ -104,10 +104,10 @@ public function treeGetChildrenByIdAction(Request $request, EventDispatcherInter } if ($object->hasChildren($objectTypes)) { - $offset = (int)$request->get('start'); - $limit = (int)$request->get('limit', 100000000); - if ($view = $request->get('view', '')) { - $cv = $this->elementService->getCustomViewById($request->get('view')); + $offset = $request->query->getInt('start'); + $limit = $request->query->getInt('limit', 100000000); + if ($view = $request->query->getString('view')) { + $cv = $this->elementService->getCustomViewById($view); } if (!is_null($filter)) { @@ -180,9 +180,9 @@ public function treeGetChildrenByIdAction(Request $request, EventDispatcherInter 'total' => $total, 'overflow' => !is_null($filter) && ($filteredTotalCount > $limit), 'nodes' => $objects, - 'fromPaging' => (int)$request->get('fromPaging'), - 'filter' => $request->get('filter') ? $request->get('filter') : '', - 'inSearch' => (int)$request->get('inSearch'), + 'fromPaging' => $request->query->getInt('fromPaging'), + 'filter' => $request->query->getString('filter'), + 'inSearch' => $request->query->getInt('inSearch'), ]); } @@ -756,7 +756,7 @@ private function getDataForField(DataObject\Concrete $object, string $key, DataO */ public function getFolderAction(Request $request, EventDispatcherInterface $eventDispatcher): JsonResponse { - $objectId = (int)$request->get('id'); + $objectId = $request->query->getInt('id'); $object = DataObject::getById($objectId); if (!$object) { @@ -1595,7 +1595,7 @@ public function previewVersionAction(Request $request, Environment $twig): Respo { DataObject::setDoNotRestoreKeyAndPath(true); - $id = (int)$request->get('id'); + $id = $request->query->getInt('id'); $version = Model\Version::getById($id); $object = $version?->loadData(); diff --git a/src/Controller/Admin/DataObject/DataObjectHelperController.php b/src/Controller/Admin/DataObject/DataObjectHelperController.php index 02ea68322d..0ab3301ac2 100644 --- a/src/Controller/Admin/DataObject/DataObjectHelperController.php +++ b/src/Controller/Admin/DataObject/DataObjectHelperController.php @@ -62,7 +62,7 @@ class DataObjectHelperController extends AdminAbstractController */ public function loadObjectDataAction(Request $request): JsonResponse { - $object = DataObject::getById((int) $request->get('id')); + $object = DataObject::getById($request->query->getInt('id')); $result = []; if ($object) { $result['success'] = true; diff --git a/src/Controller/Admin/Document/DocumentController.php b/src/Controller/Admin/Document/DocumentController.php index c06728422a..73e178e735 100644 --- a/src/Controller/Admin/Document/DocumentController.php +++ b/src/Controller/Admin/Document/DocumentController.php @@ -96,7 +96,7 @@ public function deleteInfoAction(Request $request, EventDispatcherInterface $eve */ public function getDataByIdAction(Request $request, EventDispatcherInterface $eventDispatcher): JsonResponse { - $document = Document::getById((int) $request->get('id')); + $document = Document::getById($request->query->get('id')); if (!$document) { throw $this->createNotFoundException('Document not found'); @@ -141,7 +141,7 @@ public function treeGetChildrenByIdAction(Request $request, EventDispatcherInter { $allParams = array_merge($request->request->all(), $request->query->all()); - $filter = $request->get('filter'); + $filter = $request->query->getString('filter'); $limit = (int)($allParams['limit'] ?? 100000000); $offset = (int)($allParams['start'] ?? 0); @@ -233,8 +233,8 @@ public function treeGetChildrenByIdAction(Request $request, EventDispatcherInter 'limit' => $limit, 'total' => $document->getChildAmount($this->getAdminUser()), 'nodes' => $documents, - 'filter' => $request->get('filter') ? $request->get('filter') : '', - 'inSearch' => (int)$request->get('inSearch'), + 'filter' => $request->query->getString('filter'), + 'inSearch' => $request->query->getInt('inSearch'), ]); } else { return $this->adminJson($documents); @@ -250,7 +250,7 @@ public function addAction(Request $request): JsonResponse $errorMessage = ''; // check for permission - $parentDocument = Document::getById((int)$request->get('parentId')); + $parentDocument = Document::getById($request->request->getInt('parentId')); $document = null; if ($parentDocument->isAllowed('create')) { $intendedPath = $parentDocument->getRealFullPath() . '/' . $request->get('key'); @@ -442,7 +442,7 @@ public function updateAction(Request $request): JsonResponse $data = ['success' => false]; $allowUpdate = true; - $document = Document::getById((int) $request->get('id')); + $document = Document::getById($request->request->getInt('id')); $oldPath = $document->getDao()->getCurrentFullPath(); $oldDocument = Document::getById($document->getId(), ['force' => true]); @@ -464,7 +464,7 @@ public function updateAction(Request $request): JsonResponse if ($document->isAllowed('settings')) { // if the position is changed the path must be changed || also from the children - if ($parentId = $request->get('parentId')) { + if ($parentId = $request->request->getInt('parentId')) { $parentDocument = Document::getById((int) $parentId); //check if parent is changed @@ -512,8 +512,8 @@ public function updateAction(Request $request): JsonResponse try { $document->save(); - if ($request->get('index') !== null) { - $this->updateIndexesOfDocumentSiblings($document, $request->get('index')); + if ($request->request->has('index')) { + $this->updateIndexesOfDocumentSiblings($document, $request->request->getInt('index')); } $data = [ diff --git a/src/Controller/Admin/Document/DocumentControllerBase.php b/src/Controller/Admin/Document/DocumentControllerBase.php index 189d2caa06..189d41bb2f 100644 --- a/src/Controller/Admin/Document/DocumentControllerBase.php +++ b/src/Controller/Admin/Document/DocumentControllerBase.php @@ -110,7 +110,7 @@ protected function preSendDataActions(array &$data, Model\Document $document, ?V protected function addPropertiesToDocument(Request $request, Model\Document $document): void { // properties - if ($request->get('properties')) { + if ($request->request->has('properties')) { $properties = []; // assign inherited properties foreach ($document->getProperties() as $p) { @@ -119,7 +119,7 @@ protected function addPropertiesToDocument(Request $request, Model\Document $doc } } - $propertiesData = $this->decodeJson($request->get('properties')); + $propertiesData = $this->decodeJson($request->request->getString('properties')); if (is_array($propertiesData)) { foreach ($propertiesData as $propertyName => $propertyData) { @@ -155,9 +155,9 @@ protected function addPropertiesToDocument(Request $request, Model\Document $doc protected function addSettingsToDocument(Request $request, Model\Document $document): void { // settings - if ($request->get('settings')) { + if ($request->request->has('settings')) { if ($document->isAllowed('settings')) { - $settings = $this->decodeJson($request->get('settings')); + $settings = $this->decodeJson($request->request->getString('settings')); if (array_key_exists('prettyUrl', $settings)) { $settings['prettyUrl'] = htmlspecialchars($settings['prettyUrl']); @@ -210,7 +210,7 @@ protected function addTranslationsData(Model\Document $document, array &$data): */ public function saveToSessionAction(Request $request): JsonResponse { - if ($documentId = (int) $request->get('id')) { + if ($documentId = $request->request->getInt('id')) { if (!$document = Model\Document\Service::getElementFromSession('document', $documentId, $request->getSession()->getId())) { $document = Model\Document\PageSnippet::getById($documentId); if (!$document) { @@ -263,7 +263,7 @@ protected function getFromSession(Model\Document $doc, SessionInterface $session */ public function removeFromSessionAction(Request $request): JsonResponse { - Model\Document\Service::removeElementFromSession('document', $request->get('id'), $request->getSession()->getId()); + Model\Document\Service::removeElementFromSession('document', $request->request->getInt('id'), $request->getSession()->getId()); return $this->adminJson(['success' => true]); } @@ -313,7 +313,7 @@ protected function getLatestVersion(Model\Document\PageSnippet $document, ?Versi */ public function changeMainDocumentAction(Request $request): JsonResponse { - $doc = Model\Document\PageSnippet::getById((int) $request->get('id')); + $doc = Model\Document\PageSnippet::getById($request->request->getInt('id')); if ($doc instanceof Model\Document\PageSnippet) { $doc->setEditables([]); $doc->setContentMainDocumentId($request->get('contentMainDocumentPath'), true); @@ -372,7 +372,7 @@ protected function saveDocument(Model\Document $document, Request $request, bool $document->setModificationDate(time()); $document->setUserModification($this->getAdminUser()->getId()); - $task = strtolower($task ?? $request->get('task')); + $task = strtolower($task ?? $request->query->getString('task')); $version = null; switch ($task) { case $task === self::TASK_PUBLISH && $document->isAllowed($task): diff --git a/src/Controller/Admin/Document/EmailController.php b/src/Controller/Admin/Document/EmailController.php index 23f578ff00..939b7b80aa 100644 --- a/src/Controller/Admin/Document/EmailController.php +++ b/src/Controller/Admin/Document/EmailController.php @@ -36,7 +36,7 @@ class EmailController extends DocumentControllerBase */ public function getDataByIdAction(Request $request): JsonResponse { - $email = Document\Email::getById((int)$request->get('id')); + $email = Document\Email::getById($request->query->getInt('id')); if (!$email) { throw $this->createNotFoundException('Email not found'); @@ -77,7 +77,7 @@ public function getDataByIdAction(Request $request): JsonResponse */ public function saveAction(Request $request): JsonResponse { - $page = Document\Email::getById((int) $request->get('id')); + $page = Document\Email::getById($request->request->getInt('id')); if (!$page) { throw $this->createNotFoundException('Email not found'); } diff --git a/src/Controller/Admin/Document/FolderController.php b/src/Controller/Admin/Document/FolderController.php index 83d1dbcf3e..09e69230a6 100644 --- a/src/Controller/Admin/Document/FolderController.php +++ b/src/Controller/Admin/Document/FolderController.php @@ -35,7 +35,7 @@ class FolderController extends DocumentControllerBase */ public function getDataByIdAction(Request $request): JsonResponse { - $folder = Document\Folder::getById((int)$request->get('id')); + $folder = Document\Folder::getById($request->query->getInt('id')); if (!$folder) { throw $this->createNotFoundException('Folder not found'); } @@ -60,7 +60,7 @@ public function getDataByIdAction(Request $request): JsonResponse */ public function saveAction(Request $request): JsonResponse { - $folder = Document\Folder::getById((int) $request->get('id')); + $folder = Document\Folder::getById($request->request->getInt('id')); if (!$folder) { throw $this->createNotFoundException('Folder not found'); } diff --git a/src/Controller/Admin/Document/HardlinkController.php b/src/Controller/Admin/Document/HardlinkController.php index 225609651e..e09a5c31ba 100644 --- a/src/Controller/Admin/Document/HardlinkController.php +++ b/src/Controller/Admin/Document/HardlinkController.php @@ -36,7 +36,7 @@ class HardlinkController extends DocumentControllerBase */ public function getDataByIdAction(Request $request): JsonResponse { - $link = Document\Hardlink::getById((int)$request->get('id')); + $link = Document\Hardlink::getById($request->query->getInt('id')); if (!$link) { throw $this->createNotFoundException('Hardlink not found'); @@ -76,7 +76,7 @@ static function (Task $task) { */ public function saveAction(Request $request): JsonResponse { - $link = Document\Hardlink::getById((int) $request->get('id')); + $link = Document\Hardlink::getById($request->request->getInt('id')); if (!$link) { throw $this->createNotFoundException('Hardlink not found'); } diff --git a/src/Controller/Admin/Document/LinkController.php b/src/Controller/Admin/Document/LinkController.php index b2460ced5b..dc93a42cc1 100644 --- a/src/Controller/Admin/Document/LinkController.php +++ b/src/Controller/Admin/Document/LinkController.php @@ -40,7 +40,7 @@ class LinkController extends DocumentControllerBase */ public function getDataByIdAction(Request $request, SerializerInterface $serializer): JsonResponse { - $link = Document\Link::getById((int)$request->get('id')); + $link = Document\Link::getById($request->query->getInt('id')); if (!$link) { throw $this->createNotFoundException('Link not found'); @@ -80,7 +80,7 @@ static function (Task $task) { */ public function saveAction(Request $request): JsonResponse { - $link = Document\Link::getById((int) $request->get('id')); + $link = Document\Link::getById($request->request->getInt('id')); if (!$link) { throw $this->createNotFoundException('Link not found'); } diff --git a/src/Controller/Admin/Document/PageController.php b/src/Controller/Admin/Document/PageController.php index e4c89b3342..824a904cfd 100644 --- a/src/Controller/Admin/Document/PageController.php +++ b/src/Controller/Admin/Document/PageController.php @@ -57,7 +57,7 @@ class PageController extends DocumentControllerBase */ public function getDataByIdAction(Request $request, StaticPageGenerator $staticPageGenerator): JsonResponse { - $page = Document\Page::getById((int)$request->get('id')); + $page = Document\Page::getById($request->query->getInt('id')); if (!$page) { throw $this->createNotFoundException('Page not found'); @@ -112,7 +112,7 @@ static function (Task $task) { */ public function saveAction(Request $request, StaticPageGenerator $staticPageGenerator): JsonResponse { - $oldPage = Document\Page::getById((int) $request->get('id')); + $oldPage = Document\Page::getById($request->request->getInt('id')); if (!$oldPage) { throw $this->createNotFoundException('Page not found'); } @@ -126,13 +126,13 @@ public function saveAction(Request $request, StaticPageGenerator $staticPageGene $page = $this->getLatestVersion($oldPage); } - if ($request->get('missingRequiredEditable') !== null) { - $page->setMissingRequiredEditable(($request->get('missingRequiredEditable') == 'true') ? true : false); + if ($request->request->has('missingRequiredEditable')) { + $page->setMissingRequiredEditable($request->request->getBoolean('missingRequiredEditable')); } $settings = []; - if ($request->get('settings')) { - $settings = $this->decodeJson($request->get('settings')); + if ($request->request->has('settings')) { + $settings = $this->decodeJson($request->request->getString('settings')); if ($settings['published'] ?? false) { $page->setMissingRequiredEditable(null); } @@ -205,7 +205,7 @@ public function generatePreviewsAction(Request $request, MessageBusInterface $me */ public function displayPreviewImageAction(Request $request): BinaryFileResponse { - $document = Document\Page::getById((int) $request->get('id')); + $document = Document\Page::getById($request->query->getInt('id')); if ($document instanceof Document\Page) { return new BinaryFileResponse($document->getPreviewImageFilesystemPath(), 200, [ 'Content-Type' => 'image/jpg', diff --git a/src/Controller/Admin/Document/SnippetController.php b/src/Controller/Admin/Document/SnippetController.php index 6114cc1281..95ac304338 100644 --- a/src/Controller/Admin/Document/SnippetController.php +++ b/src/Controller/Admin/Document/SnippetController.php @@ -37,7 +37,7 @@ class SnippetController extends DocumentControllerBase */ public function getDataByIdAction(Request $request): JsonResponse { - $snippet = Document\Snippet::getById((int)$request->get('id')); + $snippet = Document\Snippet::getById($request->query->getInt('id')); if (!$snippet) { throw $this->createNotFoundException('Snippet not found'); @@ -87,7 +87,7 @@ static function (Task $task) { */ public function saveAction(Request $request): JsonResponse { - $snippet = Document\Snippet::getById((int) $request->get('id')); + $snippet = Document\Snippet::getById($request->request->getInt('id')); if (!$snippet) { throw $this->createNotFoundException('Snippet not found'); } @@ -101,8 +101,8 @@ public function saveAction(Request $request): JsonResponse $snippet = $this->getLatestVersion($snippet); } - if ($request->get('missingRequiredEditable') !== null) { - $snippet->setMissingRequiredEditable(($request->get('missingRequiredEditable') == 'true') ? true : false); + if ($request->request->has('missingRequiredEditable')) { + $snippet->setMissingRequiredEditable($request->request->getBoolean('missingRequiredEditable')); } [$task, $snippet, $version] = $this->saveDocument($snippet, $request); diff --git a/src/Controller/Admin/ElementController.php b/src/Controller/Admin/ElementController.php index 9d02a77bde..e39f9b4299 100644 --- a/src/Controller/Admin/ElementController.php +++ b/src/Controller/Admin/ElementController.php @@ -571,8 +571,8 @@ public function getNicePathAction(Request $request): JsonResponse */ public function getVersionsAction(Request $request): JsonResponse { - $id = (int)$request->get('id'); - $type = $request->get('elementType'); + $id = $request->query->getInt('id'); + $type = $request->query->getString('elementType'); $allowedTypes = ['asset', 'document', 'object']; if ($id && in_array($type, $allowedTypes)) { diff --git a/src/Controller/Admin/ElementControllerBase.php b/src/Controller/Admin/ElementControllerBase.php index ae9ae783f5..cb96320cf9 100644 --- a/src/Controller/Admin/ElementControllerBase.php +++ b/src/Controller/Admin/ElementControllerBase.php @@ -59,13 +59,9 @@ protected function getTreeNodeConfig(ElementInterface $element): array */ public function treeGetRootAction(Request $request): JsonResponse { - $type = $request->get('elementType'); + $type = $request->query->getString('elementType'); $allowedTypes = ['asset', 'document', 'object']; - - $id = 1; - if ($request->get('id')) { - $id = (int)$request->get('id'); - } + $id = $request->query->getInt('id', 1); if (in_array($type, $allowedTypes)) { $root = Service::getElementById($type, $id); diff --git a/src/Controller/Admin/MiscController.php b/src/Controller/Admin/MiscController.php index 87e6bf0561..0a0257e713 100644 --- a/src/Controller/Admin/MiscController.php +++ b/src/Controller/Admin/MiscController.php @@ -85,7 +85,7 @@ public function getAvailableTemplatesAction(ControllerDataProvider $provider): J */ public function jsonTranslationsSystemAction(Request $request, TranslatorInterface $translator): Response { - $language = $request->get('language'); + $language = $request->query->getString('language'); /** @var Translator $translator */ $translator->lazyInitialize('admin', $language); diff --git a/src/Controller/Admin/SettingsController.php b/src/Controller/Admin/SettingsController.php index 5d3ea46072..34bfdd3a7d 100644 --- a/src/Controller/Admin/SettingsController.php +++ b/src/Controller/Admin/SettingsController.php @@ -71,7 +71,7 @@ public function __construct(protected TranslatorInterface $translator) public function displayCustomLogoAction(Request $request): StreamedResponse { $mime = 'image/svg+xml'; - if ($request->get('white')) { + if ($request->query->has('white')) { $logo = PIMCORE_WEB_ROOT . '/bundles/pimcoreadmin/img/logo-claim-white.svg'; } else { $logo = PIMCORE_WEB_ROOT . '/bundles/pimcoreadmin/img/logo-claim-gray.svg'; @@ -145,9 +145,10 @@ public function metadataAction(Request $request): JsonResponse { $this->checkPermission('asset_metadata'); - if ($request->get('data')) { - if ($request->get('xaction') == 'destroy') { - $data = $this->decodeJson($request->get('data')); + if ($request->request->has('data')) { + $data = $this->decodeJson($request->request->getString('data')); + + if ($request->query->getString('xaction') == 'destroy') { $id = $data['id']; $metadata = Metadata\Predefined::getById($id); if (!$metadata->isWriteable()) { @@ -157,8 +158,6 @@ public function metadataAction(Request $request): JsonResponse return $this->adminJson(['success' => true, 'data' => []]); } elseif ($request->get('xaction') == 'update') { - $data = $this->decodeJson($request->get('data')); - // save type $metadata = Metadata\Predefined::getById($data['id']); if (!$metadata->isWriteable()) { @@ -183,7 +182,6 @@ public function metadataAction(Request $request): JsonResponse if (!(new Metadata\Predefined())->isWriteable()) { throw new ConfigWriteException(); } - $data = $this->decodeJson($request->get('data')); unset($data['id']); // save type @@ -676,7 +674,7 @@ public function getAvailableSitesAction(Request $request): JsonResponse return $this->adminJson([]); } - $excludeMainSite = $request->get('excludeMainSite'); + $excludeMainSite = $request->query->getInt('excludeMainSite'); $sitesList = new Model\Site\Listing(); $sitesObjects = $sitesList->load(); diff --git a/src/Controller/Admin/TagsController.php b/src/Controller/Admin/TagsController.php index 7fa2705a57..a69df7aef8 100644 --- a/src/Controller/Admin/TagsController.php +++ b/src/Controller/Admin/TagsController.php @@ -42,7 +42,7 @@ public function addAction(Request $request): JsonResponse try { $tag = new Tag(); $tag->setName(strip_tags($request->get('text', ''))); - $tag->setParentId((int)$request->get('parentId')); + $tag->setParentId($request->request->getInt('parentId')); $tag->save(); return $this->adminJson(['success' => true, 'id' => $tag->getId()]); diff --git a/src/Controller/Admin/UserController.php b/src/Controller/Admin/UserController.php index 04148f6531..55658c45bd 100644 --- a/src/Controller/Admin/UserController.php +++ b/src/Controller/Admin/UserController.php @@ -372,7 +372,7 @@ public function updateAction(Request $request, TranslatorInterface $translator): */ public function getAction(Request $request): JsonResponse { - $userId = (int)$request->get('id'); + $userId = $request->query->getInt('id'); if ($userId < 1) { throw $this->createNotFoundException(); } @@ -477,7 +477,7 @@ public function getAction(Request $request): JsonResponse */ public function getMinimalAction(Request $request): JsonResponse { - $user = User::getById((int)$request->get('id')); + $user = User::getById($request->query->getInt('id')); if (!$user) { throw $this->createNotFoundException(); @@ -696,7 +696,7 @@ protected function getRoleTreeNodeConfig(User\Role|User\Role\Folder $role): arra */ public function roleGetAction(Request $request): JsonResponse { - $role = User\Role::getById((int)$request->get('id')); + $role = User\Role::getById($request->query->getInt('id')); if (!$role) { throw $this->createNotFoundException(); @@ -1124,12 +1124,13 @@ public function invitationLinkAction(Request $request, TranslatorInterface $tran protected function getUserId(Request $request): int { - if ($request->get('id')) { - if ($this->getAdminUser()->getId() != $request->get('id')) { + $userId = $request->query->getInt('id'); + if ($userId) { + if ($this->getAdminUser()->getId() != $userId) { $this->checkPermission('users'); } - return (int) $request->get('id'); + return $userId; } return $this->getAdminUser()->getId(); diff --git a/src/Controller/GDPR/AssetController.php b/src/Controller/GDPR/AssetController.php index 978124e87c..c45a470013 100644 --- a/src/Controller/GDPR/AssetController.php +++ b/src/Controller/GDPR/AssetController.php @@ -73,7 +73,7 @@ public function searchAssetAction(Request $request, Assets $service): JsonRespon */ public function exportAssetsAction(Request $request, Assets $service): Response { - $asset = Asset::getById((int) $request->get('id')); + $asset = Asset::getById($request->query->getInt('id')); if (!$asset) { throw $this->createNotFoundException('Asset not found'); } diff --git a/src/Controller/GDPR/DataObjectController.php b/src/Controller/GDPR/DataObjectController.php index 626cafa9d3..7eaa33676d 100644 --- a/src/Controller/GDPR/DataObjectController.php +++ b/src/Controller/GDPR/DataObjectController.php @@ -70,7 +70,7 @@ public function searchDataObjectsAction(Request $request, DataObjects $service): */ public function exportDataObjectAction(Request $request, DataObjects $service): JsonResponse { - $object = DataObject::getById((int) $request->get('id')); + $object = DataObject::getById($request->request->getInt('id')); if (!$object) { throw $this->createNotFoundException('Object not found'); } diff --git a/src/Controller/GDPR/PimcoreUsersController.php b/src/Controller/GDPR/PimcoreUsersController.php index b172f61c4d..ce94a80c71 100644 --- a/src/Controller/GDPR/PimcoreUsersController.php +++ b/src/Controller/GDPR/PimcoreUsersController.php @@ -68,7 +68,7 @@ public function searchUsersAction(Request $request, PimcoreUsers $pimcoreUsers): public function exportUserDataAction(Request $request, PimcoreUsers $pimcoreUsers): JsonResponse { $this->checkPermission('users'); - $userData = $pimcoreUsers->getExportData((int)$request->get('id')); + $userData = $pimcoreUsers->getExportData($request->query->getInt('id')); $json = $this->encodeJson($userData, [], JsonResponse::DEFAULT_ENCODING_OPTIONS | JSON_PRETTY_PRINT); $jsonResponse = new JsonResponse($json, 200, [ diff --git a/src/Controller/GDPR/SentMailController.php b/src/Controller/GDPR/SentMailController.php index 9dee41980d..00c77b6aaa 100644 --- a/src/Controller/GDPR/SentMailController.php +++ b/src/Controller/GDPR/SentMailController.php @@ -49,7 +49,7 @@ public function exportDataObjectAction(Request $request): JsonResponse { $this->checkPermission('emails'); - $sentMail = Log::getById((int) $request->get('id')); + $sentMail = Log::getById($request->query->getInt('id')); if (!$sentMail) { throw $this->createNotFoundException(); } diff --git a/src/Controller/Traits/ApplySchedulerDataTrait.php b/src/Controller/Traits/ApplySchedulerDataTrait.php index dfb7648f54..a7ea46fae7 100644 --- a/src/Controller/Traits/ApplySchedulerDataTrait.php +++ b/src/Controller/Traits/ApplySchedulerDataTrait.php @@ -31,17 +31,15 @@ protected function applySchedulerDataToElement(Request $request, ElementInterfac /** @var AdminAbstractController $this */ // scheduled tasks - if ($request->get('scheduler')) { + if ($request->request->has('scheduler')) { $tasks = []; - $tasksData = $this->decodeJson($request->get('scheduler')); + $tasksData = $this->decodeJson($request->request->getString('scheduler')); - if (!empty($tasksData)) { - foreach ($tasksData as $taskData) { - $taskData['userId'] = $this->getAdminUser()->getId(); + foreach ($tasksData as $taskData) { + $taskData['userId'] = $this->getAdminUser()->getId(); - $task = new Task($taskData); - $tasks[] = $task; - } + $task = new Task($taskData); + $tasks[] = $task; } if ($element->isAllowed('settings') && method_exists($element, 'setScheduledTasks')) { diff --git a/src/EventListener/UserPerspectiveListener.php b/src/EventListener/UserPerspectiveListener.php index 3aef557583..c0c7a2b69e 100644 --- a/src/EventListener/UserPerspectiveListener.php +++ b/src/EventListener/UserPerspectiveListener.php @@ -69,7 +69,7 @@ public function onKernelRequest(RequestEvent $event): void protected function setRequestedPerspective(User $user, Request $request): void { // update perspective settings - $requestedPerspective = $request->get('perspective'); + $requestedPerspective = $request->query->getString('perspective'); if ($requestedPerspective) { if ($requestedPerspective !== $user->getActivePerspective()) {