1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* Copyright (C) 2019 Mazarini <[email protected]>. |
5
|
|
|
* This file is part of mazarini/design. |
6
|
|
|
* |
7
|
|
|
* mazarini/design is free software: you can redistribute it and/or |
8
|
|
|
* modify it under the terms of the GNU General Public License as published by |
9
|
|
|
* the Free Software Foundation, either version 3 of the License, or (at your |
10
|
|
|
* option) any later version. |
11
|
|
|
* |
12
|
|
|
* mazarini/design is distributed in the hope that it will be useful, |
13
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
14
|
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
15
|
|
|
* more details. |
16
|
|
|
* |
17
|
|
|
* You should have received a copy of the GNU General Public License |
18
|
|
|
*/ |
19
|
|
|
|
20
|
|
|
namespace Mazarini\DesignBundle\Controller; |
21
|
|
|
|
22
|
|
|
use Mazarini\DesignBundle\Tools\Folder; |
23
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; |
24
|
|
|
use Symfony\Component\HttpFoundation\Request; |
25
|
|
|
use Symfony\Component\Routing\Annotation\Route; |
26
|
|
|
|
27
|
|
|
class DesignController extends AbstractController |
28
|
|
|
{ |
29
|
|
|
/** |
30
|
|
|
* @Route("info", name="design_info") |
31
|
|
|
*/ |
32
|
1 |
|
public function info(Request $request, Folder $folder) |
|
|
|
|
33
|
|
|
{ |
34
|
1 |
|
$param = []; |
35
|
1 |
|
$param['hasLayout'] = $folder->hasLayout(); |
36
|
1 |
|
$param['steps'] = $folder->getSteps(); |
37
|
|
|
|
38
|
1 |
|
return $this->render('@MazariniDesign/information.html.twig', $param); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @Route("/{debug}", name="design") |
43
|
|
|
*/ |
44
|
|
|
public function index(Request $request, Folder $folder, string $debug = '') |
45
|
|
|
{ |
46
|
|
|
if (!$folder->hasLayout()) { |
47
|
|
|
return $this->information($request, $folder); |
|
|
|
|
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
$step = $request->get('step'); |
51
|
|
|
$steps = $folder->getSteps(); |
52
|
|
|
if (!isset($steps[$step])) { |
53
|
|
|
$step = key($steps); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
$page = $request->get('page'); |
57
|
|
|
$pages = $folder->getPages($step); |
58
|
|
|
if (!isset($pages[$page])) { |
59
|
|
|
$page = key($pages); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
if ('' === $debug) { |
63
|
|
|
$template = '@MazariniDesign/steps/'.$step.'/'.$page; |
64
|
|
|
} else { |
65
|
|
|
$template = '@MazariniDesign/debug.html.twig'; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
return $this->render($template, [ |
69
|
|
|
'template' => $template, |
70
|
|
|
'current' => ['step' => $step, 'page' => $page], |
71
|
|
|
'steps' => $steps, |
72
|
|
|
'pages' => $pages, |
73
|
|
|
]); |
74
|
|
|
} |
75
|
|
|
} |
76
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.