Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
kingjia90 committed Nov 28, 2024
1 parent f97192f commit 18e01ad
Show file tree
Hide file tree
Showing 26 changed files with 100 additions and 107 deletions.
30 changes: 15 additions & 15 deletions src/Controller/Admin/Asset/AssetController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {

Check failure on line 261 in src/Controller/Admin/Asset/AssetController.php

View workflow job for this annotation

GitHub Actions / static-analysis (8.3, highest, 11.x-dev as 11.99.9, true) / Static analysis with phpstan

Call to function is_null() with string will always evaluate to false.

Check failure on line 261 in src/Controller/Admin/Asset/AssetController.php

View workflow job for this annotation

GitHub Actions / static-analysis (8.3, highest, false) / Static analysis with phpstan

Call to function is_null() with string will always evaluate to false.
if (substr($filter, -1) != '*') {
Expand Down Expand Up @@ -328,8 +328,8 @@ public function treeGetChildrenByIdAction(Request $request, EventDispatcherInter
'total' => $asset->getChildAmount($this->getAdminUser()),
'overflow' => !is_null($filter) && ($filteredTotalCount > $limit),

Check failure on line 329 in src/Controller/Admin/Asset/AssetController.php

View workflow job for this annotation

GitHub Actions / static-analysis (8.3, highest, 11.x-dev as 11.99.9, true) / Static analysis with phpstan

Call to function is_null() with non-falsy-string will always evaluate to false.

Check failure on line 329 in src/Controller/Admin/Asset/AssetController.php

View workflow job for this annotation

GitHub Actions / static-analysis (8.3, highest, false) / Static analysis with phpstan

Call to function is_null() with non-falsy-string will always evaluate to false.
'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);
Expand Down Expand Up @@ -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')),
]);
}

Expand Down Expand Up @@ -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')) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/Admin/Asset/AssetHelperController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
8 changes: 4 additions & 4 deletions src/Controller/Admin/DataObject/ClassController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')) {
Expand All @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
22 changes: 11 additions & 11 deletions src/Controller/Admin/DataObject/DataObjectController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand All @@ -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)) {

Check failure on line 113 in src/Controller/Admin/DataObject/DataObjectController.php

View workflow job for this annotation

GitHub Actions / static-analysis (8.3, highest, 11.x-dev as 11.99.9, true) / Static analysis with phpstan

Call to function is_null() with string will always evaluate to false.

Check failure on line 113 in src/Controller/Admin/DataObject/DataObjectController.php

View workflow job for this annotation

GitHub Actions / static-analysis (8.3, highest, false) / Static analysis with phpstan

Call to function is_null() with string will always evaluate to false.
Expand Down Expand Up @@ -180,9 +180,9 @@ public function treeGetChildrenByIdAction(Request $request, EventDispatcherInter
'total' => $total,
'overflow' => !is_null($filter) && ($filteredTotalCount > $limit),

Check failure on line 181 in src/Controller/Admin/DataObject/DataObjectController.php

View workflow job for this annotation

GitHub Actions / static-analysis (8.3, highest, 11.x-dev as 11.99.9, true) / Static analysis with phpstan

Call to function is_null() with string will always evaluate to false.

Check failure on line 181 in src/Controller/Admin/DataObject/DataObjectController.php

View workflow job for this annotation

GitHub Actions / static-analysis (8.3, highest, false) / Static analysis with phpstan

Call to function is_null() with string will always evaluate to false.
'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'),
]);
}

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
18 changes: 9 additions & 9 deletions src/Controller/Admin/Document/DocumentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Expand All @@ -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');
Expand Down Expand Up @@ -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]);
Expand All @@ -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
Expand Down Expand Up @@ -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 = [
Expand Down
16 changes: 8 additions & 8 deletions src/Controller/Admin/Document/DocumentControllerBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down Expand Up @@ -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']);
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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]);
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions src/Controller/Admin/Document/EmailController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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');
}
Expand Down
4 changes: 2 additions & 2 deletions src/Controller/Admin/Document/FolderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand All @@ -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');
}
Expand Down
Loading

0 comments on commit 18e01ad

Please sign in to comment.