Skip to content

Commit

Permalink
request explicit input
Browse files Browse the repository at this point in the history
  • Loading branch information
kingjia90 committed Aug 13, 2024
1 parent 418de7c commit a59967b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
46 changes: 23 additions & 23 deletions src/Controller/Document/PrintpageControllerBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ abstract class PrintpageControllerBase extends DocumentControllerBase
*/
public function getDataByIdAction(Request $request): JsonResponse
{
$page = PrintAbstract::getById((int)$request->get('id'));
$page = PrintAbstract::getById($request->query->getInt('id'));

if (!$page) {
throw $this->createNotFoundException('Document not found');
Expand Down Expand Up @@ -90,7 +90,7 @@ static function (Task $task) {
*/
public function saveAction(Request $request): JsonResponse
{
$page = PrintAbstract::getById((int) $request->get('id'));
$page = PrintAbstract::getById($request->request->getInt('id'));
if (!$page) {
throw $this->createNotFoundException('Document not found');
}
Expand All @@ -99,7 +99,7 @@ public function saveAction(Request $request): JsonResponse

Document\Service::saveElementToSession($page, $request->getSession()->getId());

if ($request->get('task') !== self::TASK_SAVE) {
if ($request->query->getString('task') !== self::TASK_SAVE) {
//check, if to cleanup existing elements of document
$config = Config::get();
if ($config['generalDocumentSaveMode'] == 'cleanup') {
Expand Down Expand Up @@ -145,10 +145,10 @@ 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');
$intendedPath = $parentDocument->getRealFullPath() . '/' . $request->request->getString('key');

if (!Document\Service::pathExists($intendedPath)) {
$createValues = [
Expand All @@ -157,27 +157,27 @@ public function addAction(Request $request): JsonResponse
'published' => false,
];

$createValues['key'] = \Pimcore\Model\Element\Service::getValidKey($request->get('key'), 'document');
$createValues['key'] = \Pimcore\Model\Element\Service::getValidKey($request->request->getString('key'), 'document');

// check for a docType
$docType = Document\DocType::getById($request->get('docTypeId', ''));
$docType = Document\DocType::getById($request->request->getString('docTypeId', ''));
if ($docType) {
$createValues['template'] = $docType->getTemplate();
$createValues['controller'] = $docType->getController();
} else {
$config = $this->getParameter('pimcore_web_to_print');
if ($request->get('type') === 'printpage') {
if ($request->request->getString('type') === 'printpage') {
$createValues['controller'] = $config['default_controller_print_page'];
} elseif ($request->get('type') === 'printcontainer') {
} elseif ($request->request->getString('type') === 'printcontainer') {
$createValues['controller'] = $config['default_controller_print_container'];
}
}

if ($request->get('inheritanceSource')) {
$createValues['contentMainDocumentId'] = $request->get('inheritanceSource');
if ($request->request->has('inheritanceSource')) {
$createValues['contentMainDocumentId'] = $request->request->getInt('inheritanceSource');
}

$className = \Pimcore::getContainer()->get('pimcore.class.resolver.document')->resolve($request->get('type'));
$className = \Pimcore::getContainer()->get('pimcore.class.resolver.document')->resolve($request->request->getString('type'));

/** @var Document $document */
$document = \Pimcore::getContainer()->get('pimcore.model.factory')->build($className);
Expand All @@ -200,13 +200,13 @@ public function addAction(Request $request): JsonResponse
}

if ($success && $document instanceof Document) {
if ($translationsBaseDocumentId = $request->get('translationsBaseDocument')) {
$translationsBaseDocument = Document::getById((int) $translationsBaseDocumentId);
if ($translationsBaseDocumentId = $request->request->getInt('translationsBaseDocument')) {
$translationsBaseDocument = Document::getById($translationsBaseDocumentId);

$properties = $translationsBaseDocument->getProperties();
$properties = array_merge($properties, $document->getProperties());
$document->setProperties($properties);
$document->setProperty('language', 'text', $request->get('language'), false, true);
$document->setProperty('language', 'text', $request->request->getString('language'), false, true);
$document->save();

$service = new Document\Service();
Expand Down Expand Up @@ -240,10 +240,10 @@ protected function setValuesToDocument(Request $request, Document $document): vo
*/
public function activeGenerateProcessAction(Request $request): JsonResponse
{
$document = PrintAbstract::getById((int)$request->get('id'));
$document = PrintAbstract::getById($request->request->getInt('id'));

if (!$document) {
throw $this->createNotFoundException('Document with id ' . $request->get('id') . ' not found.');
throw $this->createNotFoundException('Document with id ' . $request->request->getInt('id') . ' not found.');
}

$date = $document->getLastGeneratedDate();
Expand Down Expand Up @@ -274,16 +274,16 @@ public function activeGenerateProcessAction(Request $request): JsonResponse
*/
public function pdfDownloadAction(Request $request): BinaryFileResponse
{
$document = PrintAbstract::getById((int)$request->get('id'));
$document = PrintAbstract::getById($request->query->getInt('id'));

if (!$document) {
throw $this->createNotFoundException('Document with id ' . $request->get('id') . ' not found.');
throw $this->createNotFoundException('Document with id ' . $request->query->getInt('id') . ' not found.');
}

if ($this->checkFileExists($document->getPdfFileName())) {
$response = new BinaryFileResponse($document->getPdfFileName());
$response->headers->set('Content-Type', 'application/pdf');
if ($request->get('download')) {
if ($request->query->has('download')) {
$response->setContentDisposition('attachment', $document->getKey() . '.pdf');
}

Expand Down Expand Up @@ -333,7 +333,7 @@ public function startPdfGenerationAction(Request $request, \Pimcore\Config $conf
*/
public function checkPdfDirtyAction(Request $request): JsonResponse
{
$printDocument = PrintAbstract::getById((int) $request->get('id'));
$printDocument = PrintAbstract::getById($request->query->getInt('id'));

$dirty = true;
if ($printDocument) {
Expand All @@ -354,7 +354,7 @@ public function getProcessingOptionsAction(Request $request): JsonResponse

$returnValue = [];

$storedValues = $this->getStoredProcessingOptions((int) $request->query->get('id'));
$storedValues = $this->getStoredProcessingOptions($request->query->getInt('id'));

foreach ($options as $option) {
$value = $option['default'];
Expand Down Expand Up @@ -399,7 +399,7 @@ private function saveProcessingOptions(int $documentId, array $options): void
*/
public function cancelGenerationAction(Request $request): JsonResponse
{
Processor::getInstance()->cancelGeneration((int)$request->get('id'));
Processor::getInstance()->cancelGeneration($request->request->getInt('id'));

return $this->adminJson(['success' => true]);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function setWeb2printAction(Request $request): JsonResponse
{
$this->checkPermission('web2print_settings');

$values = $this->decodeJson($request->get('data'));
$values = $this->decodeJson($request->request->getString('data'));

unset(
$values['documentation'],
Expand Down

0 comments on commit a59967b

Please sign in to comment.