Skip to content

Commit

Permalink
CC-16912 Added validation of not supported formats when drawing a pro…
Browse files Browse the repository at this point in the history
…cess graph. (#9489)

CC-16912 Added validation of not supported formats when drawing a process graph.
  • Loading branch information
sprykerQwermus authored Jul 26, 2022
1 parent 27beda7 commit 3c816cc
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
1 change: 1 addition & 0 deletions data/translation/Zed/de_DE.csv
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ Processes,Prozesse
"Statemachine preview","State machine Vorschau"
"Total Price",Gesamtpreis
"Status change triggered successfully.","Die Statusänderung wurde erfolgreich ausgelöst."
"This file format is not supported. Please use file format SVG.","Dieses Dateiformat wird nicht unterstützt. Bitte verwenden Sie das Dateiformat SVG."
1 change: 1 addition & 0 deletions data/translation/Zed/en_US.csv
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ Processes,Processes
"Statemachine preview","State machine preview"
"Total Price","Total Price"
"Status change triggered successfully.","Status change triggered successfully."
"This file format is not supported. Please use file format SVG.","This file format is not supported. Please use file format SVG."
22 changes: 20 additions & 2 deletions src/Spryker/Zed/Oms/Communication/Controller/IndexController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@ class IndexController extends AbstractController
*/
public const DEFAULT_FONT_SIZE = 14;

/**
* @uses \Spryker\Zed\Oms\Communication\Controller\IndexController::indexAction()
*
* @var string
*/
protected const URL_OMS = '/oms';

/**
* @var string
*/
protected const ERROR_MESSAGE_FORMAT_NOT_SUPPORTED = 'This file format is not supported. Please use file format SVG.';

/**
* @var array<string, string>
*/
Expand Down Expand Up @@ -58,7 +70,7 @@ public function drawAction(Request $request)
/** @var string|null $processName */
$processName = $request->query->get('process');
if ($processName === null) {
return $this->redirectResponse('/oms');
return $this->redirectResponse(static::URL_OMS);
}

/** @var string|null $format */
Expand All @@ -82,6 +94,12 @@ public function drawAction(Request $request)
return $this->redirectResponse('/oms/index/draw?process=' . $processName . '&format=' . $format . '&font=' . $fontSize . '&state=' . $highlightState);
}

if (!isset($this->formatContentTypes[$format])) {
$this->addErrorMessage(static::ERROR_MESSAGE_FORMAT_NOT_SUPPORTED);

return $this->redirectResponse(static::URL_OMS);
}

$response = $this->getFacade()->drawProcess($processName, $highlightState, $format, $fontSize);

$callback = function () use ($response) {
Expand Down Expand Up @@ -121,7 +139,7 @@ public function drawPreviewVersionAction(Request $request)
{
$processName = $request->query->get('process');
if ($processName === null) {
return $this->redirectResponse('/oms');
return $this->redirectResponse(static::URL_OMS);
}

return $this->viewResponse([
Expand Down

0 comments on commit 3c816cc

Please sign in to comment.