-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
Co-authored-by: Ioannis Pourliotis <PheysX@users.noreply.github.com>
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,8 @@ | |
use Symfony\Component\HttpFoundation\JsonResponse; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\Routing\Annotation\Route; | ||
use Shopware\Core\Framework\Uuid\Uuid; | ||
use Shopware\Core\System\StateMachine\StateMachineEntity; | ||
|
||
#[Route(path: '/api/_action/frosh-tools', defaults: ['_routeScope' => ['api'], '_acl' => ['frosh_tools:read']])] | ||
final class StateMachineController extends AbstractController | ||
|
@@ -22,26 +24,26 @@ public function __construct(private readonly EntityRepository $stateMachineRepos | |
{ | ||
} | ||
|
||
#[Route(path: '/state-machines/load', name: 'api.frosh.tools.state-machines.load', methods: ['GET'])] | ||
public function load(Request $request): JsonResponse | ||
#[Route(path: '/state-machines/load/{stateMachineId}', name: 'api.frosh.tools.state-machines.load', methods: ['GET'])] | ||
public function load(string $stateMachineId, Request $request): JsonResponse | ||
{ | ||
$stateMachineType = $request->query->get('stateMachine'); | ||
|
||
if (empty($stateMachineType)) { | ||
if (!Uuid::isValid($stateMachineId)) { | ||
return new JsonResponse(); | ||
} | ||
|
||
$tmp = explode('.', $stateMachineType); | ||
$title = ucwords(str_replace('_', ' ', $tmp[0])); | ||
|
||
$criteria = new Criteria(); | ||
$criteria->addFilter(new EqualsFilter('technicalName', $stateMachineType)); | ||
$criteria = new Criteria([$stateMachineId]); | ||
$criteria->addAssociations([ | ||
'states', | ||
'transitions', | ||
]); | ||
|
||
$stateMachine = $this->stateMachineRepository->search($criteria, Context::createDefaultContext())->first(); | ||
Check notice on line 40 in src/Controller/StateMachineController.php GitHub Actions / Qodana for PHPUsage of internal entity
Check notice on line 40 in src/Controller/StateMachineController.php GitHub Actions / Qodana for PHPUsage of internal entity
Check notice on line 40 in src/Controller/StateMachineController.php GitHub Actions / Qodana for PHPUsage of internal entity
Check notice on line 40 in src/Controller/StateMachineController.php GitHub Actions / Qodana for PHPUsage of internal entity
Check notice on line 40 in src/Controller/StateMachineController.php GitHub Actions / Qodana for PHPUsage of internal entity
Check notice on line 40 in src/Controller/StateMachineController.php GitHub Actions / Qodana for PHPUsage of internal entity
Check notice on line 40 in src/Controller/StateMachineController.php GitHub Actions / Qodana for PHPUsage of internal entity
Check notice on line 40 in src/Controller/StateMachineController.php GitHub Actions / Qodana for PHPUsage of internal entity
Check notice on line 40 in src/Controller/StateMachineController.php GitHub Actions / Qodana for PHPUsage of internal entity
Check notice on line 40 in src/Controller/StateMachineController.php GitHub Actions / Qodana for PHPUsage of internal entity
|
||
if (!$stateMachine instanceof StateMachineEntity) { | ||
return new JsonResponse(); | ||
} | ||
|
||
$tmp = explode('.', $stateMachine->getTechnicalName()); | ||
$title = ucwords(str_replace('_', ' ', $tmp[0])); | ||
|
||
$exporter = new Plantuml(); | ||
$generatedPlantuml = $exporter->export($stateMachine, $title); | ||
|