-
Notifications
You must be signed in to change notification settings - Fork 0
/
Web2printController.php
83 lines (68 loc) · 2.13 KB
/
Web2printController.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
/**
* Studio1 Kommunikation GmbH
*
* This source file is available under following license:
* - GNU General Public License v3.0 (GNU GPLv3)
*
* @copyright Copyright (c) Studio1 Kommunikation GmbH (http://www.studio1.de)
* @license https://www.gnu.org/licenses/gpl-3.0.txt
*/
namespace Studio1\Web2PrintBricksBundle\Controller;
use Pimcore\Controller\FrontendController;
use Pimcore\Model\Document\Hardlink;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
/**
* Web2PrintController
*/
class Web2printController extends FrontendController
{
/**
* @param Request $request
*
* @return Response
*/
public function defaultAction(Request $request)
{
$paramsBag = [
'document' => $this->document
];
foreach ($request->attributes as $key => $value) {
$paramsBag[$key] = $value;
}
$paramsBag = array_merge($request->request->all(), $request->query->all(), $paramsBag);
if ($this->document->getProperty('hide-layout')) {
return $this->render('@Web2PrintBricks/web2print/default_no_layout.html.twig', $paramsBag);
} else {
return $this->render('@Web2PrintBricks/web2print/default.html.twig', $paramsBag);
}
}
/**
* @param Request $request
*
* @return Response
*
* @throws \Exception
*/
public function containerAction(Request $request)
{
$paramsBag = [
'document' => $this->document
];
foreach ($request->attributes as $key => $value) {
$paramsBag[$key] = $value;
}
$allChildren = [];
//prepare children for include
foreach ($this->document->getAllChildren() as $child) {
if ($child instanceof Hardlink) {
$child = Hardlink\Service::wrap($child);
}
$child->setProperty('hide-layout', 'bool', true, false, true);
$allChildren[] = $child;
}
$paramsBag['allChildren'] = $allChildren;
return $this->render('web2print/container.html.twig', $paramsBag);
}
}