|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the Sonata package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Thomas Rabaix <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Sonata\DoctrinePHPCRAdminBundle\Controller; |
|
13
|
|
|
|
|
14
|
|
|
use Symfony\Component\HttpFoundation\Response; |
|
15
|
|
|
use Symfony\Component\HttpFoundation\Request; |
|
16
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
|
17
|
|
|
use Symfony\Cmf\Bundle\TreeBrowserBundle\Tree\TreeInterface; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* A controller to render the tree block |
|
21
|
|
|
*/ |
|
22
|
|
|
class TreeController extends Controller |
|
23
|
|
|
{ |
|
24
|
|
|
/** |
|
25
|
|
|
* @var TreeInterface |
|
26
|
|
|
*/ |
|
27
|
|
|
private $tree; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @var string |
|
31
|
|
|
*/ |
|
32
|
|
|
private $template = 'SonataDoctrinePHPCRAdminBundle:Tree:tree.html.twig'; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @var array |
|
36
|
|
|
*/ |
|
37
|
|
|
private $defaults; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @var boolean |
|
41
|
|
|
*/ |
|
42
|
|
|
private $confirmMove = false; |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @param TreeInterface $tree |
|
46
|
|
|
* @param string $template |
|
47
|
|
|
* @param array $defaults |
|
48
|
|
|
* @param boolean $confirmMove |
|
49
|
|
|
*/ |
|
50
|
|
|
public function __construct(TreeInterface $tree, $template = null, array $defaults = array(), $confirmMove = false) |
|
51
|
|
|
{ |
|
52
|
|
|
$this->tree = $tree; |
|
53
|
|
|
if ($template) { |
|
|
|
|
|
|
54
|
|
|
$this->template = $template; |
|
55
|
|
|
} |
|
56
|
|
|
$this->defaults = $defaults; |
|
57
|
|
|
|
|
58
|
|
|
$this->confirmMove = $confirmMove; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* Renders a tree, passing the routes for each of the admin types (document types) |
|
63
|
|
|
* to the view |
|
64
|
|
|
* |
|
65
|
|
|
* @param Request $request |
|
66
|
|
|
* |
|
67
|
|
|
* @return Response |
|
68
|
|
|
*/ |
|
69
|
|
|
public function treeAction(Request $request) |
|
70
|
|
|
{ |
|
71
|
|
|
$createInOverlay = $request->attributes->get('create_in_overlay'); |
|
72
|
|
|
$editInOverlay = $request->attributes->get('edit_in_overlay'); |
|
73
|
|
|
$deleteInOverlay = $request->attributes->get('delete_in_overlay'); |
|
74
|
|
|
|
|
75
|
|
|
$root = $request->attributes->get('root'); |
|
76
|
|
|
$selected = $request->attributes->get('selected') ?: $root; |
|
77
|
|
|
|
|
78
|
|
|
return $this->render($this->template, array( |
|
79
|
|
|
'tree' => $this->tree, |
|
80
|
|
|
'root_node' => $root, |
|
81
|
|
|
'selected_node' => $selected, |
|
82
|
|
|
'routing_defaults' => $this->defaults, |
|
83
|
|
|
'confirm_move' => $this->confirmMove, |
|
84
|
|
|
'create_in_overlay' => $createInOverlay ? $createInOverlay : false, |
|
85
|
|
|
'edit_in_overlay' => $editInOverlay ? $editInOverlay : false, |
|
86
|
|
|
'delete_in_overlay' => $deleteInOverlay ? $deleteInOverlay : false, |
|
87
|
|
|
)); |
|
88
|
|
|
} |
|
89
|
|
|
} |
|
90
|
|
|
|
In PHP, under loose comparison (like
==, or!=, orswitchconditions), values of different types might be equal.For
stringvalues, the empty string''is a special case, in particular the following results might be unexpected: