1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* part-db version 0.1 |
4
|
|
|
* Copyright (C) 2005 Christoph Lechner |
5
|
|
|
* http://www.cl-projects.de/. |
6
|
|
|
* |
7
|
|
|
* part-db version 0.2+ |
8
|
|
|
* Copyright (C) 2009 K. Jacobs and others (see authors.php) |
9
|
|
|
* http://code.google.com/p/part-db/ |
10
|
|
|
* |
11
|
|
|
* Part-DB Version 0.4+ |
12
|
|
|
* Copyright (C) 2016 - 2019 Jan Böhmer |
13
|
|
|
* https://github.com/jbtronics |
14
|
|
|
* |
15
|
|
|
* This program is free software; you can redistribute it and/or |
16
|
|
|
* modify it under the terms of the GNU General Public License |
17
|
|
|
* as published by the Free Software Foundation; either version 2 |
18
|
|
|
* of the License, or (at your option) any later version. |
19
|
|
|
* |
20
|
|
|
* This program is distributed in the hope that it will be useful, |
21
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
22
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
23
|
|
|
* GNU General Public License for more details. |
24
|
|
|
* |
25
|
|
|
* You should have received a copy of the GNU General Public License |
26
|
|
|
* along with this program; if not, write to the Free Software |
27
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA |
28
|
|
|
*/ |
29
|
|
|
|
30
|
|
|
namespace App\Controller; |
31
|
|
|
|
32
|
|
|
use App\Entity\Category; |
33
|
|
|
use App\Helpers\TreeViewNode; |
34
|
|
|
use App\Services\ToolsTreeBuilder; |
35
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; |
36
|
|
|
use Symfony\Component\Routing\Annotation\Route; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* This controller has the purpose to provide the data for all treeviews. |
40
|
|
|
* |
41
|
|
|
* @package App\Controller |
42
|
|
|
*/ |
43
|
|
|
class TreeController extends AbstractController |
44
|
|
|
{ |
45
|
|
|
/** |
46
|
|
|
* @Route("/tree/tools/", name="tree_tools") |
47
|
|
|
*/ |
48
|
|
|
public function tools(ToolsTreeBuilder $builder) |
49
|
|
|
{ |
50
|
|
|
$tree = $builder->getTree(); |
51
|
|
|
|
52
|
|
|
//Ignore null values, to save data |
53
|
|
|
return $this->json($tree, 200, [], ['skip_null_values' => true]); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @Route("/tree/category/{id}", name="tree_category") |
58
|
|
|
*/ |
59
|
|
|
public function categoryTree(TreeBuilder $builder, Category $category = null) |
60
|
|
|
{ |
61
|
|
|
if($category != null) { |
62
|
|
|
$tree[] = $builder->elementToTreeNode($category); |
|
|
|
|
63
|
|
|
} else { |
64
|
|
|
$tree = $builder->typeToTree(Category::class); |
|
|
|
|
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
|
68
|
|
|
return $this->json($tree, 200, [], ['skip_null_values' => true]); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
|
72
|
|
|
|
73
|
|
|
|
74
|
|
|
} |
75
|
|
|
|