Skip to content
This repository was archived by the owner on Sep 16, 2021. It is now read-only.

Commit a760557

Browse files
committed
Merge pull request #50 from symfony-cmf/cleanup_controller
remove dynamic method calls in the controller
2 parents cc555df + dbfab6e commit a760557

File tree

1 file changed

+12
-19
lines changed

1 file changed

+12
-19
lines changed

Controller/TreeBrowserController.php

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,23 +32,6 @@ public function __construct(TreeInterface $tree)
3232
$this->tree = $tree;
3333
}
3434

35-
/**
36-
* Helper method to deliver a json node
37-
*
38-
* @param string $path Node to process
39-
* @param string $method Method to execute on the node
40-
*
41-
* @return Response
42-
*/
43-
protected function processNode($path, $method)
44-
{
45-
if (empty($path)) {
46-
$path = '/';
47-
}
48-
49-
return new JsonResponse($this->tree->$method($path));
50-
}
51-
5235
/**
5336
* Get a json encoded list of children the specified node has
5437
*
@@ -61,7 +44,12 @@ protected function processNode($path, $method)
6144
public function childrenAction(Request $request)
6245
{
6346
$path = $request->query->get('root');
64-
return $this->processNode($path, "getChildren");
47+
48+
if (empty($path)) {
49+
$path = '/';
50+
}
51+
52+
return new JsonResponse($this->tree->getChildren($path));
6553
}
6654

6755
/**
@@ -75,7 +63,12 @@ public function childrenAction(Request $request)
7563
public function propertiesAction(Request $request)
7664
{
7765
$path = $request->query->get('root');
78-
return $this->processNode($path, "getProperties");
66+
67+
if (empty($path)) {
68+
$path = '/';
69+
}
70+
71+
return new JsonResponse($this->tree->getProperties($path));
7972
}
8073

8174
/**

0 commit comments

Comments
 (0)